From 1bf9d231deb0d7e859f61a53c87a0fa865468d3f Mon Sep 17 00:00:00 2001 From: GitHub Date: Wed, 2 Nov 2022 07:48:16 +0000 Subject: [PATCH] feat(schema): update Telegram to the latest layer --- _schema/tdesktop.tl | 124 +- _schema/telegram.tl | 124 +- telegram/query/messages/queries.gen.go | 14 + tg/tl_account_get_theme_gen.go | 51 +- tg/tl_account_reorder_usernames_gen.go | 190 +++ tg/tl_account_reorder_usernames_slices_gen.go | 35 + tg/tl_account_toggle_username_gen.go | 201 ++++ tg/tl_account_toggle_username_slices_gen.go | 35 + tg/tl_channel_admin_log_event_action_gen.go | 1051 +++++++++++++++++ ...annel_admin_log_event_action_slices_gen.go | 570 +++++++++ tg/tl_channel_admin_log_events_filter_gen.go | 35 + tg/tl_channels_create_forum_topic_gen.go | 404 +++++++ ..._channels_create_forum_topic_slices_gen.go | 35 + ...l_channels_deactivate_all_usernames_gen.go | 187 +++ ...els_deactivate_all_usernames_slices_gen.go | 35 + tg/tl_channels_delete_topic_history_gen.go | 210 ++++ ...hannels_delete_topic_history_slices_gen.go | 35 + tg/tl_channels_edit_forum_topic_gen.go | 372 ++++++ tg/tl_channels_edit_forum_topic_slices_gen.go | 35 + tg/tl_channels_get_forum_topics_by_id_gen.go | 223 ++++ ...nnels_get_forum_topics_by_id_slices_gen.go | 35 + tg/tl_channels_get_forum_topics_gen.go | 357 ++++++ tg/tl_channels_get_forum_topics_slices_gen.go | 35 + tg/tl_channels_get_sponsored_messages_gen.go | 6 +- tg/tl_channels_reorder_usernames_gen.go | 224 ++++ ...l_channels_reorder_usernames_slices_gen.go | 35 + tg/tl_channels_toggle_forum_gen.go | 210 ++++ tg/tl_channels_toggle_forum_slices_gen.go | 35 + tg/tl_channels_toggle_username_gen.go | 238 ++++ tg/tl_channels_toggle_username_slices_gen.go | 35 + ..._channels_update_pinned_forum_topic_gen.go | 237 ++++ ...ls_update_pinned_forum_topic_slices_gen.go | 35 + tg/tl_chat_admin_rights_gen.go | 35 + tg/tl_chat_banned_rights_gen.go | 35 + tg/tl_chat_gen.go | 169 ++- tg/tl_forum_topic_gen.go | 918 ++++++++++++++ tg/tl_forum_topic_slices_gen.go | 427 +++++++ tg/tl_handlers_gen.go | 10 + tg/tl_input_notify_peer_gen.go | 174 +++ tg/tl_input_notify_peer_slices_gen.go | 95 ++ tg/tl_input_sticker_set_gen.go | 109 ++ tg/tl_message_action_gen.go | 512 ++++++++ tg/tl_message_action_slices_gen.go | 190 +++ tg/tl_message_reply_header_gen.go | 35 + tg/tl_messages_forum_topics_gen.go | 441 +++++++ tg/tl_messages_forum_topics_slices_gen.go | 35 + tg/tl_messages_forward_messages_gen.go | 96 +- tg/tl_messages_get_search_counters_gen.go | 96 +- tg/tl_messages_get_unread_mentions_gen.go | 98 +- tg/tl_messages_get_unread_reactions_gen.go | 98 +- tg/tl_messages_prolong_web_view_gen.go | 90 +- tg/tl_messages_read_mentions_gen.go | 93 +- tg/tl_messages_read_reactions_gen.go | 93 +- tg/tl_messages_request_web_view_gen.go | 98 +- tg/tl_messages_save_draft_gen.go | 86 +- tg/tl_messages_send_inline_bot_result_gen.go | 90 +- tg/tl_messages_send_media_gen.go | 108 +- tg/tl_messages_send_message_gen.go | 102 +- tg/tl_messages_send_multi_media_gen.go | 90 +- tg/tl_messages_sponsored_messages_gen.go | 310 ++++- ..._messages_sponsored_messages_slices_gen.go | 232 ++++ tg/tl_messages_sticker_set_gen.go | 78 +- tg/tl_messages_unpin_all_messages_gen.go | 93 +- tg/tl_notify_peer_gen.go | 174 +++ tg/tl_notify_peer_slices_gen.go | 95 ++ tg/tl_registry_gen.go | 160 ++- tg/tl_server_gen.go | 240 +++- tg/tl_sponsored_message_gen.go | 35 + tg/tl_sticker_keyword_gen.go | 201 ++++ tg/tl_sticker_keyword_slices_gen.go | 35 + tg/tl_sticker_set_covered_gen.go | 78 +- tg/tl_update_gen.go | 557 +++++++-- tg/tl_update_slices_gen.go | 95 ++ tg/tl_user_gen.go | 140 ++- tg/tl_username_gen.go | 249 ++++ tg/tl_username_slices_gen.go | 35 + 76 files changed, 12076 insertions(+), 602 deletions(-) create mode 100644 tg/tl_account_reorder_usernames_gen.go create mode 100644 tg/tl_account_reorder_usernames_slices_gen.go create mode 100644 tg/tl_account_toggle_username_gen.go create mode 100644 tg/tl_account_toggle_username_slices_gen.go create mode 100644 tg/tl_channels_create_forum_topic_gen.go create mode 100644 tg/tl_channels_create_forum_topic_slices_gen.go create mode 100644 tg/tl_channels_deactivate_all_usernames_gen.go create mode 100644 tg/tl_channels_deactivate_all_usernames_slices_gen.go create mode 100644 tg/tl_channels_delete_topic_history_gen.go create mode 100644 tg/tl_channels_delete_topic_history_slices_gen.go create mode 100644 tg/tl_channels_edit_forum_topic_gen.go create mode 100644 tg/tl_channels_edit_forum_topic_slices_gen.go create mode 100644 tg/tl_channels_get_forum_topics_by_id_gen.go create mode 100644 tg/tl_channels_get_forum_topics_by_id_slices_gen.go create mode 100644 tg/tl_channels_get_forum_topics_gen.go create mode 100644 tg/tl_channels_get_forum_topics_slices_gen.go create mode 100644 tg/tl_channels_reorder_usernames_gen.go create mode 100644 tg/tl_channels_reorder_usernames_slices_gen.go create mode 100644 tg/tl_channels_toggle_forum_gen.go create mode 100644 tg/tl_channels_toggle_forum_slices_gen.go create mode 100644 tg/tl_channels_toggle_username_gen.go create mode 100644 tg/tl_channels_toggle_username_slices_gen.go create mode 100644 tg/tl_channels_update_pinned_forum_topic_gen.go create mode 100644 tg/tl_channels_update_pinned_forum_topic_slices_gen.go create mode 100644 tg/tl_forum_topic_gen.go create mode 100644 tg/tl_forum_topic_slices_gen.go create mode 100644 tg/tl_messages_forum_topics_gen.go create mode 100644 tg/tl_messages_forum_topics_slices_gen.go create mode 100644 tg/tl_sticker_keyword_gen.go create mode 100644 tg/tl_sticker_keyword_slices_gen.go create mode 100644 tg/tl_username_gen.go create mode 100644 tg/tl_username_slices_gen.go diff --git a/_schema/tdesktop.tl b/_schema/tdesktop.tl index 6a2ac17b8d..656be6478e 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/Resources/tl/api.tl -// Layer: 146 -// SHA256: ba16bf92d16a2cdcb07672ac0b463e9fea6bc3d9b5641adced6f9cd9f006ebdc +// Layer: 148 +// SHA256: 19fd5971d04078f793254cd1e591d1e9ad9aed8ace833187bc55edb5c7ffa541 boolFalse#bc799737 = Bool; @@ -134,7 +134,7 @@ storage.fileWebp#1081464c = storage.FileType; userEmpty#d3bc4b7a id:long = User; -user#5d99adee flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true fake:flags.26?true bot_attach_menu:flags.27?true premium:flags.28?true attach_menu_enabled:flags.29?true id:long access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector bot_inline_placeholder:flags.19?string lang_code:flags.22?string emoji_status:flags.30?EmojiStatus = User; +user#8f97c628 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true fake:flags.26?true bot_attach_menu:flags.27?true premium:flags.28?true attach_menu_enabled:flags.29?true flags2:# id:long access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector bot_inline_placeholder:flags.19?string lang_code:flags.22?string emoji_status:flags.30?EmojiStatus usernames:flags2.0?Vector = User; userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto; @@ -158,7 +158,7 @@ chat#41cbf256 flags:# creator:flags.0?true left:flags.2?true deactivated:flags.5 chatForbidden#6592a1a7 id:long title:string = Chat; -channel#8261ac61 flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true scam:flags.19?true has_link:flags.20?true has_geo:flags.21?true slowmode_enabled:flags.22?true call_active:flags.23?true call_not_empty:flags.24?true fake:flags.25?true gigagroup:flags.26?true noforwards:flags.27?true join_to_send:flags.28?true join_request:flags.29?true id:long access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int restriction_reason:flags.9?Vector admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int = Chat; +channel#83259464 flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true scam:flags.19?true has_link:flags.20?true has_geo:flags.21?true slowmode_enabled:flags.22?true call_active:flags.23?true call_not_empty:flags.24?true fake:flags.25?true gigagroup:flags.26?true noforwards:flags.27?true join_to_send:flags.28?true join_request:flags.29?true forum:flags.30?true flags2:# id:long access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int restriction_reason:flags.9?Vector admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int usernames:flags2.0?Vector = Chat; channelForbidden#17d493d5 flags:# broadcast:flags.5?true megagroup:flags.8?true id:long access_hash:long title:string until_date:flags.16?int = Chat; @@ -278,6 +278,10 @@ messageActionWebViewDataSent#b4c38cb5 text:string = MessageAction; messageActionGiftPremium#aba0f5c6 currency:string amount:long months:int = MessageAction; +messageActionTopicCreate#d999256 flags:# title:string icon_color:int icon_emoji_id:flags.0?long = MessageAction; + +messageActionTopicEdit#b18a431c flags:# title:flags.0?string icon_emoji_id:flags.1?long closed:flags.2?Bool = MessageAction; + dialog#a8edd0f5 flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int = Dialog; dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog; @@ -318,6 +322,8 @@ inputNotifyChats#4a95e84e = InputNotifyPeer; inputNotifyBroadcasts#b1db7c7e = InputNotifyPeer; +inputNotifyForumTopic#5c467992 peer:InputPeer top_msg_id:int = InputNotifyPeer; + inputPeerNotifySettings#df1f002b flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int sound:flags.3?NotificationSound = InputPeerNotifySettings; peerNotifySettings#a83b0426 flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int ios_sound:flags.3?NotificationSound android_sound:flags.4?NotificationSound other_sound:flags.5?NotificationSound = PeerNotifySettings; @@ -436,7 +442,7 @@ updateChatParticipants#7761198 participants:ChatParticipants = Update; updateUserStatus#e5bdf8de user_id:long status:UserStatus = Update; -updateUserName#c3f202e0 user_id:long first_name:string last_name:string username:string = Update; +updateUserName#a7848924 user_id:long first_name:string last_name:string usernames:Vector = Update; updateUserPhoto#f227868c user_id:long date:int photo:UserProfilePhoto previous:Bool = Update; @@ -506,7 +512,7 @@ updateInlineBotCallbackQuery#691e9052 flags:# query_id:long user_id:long msg_id: updateReadChannelOutbox#b75f99a9 channel_id:long max_id:int = Update; -updateDraftMessage#ee2bb969 peer:Peer draft:DraftMessage = Update; +updateDraftMessage#1b49ec6d flags:# peer:Peer top_msg_id:flags.0?int draft:DraftMessage = Update; updateReadFeaturedStickers#571d2742 = Update; @@ -538,7 +544,7 @@ updateLangPack#56022f4d difference:LangPackDifference = Update; updateFavedStickers#e511996d = Update; -updateChannelReadMessagesContents#44bdd535 channel_id:long messages:Vector = Update; +updateChannelReadMessagesContents#ea29055d flags:# channel_id:long top_msg_id:flags.0?int messages:Vector = Update; updateContactsReset#7084a7be = Update; @@ -612,7 +618,7 @@ updatePendingJoinRequests#7063c3db peer:Peer requests_pending:int recent_request updateBotChatInviteRequester#11dfa986 peer:Peer date:int user_id:long about:string invite:ExportedChatInvite qts:int = Update; -updateMessageReactions#154798c3 peer:Peer msg_id:int reactions:MessageReactions = Update; +updateMessageReactions#5e1b3cb8 flags:# peer:Peer msg_id:int top_msg_id:flags.0?int reactions:MessageReactions = Update; updateAttachMenuBots#17b7a20b = Update; @@ -636,6 +642,8 @@ updateMoveStickerSetToTop#86fccf85 flags:# masks:flags.0?true emojis:flags.1?tru updateMessageExtendedMedia#5a73a98c peer:Peer msg_id:int extended_media:MessageExtendedMedia = Update; +updateChannelPinnedTopic#f694b0ae flags:# channel_id:long topic_id:flags.0?int = Update; + updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; updates.differenceEmpty#5d75a138 date:int seq:int = updates.Difference; @@ -736,6 +744,8 @@ notifyChats#c007cec3 = NotifyPeer; notifyBroadcasts#d612e8ef = NotifyPeer; +notifyForumTopic#226e6308 peer:Peer top_msg_id:int = NotifyPeer; + sendMessageTypingAction#16bf744e = SendMessageAction; sendMessageCancelAction#fd5ec8f5 = SendMessageAction; @@ -924,9 +934,11 @@ inputStickerSetEmojiGenericAnimations#4c4d4ce = InputStickerSet; inputStickerSetEmojiDefaultStatuses#29d0f5ee = InputStickerSet; +inputStickerSetEmojiDefaultTopicIcons#44c1f8e9 = InputStickerSet; + stickerSet#2dd14edc flags:# archived:flags.1?true official:flags.2?true masks:flags.3?true animated:flags.5?true videos:flags.6?true emojis:flags.7?true installed_date:flags.0?int id:long access_hash:long title:string short_name:string thumbs:flags.4?Vector thumb_dc_id:flags.4?int thumb_version:flags.4?int thumb_document_id:flags.8?long count:int hash:int = StickerSet; -messages.stickerSet#b60a24a6 set:StickerSet packs:Vector documents:Vector = messages.StickerSet; +messages.stickerSet#6e153f16 set:StickerSet packs:Vector keywords:Vector documents:Vector = messages.StickerSet; messages.stickerSetNotModified#d3f924eb = messages.StickerSet; @@ -1202,7 +1214,7 @@ stickerSetCovered#6410a5d2 set:StickerSet cover:Document = StickerSetCovered; stickerSetMultiCovered#3407e51b set:StickerSet covers:Vector = StickerSetCovered; -stickerSetFullCovered#1aed5ee5 set:StickerSet packs:Vector documents:Vector = StickerSetCovered; +stickerSetFullCovered#40d13c0e set:StickerSet packs:Vector keywords:Vector documents:Vector = StickerSetCovered; maskCoords#aed6dbb2 n:int x:double y:double zoom:double = MaskCoords; @@ -1484,11 +1496,23 @@ channelAdminLogEventActionSendMessage#278f2868 message:Message = ChannelAdminLog channelAdminLogEventActionChangeAvailableReactions#be4e0ef8 prev_value:ChatReactions new_value:ChatReactions = ChannelAdminLogEventAction; +channelAdminLogEventActionChangeUsernames#f04fb3a9 prev_value:Vector new_value:Vector = ChannelAdminLogEventAction; + +channelAdminLogEventActionToggleForum#2cc6383 new_value:Bool = ChannelAdminLogEventAction; + +channelAdminLogEventActionCreateTopic#58707d28 topic:ForumTopic = ChannelAdminLogEventAction; + +channelAdminLogEventActionEditTopic#f06fe208 prev_topic:ForumTopic new_topic:ForumTopic = ChannelAdminLogEventAction; + +channelAdminLogEventActionDeleteTopic#ae168909 topic:ForumTopic = ChannelAdminLogEventAction; + +channelAdminLogEventActionPinTopic#5d8d353b flags:# prev_topic:flags.0?ForumTopic new_topic:flags.1?ForumTopic = ChannelAdminLogEventAction; + channelAdminLogEvent#1fad68cd id:long date:int user_id:long action:ChannelAdminLogEventAction = ChannelAdminLogEvent; channels.adminLogResults#ed8af74d events:Vector chats:Vector users:Vector = channels.AdminLogResults; -channelAdminLogEventsFilter#ea107ae4 flags:# join:flags.0?true leave:flags.1?true invite:flags.2?true ban:flags.3?true unban:flags.4?true kick:flags.5?true unkick:flags.6?true promote:flags.7?true demote:flags.8?true info:flags.9?true settings:flags.10?true pinned:flags.11?true edit:flags.12?true delete:flags.13?true group_call:flags.14?true invites:flags.15?true send:flags.16?true = ChannelAdminLogEventsFilter; +channelAdminLogEventsFilter#ea107ae4 flags:# join:flags.0?true leave:flags.1?true invite:flags.2?true ban:flags.3?true unban:flags.4?true kick:flags.5?true unkick:flags.6?true promote:flags.7?true demote:flags.8?true info:flags.9?true settings:flags.10?true pinned:flags.11?true edit:flags.12?true delete:flags.13?true group_call:flags.14?true invites:flags.15?true send:flags.16?true forums:flags.17?true = ChannelAdminLogEventsFilter; popularContact#5ce14175 client_id:long importers:int = PopularContact; @@ -1696,9 +1720,9 @@ chatOnlines#f041e250 onlines:int = ChatOnlines; statsURL#47a971e0 url:string = StatsURL; -chatAdminRights#5fb224d5 flags:# change_info:flags.0?true post_messages:flags.1?true edit_messages:flags.2?true delete_messages:flags.3?true ban_users:flags.4?true invite_users:flags.5?true pin_messages:flags.7?true add_admins:flags.9?true anonymous:flags.10?true manage_call:flags.11?true other:flags.12?true = ChatAdminRights; +chatAdminRights#5fb224d5 flags:# change_info:flags.0?true post_messages:flags.1?true edit_messages:flags.2?true delete_messages:flags.3?true ban_users:flags.4?true invite_users:flags.5?true pin_messages:flags.7?true add_admins:flags.9?true anonymous:flags.10?true manage_call:flags.11?true other:flags.12?true manage_topics:flags.13?true = ChatAdminRights; -chatBannedRights#9f120418 flags:# view_messages:flags.0?true send_messages:flags.1?true send_media:flags.2?true send_stickers:flags.3?true send_gifs:flags.4?true send_games:flags.5?true send_inline:flags.6?true embed_links:flags.7?true send_polls:flags.8?true change_info:flags.10?true invite_users:flags.15?true pin_messages:flags.17?true until_date:int = ChatBannedRights; +chatBannedRights#9f120418 flags:# view_messages:flags.0?true send_messages:flags.1?true send_media:flags.2?true send_stickers:flags.3?true send_gifs:flags.4?true send_games:flags.5?true send_inline:flags.6?true embed_links:flags.7?true send_polls:flags.8?true change_info:flags.10?true invite_users:flags.15?true pin_messages:flags.17?true manage_topics:flags.18?true until_date:int = ChatBannedRights; inputWallPaper#e630b979 id:long access_hash:long = InputWallPaper; @@ -1852,7 +1876,7 @@ messages.messageViews#b6c4f543 views:Vector chats:Vector use messages.discussionMessage#a6341782 flags:# messages:Vector max_id:flags.0?int read_inbox_max_id:flags.1?int read_outbox_max_id:flags.2?int unread_count:int chats:Vector users:Vector = messages.DiscussionMessage; -messageReplyHeader#a6d57763 flags:# reply_to_scheduled:flags.2?true reply_to_msg_id:int reply_to_peer_id:flags.0?Peer reply_to_top_id:flags.1?int = MessageReplyHeader; +messageReplyHeader#a6d57763 flags:# reply_to_scheduled:flags.2?true forum_topic:flags.3?true reply_to_msg_id:int reply_to_peer_id:flags.0?Peer reply_to_top_id:flags.1?int = MessageReplyHeader; messageReplies#83d60fc2 flags:# comments:flags.0?true replies:int replies_pts:int recent_repliers:flags.1?Vector channel_id:flags.0?long max_id:flags.2?int read_max_id:flags.3?int = MessageReplies; @@ -1934,9 +1958,11 @@ account.resetPasswordRequestedWait#e9effc7d until_date:int = account.ResetPasswo account.resetPasswordOk#e926d63e = account.ResetPasswordResult; -sponsoredMessage#3a836df8 flags:# recommended:flags.5?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 message:string entities:flags.1?Vector = SponsoredMessage; +sponsoredMessage#3a836df8 flags:# recommended:flags.5?true show_peer_photo:flags.6?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 message:string entities:flags.1?Vector = SponsoredMessage; -messages.sponsoredMessages#65a4c7d5 messages:Vector chats:Vector users:Vector = messages.SponsoredMessages; +messages.sponsoredMessages#c9ee1d87 flags:# posts_between:flags.0?int messages:Vector chats:Vector users:Vector = messages.SponsoredMessages; + +messages.sponsoredMessagesEmpty#1839490f = messages.SponsoredMessages; searchResultsCalendarPeriod#c9b0539f date:int min_msg_id:int max_msg_id:int count:int = SearchResultsCalendarPeriod; @@ -2096,6 +2122,16 @@ messageExtendedMediaPreview#ad628cc8 flags:# w:flags.0?int h:flags.0?int thumb:f messageExtendedMedia#ee479c64 media:MessageMedia = MessageExtendedMedia; +stickerKeyword#fcfeb29c document_id:long keyword:Vector = StickerKeyword; + +username#b4073647 flags:# editable:flags.0?true active:flags.1?true username:string = Username; + +forumTopicDeleted#23f109b id:int = ForumTopic; + +forumTopic#71701da9 flags:# my:flags.1?true closed:flags.2?true pinned:flags.3?true id:int date:int title:string icon_color:int icon_emoji_id:flags.0?long top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int from_id:Peer notify_settings:PeerNotifySettings draft:flags.4?DraftMessage = ForumTopic; + +messages.forumTopics#367617d3 flags:# order_by_create_date:flags.0?true count:int topics:Vector messages:Vector chats:Vector users:Vector pts:int = messages.ForumTopics; + ---functions--- @@ -2271,7 +2307,7 @@ account.saveTheme#f257106c theme:InputTheme unsave:Bool = Bool; account.installTheme#c727bb3b flags:# dark:flags.0?true theme:flags.1?InputTheme format:flags.2?string base_theme:flags.3?BaseTheme = Bool; -account.getTheme#8d9d742b format:string theme:InputTheme document_id:long = Theme; +account.getTheme#3a5869ec format:string theme:InputTheme = Theme; account.getThemes#7206e458 format:string hash:long = account.Themes; @@ -2311,6 +2347,10 @@ account.getRecentEmojiStatuses#f578105 hash:long = account.EmojiStatuses; account.clearRecentEmojiStatuses#18201aae = Bool; +account.reorderUsernames#ef500eab order:Vector = Bool; + +account.toggleUsername#58d6b376 username:string active:Bool = Bool; + users.getUsers#d91a548 id:Vector = Vector; users.getFullUser#b60f5918 id:InputUser = users.UserFull; @@ -2377,11 +2417,11 @@ messages.receivedMessages#5a954c0 max_id:int = Vector; messages.setTyping#58943ee2 flags:# peer:InputPeer top_msg_id:flags.0?int action:SendMessageAction = Bool; -messages.sendMessage#d9d75a4 flags:# no_webpage:flags.1?true silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true peer:InputPeer reply_to_msg_id:flags.0?int message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; +messages.sendMessage#1cc20387 flags:# no_webpage:flags.1?true silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true peer:InputPeer reply_to_msg_id:flags.0?int top_msg_id:flags.9?int message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; -messages.sendMedia#e25ff8e0 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true peer:InputPeer reply_to_msg_id:flags.0?int media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; +messages.sendMedia#7547c966 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true peer:InputPeer reply_to_msg_id:flags.0?int top_msg_id:flags.9?int media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; -messages.forwardMessages#cc30290b flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true drop_author:flags.11?true drop_media_captions:flags.12?true noforwards:flags.14?true from_peer:InputPeer id:Vector random_id:Vector to_peer:InputPeer schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; +messages.forwardMessages#c661bbc4 flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true drop_author:flags.11?true drop_media_captions:flags.12?true noforwards:flags.14?true from_peer:InputPeer id:Vector random_id:Vector to_peer:InputPeer top_msg_id:flags.9?int schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; messages.reportSpam#cf1592db peer:InputPeer = Bool; @@ -2467,7 +2507,7 @@ messages.getInlineBotResults#514e999d flags:# bot:InputUser peer:InputPeer geo_p messages.setInlineBotResults#eb5ea206 flags:# gallery:flags.0?true private:flags.1?true query_id:long results:Vector cache_time:int next_offset:flags.2?string switch_pm:flags.3?InlineBotSwitchPM = Bool; -messages.sendInlineBotResult#7aa11297 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true hide_via:flags.11?true peer:InputPeer reply_to_msg_id:flags.0?int random_id:long query_id:long id:string schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; +messages.sendInlineBotResult#d3fbdccb flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true hide_via:flags.11?true peer:InputPeer reply_to_msg_id:flags.0?int top_msg_id:flags.9?int random_id:long query_id:long id:string schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; messages.getMessageEditData#fda68d36 peer:InputPeer id:int = messages.MessageEditData; @@ -2481,7 +2521,7 @@ messages.setBotCallbackAnswer#d58f130a flags:# alert:flags.1?true query_id:long messages.getPeerDialogs#e470bcfd peers:Vector = messages.PeerDialogs; -messages.saveDraft#bc39e14b flags:# no_webpage:flags.1?true reply_to_msg_id:flags.0?int peer:InputPeer message:string entities:flags.3?Vector = Bool; +messages.saveDraft#b4331e3f flags:# no_webpage:flags.1?true reply_to_msg_id:flags.0?int top_msg_id:flags.2?int peer:InputPeer message:string entities:flags.3?Vector = Bool; messages.getAllDrafts#6a3f8d65 = Updates; @@ -2533,13 +2573,13 @@ messages.getFavedStickers#4f1aaa9 hash:long = messages.FavedStickers; messages.faveSticker#b9ffc55b id:InputDocument unfave:Bool = Bool; -messages.getUnreadMentions#46578472 peer:InputPeer offset_id:int add_offset:int limit:int max_id:int min_id:int = messages.Messages; +messages.getUnreadMentions#f107e790 flags:# peer:InputPeer top_msg_id:flags.0?int offset_id:int add_offset:int limit:int max_id:int min_id:int = messages.Messages; -messages.readMentions#f0189d3 peer:InputPeer = messages.AffectedHistory; +messages.readMentions#36e5bf4d flags:# peer:InputPeer top_msg_id:flags.0?int = messages.AffectedHistory; messages.getRecentLocations#702a40e0 peer:InputPeer limit:int hash:long = messages.Messages; -messages.sendMultiMedia#f803138f flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true peer:InputPeer reply_to_msg_id:flags.0?int multi_media:Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; +messages.sendMultiMedia#b6f11a1c flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true peer:InputPeer reply_to_msg_id:flags.0?int top_msg_id:flags.9?int multi_media:Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; messages.uploadEncryptedFile#5057c497 peer:InputEncryptedChat file:InputEncryptedFile = EncryptedFile; @@ -2573,7 +2613,7 @@ messages.getEmojiKeywordsLanguages#4e9963b2 lang_codes:Vector = Vector = Vector; +messages.getSearchCounters#ae7cc1 flags:# peer:InputPeer top_msg_id:flags.0?int filters:Vector = Vector; messages.requestUrlAuth#198fb446 flags:# peer:flags.1?InputPeer msg_id:flags.1?int button_id:flags.1?int url:flags.2?string = UrlAuthResult; @@ -2609,7 +2649,7 @@ messages.getDiscussionMessage#446972fd peer:InputPeer msg_id:int = messages.Disc messages.readDiscussion#f731a9f4 peer:InputPeer msg_id:int read_max_id:int = Bool; -messages.unpinAllMessages#f025bc8b peer:InputPeer = messages.AffectedHistory; +messages.unpinAllMessages#ee22b9a8 flags:# peer:InputPeer top_msg_id:flags.0?int = messages.AffectedHistory; messages.deleteChat#5bd0ee50 chat_id:long = Bool; @@ -2671,9 +2711,9 @@ messages.setDefaultReaction#4f47a016 reaction:Reaction = Bool; messages.translateText#24ce6dee flags:# peer:flags.0?InputPeer msg_id:flags.0?int text:flags.1?string from_lang:flags.2?string to_lang:string = messages.TranslatedText; -messages.getUnreadReactions#e85bae1a peer:InputPeer offset_id:int add_offset:int limit:int max_id:int min_id:int = messages.Messages; +messages.getUnreadReactions#3223495b flags:# peer:InputPeer top_msg_id:flags.0?int offset_id:int add_offset:int limit:int max_id:int min_id:int = messages.Messages; -messages.readReactions#82e251d7 peer:InputPeer = messages.AffectedHistory; +messages.readReactions#54aa7f8e flags:# peer:InputPeer top_msg_id:flags.0?int = messages.AffectedHistory; messages.searchSentMedia#107e31a0 q:string filter:MessagesFilter limit:int = messages.Messages; @@ -2683,9 +2723,9 @@ messages.getAttachMenuBot#77216192 bot:InputUser = AttachMenuBotsBot; messages.toggleBotInAttachMenu#1aee33af bot:InputUser enabled:Bool = Bool; -messages.requestWebView#fc87a53c flags:# from_bot_menu:flags.4?true silent:flags.5?true peer:InputPeer bot:InputUser url:flags.1?string start_param:flags.3?string theme_params:flags.2?DataJSON platform:string reply_to_msg_id:flags.0?int send_as:flags.13?InputPeer = WebViewResult; +messages.requestWebView#178b480b flags:# from_bot_menu:flags.4?true silent:flags.5?true peer:InputPeer bot:InputUser url:flags.1?string start_param:flags.3?string theme_params:flags.2?DataJSON platform:string reply_to_msg_id:flags.0?int top_msg_id:flags.9?int send_as:flags.13?InputPeer = WebViewResult; -messages.prolongWebView#ea5fbcce flags:# silent:flags.5?true peer:InputPeer bot:InputUser query_id:long reply_to_msg_id:flags.0?int send_as:flags.13?InputPeer = Bool; +messages.prolongWebView#7ff34309 flags:# silent:flags.5?true peer:InputPeer bot:InputUser query_id:long reply_to_msg_id:flags.0?int top_msg_id:flags.9?int send_as:flags.13?InputPeer = Bool; messages.requestSimpleWebView#299bec8e flags:# bot:InputUser url:string theme_params:flags.0?DataJSON platform:string = SimpleWebViewResult; @@ -2871,6 +2911,26 @@ channels.toggleJoinToSend#e4cb9580 channel:InputChannel enabled:Bool = Updates; channels.toggleJoinRequest#4c2985b6 channel:InputChannel enabled:Bool = Updates; +channels.reorderUsernames#b45ced1d channel:InputChannel order:Vector = Bool; + +channels.toggleUsername#50f24105 channel:InputChannel username:string active:Bool = Bool; + +channels.deactivateAllUsernames#a245dd3 channel:InputChannel = Bool; + +channels.toggleForum#a4298b29 channel:InputChannel enabled:Bool = Updates; + +channels.createForumTopic#f40c0224 flags:# channel:InputChannel title:string icon_color:flags.0?int icon_emoji_id:flags.3?long random_id:long send_as:flags.2?InputPeer = Updates; + +channels.getForumTopics#de560d1 flags:# channel:InputChannel q:flags.0?string offset_date:int offset_id:int offset_topic:int limit:int = messages.ForumTopics; + +channels.getForumTopicsByID#b0831eb9 channel:InputChannel topics:Vector = messages.ForumTopics; + +channels.editForumTopic#6c883e2d flags:# channel:InputChannel topic_id:int title:flags.0?string icon_emoji_id:flags.1?long closed:flags.2?Bool = Updates; + +channels.updatePinnedForumTopic#6c2d9026 channel:InputChannel topic_id:int pinned:Bool = Updates; + +channels.deleteTopicHistory#34435f2d channel:InputChannel top_msg_id:int = messages.AffectedHistory; + bots.sendCustomRequest#aa2769ed custom_method:string params:DataJSON = DataJSON; bots.answerWebhookJSONQuery#e6213f4d query_id:long data:DataJSON = Bool; @@ -3011,4 +3071,4 @@ stats.getMessagePublicForwards#5630281b channel:InputChannel msg_id:int offset_r stats.getMessageStats#b6e0a3f5 flags:# dark:flags.0?true channel:InputChannel msg_id:int = stats.MessageStats; -// LAYER 146 +// LAYER 148 diff --git a/_schema/telegram.tl b/_schema/telegram.tl index 373aa85103..acfc451baf 100644 --- a/_schema/telegram.tl +++ b/_schema/telegram.tl @@ -2,8 +2,8 @@ // // Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/Resources/tl/api.tl // Merge: _schema/legacy.tl -// Layer: 146 -// SHA256: ba16bf92d16a2cdcb07672ac0b463e9fea6bc3d9b5641adced6f9cd9f006ebdc +// Layer: 148 +// SHA256: 19fd5971d04078f793254cd1e591d1e9ad9aed8ace833187bc55edb5c7ffa541 boolFalse#bc799737 = Bool; @@ -135,7 +135,7 @@ storage.fileWebp#1081464c = storage.FileType; userEmpty#d3bc4b7a id:long = User; -user#5d99adee flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true fake:flags.26?true bot_attach_menu:flags.27?true premium:flags.28?true attach_menu_enabled:flags.29?true id:long access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector bot_inline_placeholder:flags.19?string lang_code:flags.22?string emoji_status:flags.30?EmojiStatus = User; +user#8f97c628 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true fake:flags.26?true bot_attach_menu:flags.27?true premium:flags.28?true attach_menu_enabled:flags.29?true flags2:# id:long access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector bot_inline_placeholder:flags.19?string lang_code:flags.22?string emoji_status:flags.30?EmojiStatus usernames:flags2.0?Vector = User; userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto; @@ -159,7 +159,7 @@ chat#41cbf256 flags:# creator:flags.0?true left:flags.2?true deactivated:flags.5 chatForbidden#6592a1a7 id:long title:string = Chat; -channel#8261ac61 flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true scam:flags.19?true has_link:flags.20?true has_geo:flags.21?true slowmode_enabled:flags.22?true call_active:flags.23?true call_not_empty:flags.24?true fake:flags.25?true gigagroup:flags.26?true noforwards:flags.27?true join_to_send:flags.28?true join_request:flags.29?true id:long access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int restriction_reason:flags.9?Vector admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int = Chat; +channel#83259464 flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true scam:flags.19?true has_link:flags.20?true has_geo:flags.21?true slowmode_enabled:flags.22?true call_active:flags.23?true call_not_empty:flags.24?true fake:flags.25?true gigagroup:flags.26?true noforwards:flags.27?true join_to_send:flags.28?true join_request:flags.29?true forum:flags.30?true flags2:# id:long access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int restriction_reason:flags.9?Vector admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int usernames:flags2.0?Vector = Chat; channelForbidden#17d493d5 flags:# broadcast:flags.5?true megagroup:flags.8?true id:long access_hash:long title:string until_date:flags.16?int = Chat; @@ -279,6 +279,10 @@ messageActionWebViewDataSent#b4c38cb5 text:string = MessageAction; messageActionGiftPremium#aba0f5c6 currency:string amount:long months:int = MessageAction; +messageActionTopicCreate#d999256 flags:# title:string icon_color:int icon_emoji_id:flags.0?long = MessageAction; + +messageActionTopicEdit#b18a431c flags:# title:flags.0?string icon_emoji_id:flags.1?long closed:flags.2?Bool = MessageAction; + dialog#a8edd0f5 flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int = Dialog; dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog; @@ -319,6 +323,8 @@ inputNotifyChats#4a95e84e = InputNotifyPeer; inputNotifyBroadcasts#b1db7c7e = InputNotifyPeer; +inputNotifyForumTopic#5c467992 peer:InputPeer top_msg_id:int = InputNotifyPeer; + inputPeerNotifySettings#df1f002b flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int sound:flags.3?NotificationSound = InputPeerNotifySettings; peerNotifySettings#a83b0426 flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int ios_sound:flags.3?NotificationSound android_sound:flags.4?NotificationSound other_sound:flags.5?NotificationSound = PeerNotifySettings; @@ -437,7 +443,7 @@ updateChatParticipants#7761198 participants:ChatParticipants = Update; updateUserStatus#e5bdf8de user_id:long status:UserStatus = Update; -updateUserName#c3f202e0 user_id:long first_name:string last_name:string username:string = Update; +updateUserName#a7848924 user_id:long first_name:string last_name:string usernames:Vector = Update; updateUserPhoto#f227868c user_id:long date:int photo:UserProfilePhoto previous:Bool = Update; @@ -507,7 +513,7 @@ updateInlineBotCallbackQuery#691e9052 flags:# query_id:long user_id:long msg_id: updateReadChannelOutbox#b75f99a9 channel_id:long max_id:int = Update; -updateDraftMessage#ee2bb969 peer:Peer draft:DraftMessage = Update; +updateDraftMessage#1b49ec6d flags:# peer:Peer top_msg_id:flags.0?int draft:DraftMessage = Update; updateReadFeaturedStickers#571d2742 = Update; @@ -539,7 +545,7 @@ updateLangPack#56022f4d difference:LangPackDifference = Update; updateFavedStickers#e511996d = Update; -updateChannelReadMessagesContents#44bdd535 channel_id:long messages:Vector = Update; +updateChannelReadMessagesContents#ea29055d flags:# channel_id:long top_msg_id:flags.0?int messages:Vector = Update; updateContactsReset#7084a7be = Update; @@ -613,7 +619,7 @@ updatePendingJoinRequests#7063c3db peer:Peer requests_pending:int recent_request updateBotChatInviteRequester#11dfa986 peer:Peer date:int user_id:long about:string invite:ExportedChatInvite qts:int = Update; -updateMessageReactions#154798c3 peer:Peer msg_id:int reactions:MessageReactions = Update; +updateMessageReactions#5e1b3cb8 flags:# peer:Peer msg_id:int top_msg_id:flags.0?int reactions:MessageReactions = Update; updateAttachMenuBots#17b7a20b = Update; @@ -637,6 +643,8 @@ updateMoveStickerSetToTop#86fccf85 flags:# masks:flags.0?true emojis:flags.1?tru updateMessageExtendedMedia#5a73a98c peer:Peer msg_id:int extended_media:MessageExtendedMedia = Update; +updateChannelPinnedTopic#f694b0ae flags:# channel_id:long topic_id:flags.0?int = Update; + updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; updates.differenceEmpty#5d75a138 date:int seq:int = updates.Difference; @@ -737,6 +745,8 @@ notifyChats#c007cec3 = NotifyPeer; notifyBroadcasts#d612e8ef = NotifyPeer; +notifyForumTopic#226e6308 peer:Peer top_msg_id:int = NotifyPeer; + sendMessageTypingAction#16bf744e = SendMessageAction; sendMessageCancelAction#fd5ec8f5 = SendMessageAction; @@ -925,9 +935,11 @@ inputStickerSetEmojiGenericAnimations#4c4d4ce = InputStickerSet; inputStickerSetEmojiDefaultStatuses#29d0f5ee = InputStickerSet; +inputStickerSetEmojiDefaultTopicIcons#44c1f8e9 = InputStickerSet; + stickerSet#2dd14edc flags:# archived:flags.1?true official:flags.2?true masks:flags.3?true animated:flags.5?true videos:flags.6?true emojis:flags.7?true installed_date:flags.0?int id:long access_hash:long title:string short_name:string thumbs:flags.4?Vector thumb_dc_id:flags.4?int thumb_version:flags.4?int thumb_document_id:flags.8?long count:int hash:int = StickerSet; -messages.stickerSet#b60a24a6 set:StickerSet packs:Vector documents:Vector = messages.StickerSet; +messages.stickerSet#6e153f16 set:StickerSet packs:Vector keywords:Vector documents:Vector = messages.StickerSet; messages.stickerSetNotModified#d3f924eb = messages.StickerSet; @@ -1203,7 +1215,7 @@ stickerSetCovered#6410a5d2 set:StickerSet cover:Document = StickerSetCovered; stickerSetMultiCovered#3407e51b set:StickerSet covers:Vector = StickerSetCovered; -stickerSetFullCovered#1aed5ee5 set:StickerSet packs:Vector documents:Vector = StickerSetCovered; +stickerSetFullCovered#40d13c0e set:StickerSet packs:Vector keywords:Vector documents:Vector = StickerSetCovered; maskCoords#aed6dbb2 n:int x:double y:double zoom:double = MaskCoords; @@ -1485,11 +1497,23 @@ channelAdminLogEventActionSendMessage#278f2868 message:Message = ChannelAdminLog channelAdminLogEventActionChangeAvailableReactions#be4e0ef8 prev_value:ChatReactions new_value:ChatReactions = ChannelAdminLogEventAction; +channelAdminLogEventActionChangeUsernames#f04fb3a9 prev_value:Vector new_value:Vector = ChannelAdminLogEventAction; + +channelAdminLogEventActionToggleForum#2cc6383 new_value:Bool = ChannelAdminLogEventAction; + +channelAdminLogEventActionCreateTopic#58707d28 topic:ForumTopic = ChannelAdminLogEventAction; + +channelAdminLogEventActionEditTopic#f06fe208 prev_topic:ForumTopic new_topic:ForumTopic = ChannelAdminLogEventAction; + +channelAdminLogEventActionDeleteTopic#ae168909 topic:ForumTopic = ChannelAdminLogEventAction; + +channelAdminLogEventActionPinTopic#5d8d353b flags:# prev_topic:flags.0?ForumTopic new_topic:flags.1?ForumTopic = ChannelAdminLogEventAction; + channelAdminLogEvent#1fad68cd id:long date:int user_id:long action:ChannelAdminLogEventAction = ChannelAdminLogEvent; channels.adminLogResults#ed8af74d events:Vector chats:Vector users:Vector = channels.AdminLogResults; -channelAdminLogEventsFilter#ea107ae4 flags:# join:flags.0?true leave:flags.1?true invite:flags.2?true ban:flags.3?true unban:flags.4?true kick:flags.5?true unkick:flags.6?true promote:flags.7?true demote:flags.8?true info:flags.9?true settings:flags.10?true pinned:flags.11?true edit:flags.12?true delete:flags.13?true group_call:flags.14?true invites:flags.15?true send:flags.16?true = ChannelAdminLogEventsFilter; +channelAdminLogEventsFilter#ea107ae4 flags:# join:flags.0?true leave:flags.1?true invite:flags.2?true ban:flags.3?true unban:flags.4?true kick:flags.5?true unkick:flags.6?true promote:flags.7?true demote:flags.8?true info:flags.9?true settings:flags.10?true pinned:flags.11?true edit:flags.12?true delete:flags.13?true group_call:flags.14?true invites:flags.15?true send:flags.16?true forums:flags.17?true = ChannelAdminLogEventsFilter; popularContact#5ce14175 client_id:long importers:int = PopularContact; @@ -1697,9 +1721,9 @@ chatOnlines#f041e250 onlines:int = ChatOnlines; statsURL#47a971e0 url:string = StatsURL; -chatAdminRights#5fb224d5 flags:# change_info:flags.0?true post_messages:flags.1?true edit_messages:flags.2?true delete_messages:flags.3?true ban_users:flags.4?true invite_users:flags.5?true pin_messages:flags.7?true add_admins:flags.9?true anonymous:flags.10?true manage_call:flags.11?true other:flags.12?true = ChatAdminRights; +chatAdminRights#5fb224d5 flags:# change_info:flags.0?true post_messages:flags.1?true edit_messages:flags.2?true delete_messages:flags.3?true ban_users:flags.4?true invite_users:flags.5?true pin_messages:flags.7?true add_admins:flags.9?true anonymous:flags.10?true manage_call:flags.11?true other:flags.12?true manage_topics:flags.13?true = ChatAdminRights; -chatBannedRights#9f120418 flags:# view_messages:flags.0?true send_messages:flags.1?true send_media:flags.2?true send_stickers:flags.3?true send_gifs:flags.4?true send_games:flags.5?true send_inline:flags.6?true embed_links:flags.7?true send_polls:flags.8?true change_info:flags.10?true invite_users:flags.15?true pin_messages:flags.17?true until_date:int = ChatBannedRights; +chatBannedRights#9f120418 flags:# view_messages:flags.0?true send_messages:flags.1?true send_media:flags.2?true send_stickers:flags.3?true send_gifs:flags.4?true send_games:flags.5?true send_inline:flags.6?true embed_links:flags.7?true send_polls:flags.8?true change_info:flags.10?true invite_users:flags.15?true pin_messages:flags.17?true manage_topics:flags.18?true until_date:int = ChatBannedRights; inputWallPaper#e630b979 id:long access_hash:long = InputWallPaper; @@ -1853,7 +1877,7 @@ messages.messageViews#b6c4f543 views:Vector chats:Vector use messages.discussionMessage#a6341782 flags:# messages:Vector max_id:flags.0?int read_inbox_max_id:flags.1?int read_outbox_max_id:flags.2?int unread_count:int chats:Vector users:Vector = messages.DiscussionMessage; -messageReplyHeader#a6d57763 flags:# reply_to_scheduled:flags.2?true reply_to_msg_id:int reply_to_peer_id:flags.0?Peer reply_to_top_id:flags.1?int = MessageReplyHeader; +messageReplyHeader#a6d57763 flags:# reply_to_scheduled:flags.2?true forum_topic:flags.3?true reply_to_msg_id:int reply_to_peer_id:flags.0?Peer reply_to_top_id:flags.1?int = MessageReplyHeader; messageReplies#83d60fc2 flags:# comments:flags.0?true replies:int replies_pts:int recent_repliers:flags.1?Vector channel_id:flags.0?long max_id:flags.2?int read_max_id:flags.3?int = MessageReplies; @@ -1935,9 +1959,11 @@ account.resetPasswordRequestedWait#e9effc7d until_date:int = account.ResetPasswo account.resetPasswordOk#e926d63e = account.ResetPasswordResult; -sponsoredMessage#3a836df8 flags:# recommended:flags.5?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 message:string entities:flags.1?Vector = SponsoredMessage; +sponsoredMessage#3a836df8 flags:# recommended:flags.5?true show_peer_photo:flags.6?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 message:string entities:flags.1?Vector = SponsoredMessage; -messages.sponsoredMessages#65a4c7d5 messages:Vector chats:Vector users:Vector = messages.SponsoredMessages; +messages.sponsoredMessages#c9ee1d87 flags:# posts_between:flags.0?int messages:Vector chats:Vector users:Vector = messages.SponsoredMessages; + +messages.sponsoredMessagesEmpty#1839490f = messages.SponsoredMessages; searchResultsCalendarPeriod#c9b0539f date:int min_msg_id:int max_msg_id:int count:int = SearchResultsCalendarPeriod; @@ -2097,6 +2123,16 @@ messageExtendedMediaPreview#ad628cc8 flags:# w:flags.0?int h:flags.0?int thumb:f messageExtendedMedia#ee479c64 media:MessageMedia = MessageExtendedMedia; +stickerKeyword#fcfeb29c document_id:long keyword:Vector = StickerKeyword; + +username#b4073647 flags:# editable:flags.0?true active:flags.1?true username:string = Username; + +forumTopicDeleted#23f109b id:int = ForumTopic; + +forumTopic#71701da9 flags:# my:flags.1?true closed:flags.2?true pinned:flags.3?true id:int date:int title:string icon_color:int icon_emoji_id:flags.0?long top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int from_id:Peer notify_settings:PeerNotifySettings draft:flags.4?DraftMessage = ForumTopic; + +messages.forumTopics#367617d3 flags:# order_by_create_date:flags.0?true count:int topics:Vector messages:Vector chats:Vector users:Vector pts:int = messages.ForumTopics; + ---functions--- @@ -2272,7 +2308,7 @@ account.saveTheme#f257106c theme:InputTheme unsave:Bool = Bool; account.installTheme#c727bb3b flags:# dark:flags.0?true theme:flags.1?InputTheme format:flags.2?string base_theme:flags.3?BaseTheme = Bool; -account.getTheme#8d9d742b format:string theme:InputTheme document_id:long = Theme; +account.getTheme#3a5869ec format:string theme:InputTheme = Theme; account.getThemes#7206e458 format:string hash:long = account.Themes; @@ -2312,6 +2348,10 @@ account.getRecentEmojiStatuses#f578105 hash:long = account.EmojiStatuses; account.clearRecentEmojiStatuses#18201aae = Bool; +account.reorderUsernames#ef500eab order:Vector = Bool; + +account.toggleUsername#58d6b376 username:string active:Bool = Bool; + users.getUsers#d91a548 id:Vector = Vector; users.getFullUser#b60f5918 id:InputUser = users.UserFull; @@ -2378,11 +2418,11 @@ messages.receivedMessages#5a954c0 max_id:int = Vector; messages.setTyping#58943ee2 flags:# peer:InputPeer top_msg_id:flags.0?int action:SendMessageAction = Bool; -messages.sendMessage#d9d75a4 flags:# no_webpage:flags.1?true silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true peer:InputPeer reply_to_msg_id:flags.0?int message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; +messages.sendMessage#1cc20387 flags:# no_webpage:flags.1?true silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true peer:InputPeer reply_to_msg_id:flags.0?int top_msg_id:flags.9?int message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; -messages.sendMedia#e25ff8e0 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true peer:InputPeer reply_to_msg_id:flags.0?int media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; +messages.sendMedia#7547c966 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true peer:InputPeer reply_to_msg_id:flags.0?int top_msg_id:flags.9?int media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; -messages.forwardMessages#cc30290b flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true drop_author:flags.11?true drop_media_captions:flags.12?true noforwards:flags.14?true from_peer:InputPeer id:Vector random_id:Vector to_peer:InputPeer schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; +messages.forwardMessages#c661bbc4 flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true drop_author:flags.11?true drop_media_captions:flags.12?true noforwards:flags.14?true from_peer:InputPeer id:Vector random_id:Vector to_peer:InputPeer top_msg_id:flags.9?int schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; messages.reportSpam#cf1592db peer:InputPeer = Bool; @@ -2468,7 +2508,7 @@ messages.getInlineBotResults#514e999d flags:# bot:InputUser peer:InputPeer geo_p messages.setInlineBotResults#eb5ea206 flags:# gallery:flags.0?true private:flags.1?true query_id:long results:Vector cache_time:int next_offset:flags.2?string switch_pm:flags.3?InlineBotSwitchPM = Bool; -messages.sendInlineBotResult#7aa11297 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true hide_via:flags.11?true peer:InputPeer reply_to_msg_id:flags.0?int random_id:long query_id:long id:string schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; +messages.sendInlineBotResult#d3fbdccb flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true hide_via:flags.11?true peer:InputPeer reply_to_msg_id:flags.0?int top_msg_id:flags.9?int random_id:long query_id:long id:string schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; messages.getMessageEditData#fda68d36 peer:InputPeer id:int = messages.MessageEditData; @@ -2482,7 +2522,7 @@ messages.setBotCallbackAnswer#d58f130a flags:# alert:flags.1?true query_id:long messages.getPeerDialogs#e470bcfd peers:Vector = messages.PeerDialogs; -messages.saveDraft#bc39e14b flags:# no_webpage:flags.1?true reply_to_msg_id:flags.0?int peer:InputPeer message:string entities:flags.3?Vector = Bool; +messages.saveDraft#b4331e3f flags:# no_webpage:flags.1?true reply_to_msg_id:flags.0?int top_msg_id:flags.2?int peer:InputPeer message:string entities:flags.3?Vector = Bool; messages.getAllDrafts#6a3f8d65 = Updates; @@ -2534,13 +2574,13 @@ messages.getFavedStickers#4f1aaa9 hash:long = messages.FavedStickers; messages.faveSticker#b9ffc55b id:InputDocument unfave:Bool = Bool; -messages.getUnreadMentions#46578472 peer:InputPeer offset_id:int add_offset:int limit:int max_id:int min_id:int = messages.Messages; +messages.getUnreadMentions#f107e790 flags:# peer:InputPeer top_msg_id:flags.0?int offset_id:int add_offset:int limit:int max_id:int min_id:int = messages.Messages; -messages.readMentions#f0189d3 peer:InputPeer = messages.AffectedHistory; +messages.readMentions#36e5bf4d flags:# peer:InputPeer top_msg_id:flags.0?int = messages.AffectedHistory; messages.getRecentLocations#702a40e0 peer:InputPeer limit:int hash:long = messages.Messages; -messages.sendMultiMedia#f803138f flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true peer:InputPeer reply_to_msg_id:flags.0?int multi_media:Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; +messages.sendMultiMedia#b6f11a1c flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true peer:InputPeer reply_to_msg_id:flags.0?int top_msg_id:flags.9?int multi_media:Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; messages.uploadEncryptedFile#5057c497 peer:InputEncryptedChat file:InputEncryptedFile = EncryptedFile; @@ -2574,7 +2614,7 @@ messages.getEmojiKeywordsLanguages#4e9963b2 lang_codes:Vector = Vector = Vector; +messages.getSearchCounters#ae7cc1 flags:# peer:InputPeer top_msg_id:flags.0?int filters:Vector = Vector; messages.requestUrlAuth#198fb446 flags:# peer:flags.1?InputPeer msg_id:flags.1?int button_id:flags.1?int url:flags.2?string = UrlAuthResult; @@ -2610,7 +2650,7 @@ messages.getDiscussionMessage#446972fd peer:InputPeer msg_id:int = messages.Disc messages.readDiscussion#f731a9f4 peer:InputPeer msg_id:int read_max_id:int = Bool; -messages.unpinAllMessages#f025bc8b peer:InputPeer = messages.AffectedHistory; +messages.unpinAllMessages#ee22b9a8 flags:# peer:InputPeer top_msg_id:flags.0?int = messages.AffectedHistory; messages.deleteChat#5bd0ee50 chat_id:long = Bool; @@ -2672,9 +2712,9 @@ messages.setDefaultReaction#4f47a016 reaction:Reaction = Bool; messages.translateText#24ce6dee flags:# peer:flags.0?InputPeer msg_id:flags.0?int text:flags.1?string from_lang:flags.2?string to_lang:string = messages.TranslatedText; -messages.getUnreadReactions#e85bae1a peer:InputPeer offset_id:int add_offset:int limit:int max_id:int min_id:int = messages.Messages; +messages.getUnreadReactions#3223495b flags:# peer:InputPeer top_msg_id:flags.0?int offset_id:int add_offset:int limit:int max_id:int min_id:int = messages.Messages; -messages.readReactions#82e251d7 peer:InputPeer = messages.AffectedHistory; +messages.readReactions#54aa7f8e flags:# peer:InputPeer top_msg_id:flags.0?int = messages.AffectedHistory; messages.searchSentMedia#107e31a0 q:string filter:MessagesFilter limit:int = messages.Messages; @@ -2684,9 +2724,9 @@ messages.getAttachMenuBot#77216192 bot:InputUser = AttachMenuBotsBot; messages.toggleBotInAttachMenu#1aee33af bot:InputUser enabled:Bool = Bool; -messages.requestWebView#fc87a53c flags:# from_bot_menu:flags.4?true silent:flags.5?true peer:InputPeer bot:InputUser url:flags.1?string start_param:flags.3?string theme_params:flags.2?DataJSON platform:string reply_to_msg_id:flags.0?int send_as:flags.13?InputPeer = WebViewResult; +messages.requestWebView#178b480b flags:# from_bot_menu:flags.4?true silent:flags.5?true peer:InputPeer bot:InputUser url:flags.1?string start_param:flags.3?string theme_params:flags.2?DataJSON platform:string reply_to_msg_id:flags.0?int top_msg_id:flags.9?int send_as:flags.13?InputPeer = WebViewResult; -messages.prolongWebView#ea5fbcce flags:# silent:flags.5?true peer:InputPeer bot:InputUser query_id:long reply_to_msg_id:flags.0?int send_as:flags.13?InputPeer = Bool; +messages.prolongWebView#7ff34309 flags:# silent:flags.5?true peer:InputPeer bot:InputUser query_id:long reply_to_msg_id:flags.0?int top_msg_id:flags.9?int send_as:flags.13?InputPeer = Bool; messages.requestSimpleWebView#299bec8e flags:# bot:InputUser url:string theme_params:flags.0?DataJSON platform:string = SimpleWebViewResult; @@ -2872,6 +2912,26 @@ channels.toggleJoinToSend#e4cb9580 channel:InputChannel enabled:Bool = Updates; channels.toggleJoinRequest#4c2985b6 channel:InputChannel enabled:Bool = Updates; +channels.reorderUsernames#b45ced1d channel:InputChannel order:Vector = Bool; + +channels.toggleUsername#50f24105 channel:InputChannel username:string active:Bool = Bool; + +channels.deactivateAllUsernames#a245dd3 channel:InputChannel = Bool; + +channels.toggleForum#a4298b29 channel:InputChannel enabled:Bool = Updates; + +channels.createForumTopic#f40c0224 flags:# channel:InputChannel title:string icon_color:flags.0?int icon_emoji_id:flags.3?long random_id:long send_as:flags.2?InputPeer = Updates; + +channels.getForumTopics#de560d1 flags:# channel:InputChannel q:flags.0?string offset_date:int offset_id:int offset_topic:int limit:int = messages.ForumTopics; + +channels.getForumTopicsByID#b0831eb9 channel:InputChannel topics:Vector = messages.ForumTopics; + +channels.editForumTopic#6c883e2d flags:# channel:InputChannel topic_id:int title:flags.0?string icon_emoji_id:flags.1?long closed:flags.2?Bool = Updates; + +channels.updatePinnedForumTopic#6c2d9026 channel:InputChannel topic_id:int pinned:Bool = Updates; + +channels.deleteTopicHistory#34435f2d channel:InputChannel top_msg_id:int = messages.AffectedHistory; + bots.sendCustomRequest#aa2769ed custom_method:string params:DataJSON = DataJSON; bots.answerWebhookJSONQuery#e6213f4d query_id:long data:DataJSON = Bool; @@ -3044,4 +3104,4 @@ test.useError#ee75af01 = Error; test.useConfigSimple#f9b7b23d = help.ConfigSimple; -// LAYER 146 +// LAYER 148 diff --git a/telegram/query/messages/queries.gen.go b/telegram/query/messages/queries.gen.go index e634053851..63875f8c2c 100644 --- a/telegram/query/messages/queries.gen.go +++ b/telegram/query/messages/queries.gen.go @@ -401,6 +401,12 @@ func (b *GetUnreadMentionsQueryBuilder) Peer(paramPeer tg.InputPeerClass) *GetUn return b } +// TopMsgID sets TopMsgID field of GetUnreadMentions query. +func (b *GetUnreadMentionsQueryBuilder) TopMsgID(paramTopMsgID int) *GetUnreadMentionsQueryBuilder { + b.req.TopMsgID = paramTopMsgID + return b +} + // Query implements Query interface. func (b *GetUnreadMentionsQueryBuilder) Query(ctx context.Context, req Request) (tg.MessagesMessagesClass, error) { r := &tg.MessagesGetUnreadMentionsRequest{ @@ -408,6 +414,7 @@ func (b *GetUnreadMentionsQueryBuilder) Query(ctx context.Context, req Request) } r.Peer = b.req.Peer + r.TopMsgID = b.req.TopMsgID r.AddOffset = req.AddOffset r.OffsetID = req.OffsetID return b.raw.MessagesGetUnreadMentions(ctx, r) @@ -500,6 +507,12 @@ func (b *GetUnreadReactionsQueryBuilder) Peer(paramPeer tg.InputPeerClass) *GetU return b } +// TopMsgID sets TopMsgID field of GetUnreadReactions query. +func (b *GetUnreadReactionsQueryBuilder) TopMsgID(paramTopMsgID int) *GetUnreadReactionsQueryBuilder { + b.req.TopMsgID = paramTopMsgID + return b +} + // Query implements Query interface. func (b *GetUnreadReactionsQueryBuilder) Query(ctx context.Context, req Request) (tg.MessagesMessagesClass, error) { r := &tg.MessagesGetUnreadReactionsRequest{ @@ -507,6 +520,7 @@ func (b *GetUnreadReactionsQueryBuilder) Query(ctx context.Context, req Request) } r.Peer = b.req.Peer + r.TopMsgID = b.req.TopMsgID r.AddOffset = req.AddOffset r.OffsetID = req.OffsetID return b.raw.MessagesGetUnreadReactions(ctx, r) diff --git a/tg/tl_account_get_theme_gen.go b/tg/tl_account_get_theme_gen.go index 433962f264..1ba8b55d11 100644 --- a/tg/tl_account_get_theme_gen.go +++ b/tg/tl_account_get_theme_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// AccountGetThemeRequest represents TL type `account.getTheme#8d9d742b`. +// AccountGetThemeRequest represents TL type `account.getTheme#3a5869ec`. // Get theme information // // See https://core.telegram.org/method/account.getTheme for reference. @@ -40,12 +40,10 @@ type AccountGetThemeRequest struct { Format string // Theme Theme InputThemeClass - // Document ID - DocumentID int64 } // AccountGetThemeRequestTypeID is TL type id of AccountGetThemeRequest. -const AccountGetThemeRequestTypeID = 0x8d9d742b +const AccountGetThemeRequestTypeID = 0x3a5869ec // Ensuring interfaces in compile-time for AccountGetThemeRequest. var ( @@ -65,9 +63,6 @@ func (g *AccountGetThemeRequest) Zero() bool { if !(g.Theme == nil) { return false } - if !(g.DocumentID == 0) { - return false - } return true } @@ -85,11 +80,9 @@ func (g *AccountGetThemeRequest) String() string { func (g *AccountGetThemeRequest) FillFrom(from interface { GetFormat() (value string) GetTheme() (value InputThemeClass) - GetDocumentID() (value int64) }) { g.Format = from.GetFormat() g.Theme = from.GetTheme() - g.DocumentID = from.GetDocumentID() } // TypeID returns type id in TL schema. @@ -123,10 +116,6 @@ func (g *AccountGetThemeRequest) TypeInfo() tdp.Type { Name: "Theme", SchemaName: "theme", }, - { - Name: "DocumentID", - SchemaName: "document_id", - }, } return typ } @@ -134,7 +123,7 @@ func (g *AccountGetThemeRequest) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (g *AccountGetThemeRequest) Encode(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't encode account.getTheme#8d9d742b as nil") + return fmt.Errorf("can't encode account.getTheme#3a5869ec as nil") } b.PutID(AccountGetThemeRequestTypeID) return g.EncodeBare(b) @@ -143,26 +132,25 @@ func (g *AccountGetThemeRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (g *AccountGetThemeRequest) EncodeBare(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't encode account.getTheme#8d9d742b as nil") + return fmt.Errorf("can't encode account.getTheme#3a5869ec as nil") } b.PutString(g.Format) if g.Theme == nil { - return fmt.Errorf("unable to encode account.getTheme#8d9d742b: field theme is nil") + return fmt.Errorf("unable to encode account.getTheme#3a5869ec: field theme is nil") } if err := g.Theme.Encode(b); err != nil { - return fmt.Errorf("unable to encode account.getTheme#8d9d742b: field theme: %w", err) + return fmt.Errorf("unable to encode account.getTheme#3a5869ec: field theme: %w", err) } - b.PutLong(g.DocumentID) return nil } // Decode implements bin.Decoder. func (g *AccountGetThemeRequest) Decode(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't decode account.getTheme#8d9d742b to nil") + return fmt.Errorf("can't decode account.getTheme#3a5869ec to nil") } if err := b.ConsumeID(AccountGetThemeRequestTypeID); err != nil { - return fmt.Errorf("unable to decode account.getTheme#8d9d742b: %w", err) + return fmt.Errorf("unable to decode account.getTheme#3a5869ec: %w", err) } return g.DecodeBare(b) } @@ -170,29 +158,22 @@ func (g *AccountGetThemeRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (g *AccountGetThemeRequest) DecodeBare(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't decode account.getTheme#8d9d742b to nil") + return fmt.Errorf("can't decode account.getTheme#3a5869ec to nil") } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode account.getTheme#8d9d742b: field format: %w", err) + return fmt.Errorf("unable to decode account.getTheme#3a5869ec: field format: %w", err) } g.Format = value } { value, err := DecodeInputTheme(b) if err != nil { - return fmt.Errorf("unable to decode account.getTheme#8d9d742b: field theme: %w", err) + return fmt.Errorf("unable to decode account.getTheme#3a5869ec: field theme: %w", err) } g.Theme = value } - { - value, err := b.Long() - if err != nil { - return fmt.Errorf("unable to decode account.getTheme#8d9d742b: field document_id: %w", err) - } - g.DocumentID = value - } return nil } @@ -212,15 +193,7 @@ func (g *AccountGetThemeRequest) GetTheme() (value InputThemeClass) { return g.Theme } -// GetDocumentID returns value of DocumentID field. -func (g *AccountGetThemeRequest) GetDocumentID() (value int64) { - if g == nil { - return - } - return g.DocumentID -} - -// AccountGetTheme invokes method account.getTheme#8d9d742b returning error if any. +// AccountGetTheme invokes method account.getTheme#3a5869ec returning error if any. // Get theme information // // Possible errors: diff --git a/tg/tl_account_reorder_usernames_gen.go b/tg/tl_account_reorder_usernames_gen.go new file mode 100644 index 0000000000..1a1984181b --- /dev/null +++ b/tg/tl_account_reorder_usernames_gen.go @@ -0,0 +1,190 @@ +// 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{} +) + +// AccountReorderUsernamesRequest represents TL type `account.reorderUsernames#ef500eab`. +// +// See https://core.telegram.org/method/account.reorderUsernames for reference. +type AccountReorderUsernamesRequest struct { + // Order field of AccountReorderUsernamesRequest. + Order []string +} + +// AccountReorderUsernamesRequestTypeID is TL type id of AccountReorderUsernamesRequest. +const AccountReorderUsernamesRequestTypeID = 0xef500eab + +// Ensuring interfaces in compile-time for AccountReorderUsernamesRequest. +var ( + _ bin.Encoder = &AccountReorderUsernamesRequest{} + _ bin.Decoder = &AccountReorderUsernamesRequest{} + _ bin.BareEncoder = &AccountReorderUsernamesRequest{} + _ bin.BareDecoder = &AccountReorderUsernamesRequest{} +) + +func (r *AccountReorderUsernamesRequest) Zero() bool { + if r == nil { + return true + } + if !(r.Order == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (r *AccountReorderUsernamesRequest) String() string { + if r == nil { + return "AccountReorderUsernamesRequest(nil)" + } + type Alias AccountReorderUsernamesRequest + return fmt.Sprintf("AccountReorderUsernamesRequest%+v", Alias(*r)) +} + +// FillFrom fills AccountReorderUsernamesRequest from given interface. +func (r *AccountReorderUsernamesRequest) FillFrom(from interface { + GetOrder() (value []string) +}) { + r.Order = from.GetOrder() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AccountReorderUsernamesRequest) TypeID() uint32 { + return AccountReorderUsernamesRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*AccountReorderUsernamesRequest) TypeName() string { + return "account.reorderUsernames" +} + +// TypeInfo returns info about TL type. +func (r *AccountReorderUsernamesRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "account.reorderUsernames", + ID: AccountReorderUsernamesRequestTypeID, + } + if r == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Order", + SchemaName: "order", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (r *AccountReorderUsernamesRequest) Encode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode account.reorderUsernames#ef500eab as nil") + } + b.PutID(AccountReorderUsernamesRequestTypeID) + return r.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (r *AccountReorderUsernamesRequest) EncodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode account.reorderUsernames#ef500eab as nil") + } + b.PutVectorHeader(len(r.Order)) + for _, v := range r.Order { + b.PutString(v) + } + return nil +} + +// Decode implements bin.Decoder. +func (r *AccountReorderUsernamesRequest) Decode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode account.reorderUsernames#ef500eab to nil") + } + if err := b.ConsumeID(AccountReorderUsernamesRequestTypeID); err != nil { + return fmt.Errorf("unable to decode account.reorderUsernames#ef500eab: %w", err) + } + return r.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (r *AccountReorderUsernamesRequest) DecodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode account.reorderUsernames#ef500eab to nil") + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode account.reorderUsernames#ef500eab: field order: %w", err) + } + + if headerLen > 0 { + r.Order = make([]string, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode account.reorderUsernames#ef500eab: field order: %w", err) + } + r.Order = append(r.Order, value) + } + } + return nil +} + +// GetOrder returns value of Order field. +func (r *AccountReorderUsernamesRequest) GetOrder() (value []string) { + if r == nil { + return + } + return r.Order +} + +// AccountReorderUsernames invokes method account.reorderUsernames#ef500eab returning error if any. +// +// See https://core.telegram.org/method/account.reorderUsernames for reference. +func (c *Client) AccountReorderUsernames(ctx context.Context, order []string) (bool, error) { + var result BoolBox + + request := &AccountReorderUsernamesRequest{ + Order: order, + } + 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_reorder_usernames_slices_gen.go b/tg/tl_account_reorder_usernames_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_account_reorder_usernames_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_username_gen.go b/tg/tl_account_toggle_username_gen.go new file mode 100644 index 0000000000..398b3bb93d --- /dev/null +++ b/tg/tl_account_toggle_username_gen.go @@ -0,0 +1,201 @@ +// 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{} +) + +// AccountToggleUsernameRequest represents TL type `account.toggleUsername#58d6b376`. +// +// See https://core.telegram.org/method/account.toggleUsername for reference. +type AccountToggleUsernameRequest struct { + // Username field of AccountToggleUsernameRequest. + Username string + // Active field of AccountToggleUsernameRequest. + Active bool +} + +// AccountToggleUsernameRequestTypeID is TL type id of AccountToggleUsernameRequest. +const AccountToggleUsernameRequestTypeID = 0x58d6b376 + +// Ensuring interfaces in compile-time for AccountToggleUsernameRequest. +var ( + _ bin.Encoder = &AccountToggleUsernameRequest{} + _ bin.Decoder = &AccountToggleUsernameRequest{} + _ bin.BareEncoder = &AccountToggleUsernameRequest{} + _ bin.BareDecoder = &AccountToggleUsernameRequest{} +) + +func (t *AccountToggleUsernameRequest) Zero() bool { + if t == nil { + return true + } + if !(t.Username == "") { + return false + } + if !(t.Active == false) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (t *AccountToggleUsernameRequest) String() string { + if t == nil { + return "AccountToggleUsernameRequest(nil)" + } + type Alias AccountToggleUsernameRequest + return fmt.Sprintf("AccountToggleUsernameRequest%+v", Alias(*t)) +} + +// FillFrom fills AccountToggleUsernameRequest from given interface. +func (t *AccountToggleUsernameRequest) FillFrom(from interface { + GetUsername() (value string) + GetActive() (value bool) +}) { + t.Username = from.GetUsername() + t.Active = from.GetActive() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AccountToggleUsernameRequest) TypeID() uint32 { + return AccountToggleUsernameRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*AccountToggleUsernameRequest) TypeName() string { + return "account.toggleUsername" +} + +// TypeInfo returns info about TL type. +func (t *AccountToggleUsernameRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "account.toggleUsername", + ID: AccountToggleUsernameRequestTypeID, + } + if t == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Username", + SchemaName: "username", + }, + { + Name: "Active", + SchemaName: "active", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (t *AccountToggleUsernameRequest) Encode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode account.toggleUsername#58d6b376 as nil") + } + b.PutID(AccountToggleUsernameRequestTypeID) + return t.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (t *AccountToggleUsernameRequest) EncodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode account.toggleUsername#58d6b376 as nil") + } + b.PutString(t.Username) + b.PutBool(t.Active) + return nil +} + +// Decode implements bin.Decoder. +func (t *AccountToggleUsernameRequest) Decode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode account.toggleUsername#58d6b376 to nil") + } + if err := b.ConsumeID(AccountToggleUsernameRequestTypeID); err != nil { + return fmt.Errorf("unable to decode account.toggleUsername#58d6b376: %w", err) + } + return t.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (t *AccountToggleUsernameRequest) DecodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode account.toggleUsername#58d6b376 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode account.toggleUsername#58d6b376: field username: %w", err) + } + t.Username = value + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode account.toggleUsername#58d6b376: field active: %w", err) + } + t.Active = value + } + return nil +} + +// GetUsername returns value of Username field. +func (t *AccountToggleUsernameRequest) GetUsername() (value string) { + if t == nil { + return + } + return t.Username +} + +// GetActive returns value of Active field. +func (t *AccountToggleUsernameRequest) GetActive() (value bool) { + if t == nil { + return + } + return t.Active +} + +// AccountToggleUsername invokes method account.toggleUsername#58d6b376 returning error if any. +// +// See https://core.telegram.org/method/account.toggleUsername for reference. +func (c *Client) AccountToggleUsername(ctx context.Context, request *AccountToggleUsernameRequest) (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_account_toggle_username_slices_gen.go b/tg/tl_account_toggle_username_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_account_toggle_username_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_channel_admin_log_event_action_gen.go b/tg/tl_channel_admin_log_event_action_gen.go index b8d998c9d9..72bd17d97d 100644 --- a/tg/tl_channel_admin_log_event_action_gen.go +++ b/tg/tl_channel_admin_log_event_action_gen.go @@ -5472,6 +5472,1009 @@ func (c *ChannelAdminLogEventActionChangeAvailableReactions) GetNewValue() (valu return c.NewValue } +// ChannelAdminLogEventActionChangeUsernames represents TL type `channelAdminLogEventActionChangeUsernames#f04fb3a9`. +// +// See https://core.telegram.org/constructor/channelAdminLogEventActionChangeUsernames for reference. +type ChannelAdminLogEventActionChangeUsernames struct { + // PrevValue field of ChannelAdminLogEventActionChangeUsernames. + PrevValue []string + // NewValue field of ChannelAdminLogEventActionChangeUsernames. + NewValue []string +} + +// ChannelAdminLogEventActionChangeUsernamesTypeID is TL type id of ChannelAdminLogEventActionChangeUsernames. +const ChannelAdminLogEventActionChangeUsernamesTypeID = 0xf04fb3a9 + +// construct implements constructor of ChannelAdminLogEventActionClass. +func (c ChannelAdminLogEventActionChangeUsernames) construct() ChannelAdminLogEventActionClass { + return &c +} + +// Ensuring interfaces in compile-time for ChannelAdminLogEventActionChangeUsernames. +var ( + _ bin.Encoder = &ChannelAdminLogEventActionChangeUsernames{} + _ bin.Decoder = &ChannelAdminLogEventActionChangeUsernames{} + _ bin.BareEncoder = &ChannelAdminLogEventActionChangeUsernames{} + _ bin.BareDecoder = &ChannelAdminLogEventActionChangeUsernames{} + + _ ChannelAdminLogEventActionClass = &ChannelAdminLogEventActionChangeUsernames{} +) + +func (c *ChannelAdminLogEventActionChangeUsernames) Zero() bool { + if c == nil { + return true + } + if !(c.PrevValue == nil) { + return false + } + if !(c.NewValue == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (c *ChannelAdminLogEventActionChangeUsernames) String() string { + if c == nil { + return "ChannelAdminLogEventActionChangeUsernames(nil)" + } + type Alias ChannelAdminLogEventActionChangeUsernames + return fmt.Sprintf("ChannelAdminLogEventActionChangeUsernames%+v", Alias(*c)) +} + +// FillFrom fills ChannelAdminLogEventActionChangeUsernames from given interface. +func (c *ChannelAdminLogEventActionChangeUsernames) FillFrom(from interface { + GetPrevValue() (value []string) + GetNewValue() (value []string) +}) { + c.PrevValue = from.GetPrevValue() + c.NewValue = from.GetNewValue() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChannelAdminLogEventActionChangeUsernames) TypeID() uint32 { + return ChannelAdminLogEventActionChangeUsernamesTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChannelAdminLogEventActionChangeUsernames) TypeName() string { + return "channelAdminLogEventActionChangeUsernames" +} + +// TypeInfo returns info about TL type. +func (c *ChannelAdminLogEventActionChangeUsernames) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "channelAdminLogEventActionChangeUsernames", + ID: ChannelAdminLogEventActionChangeUsernamesTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "PrevValue", + SchemaName: "prev_value", + }, + { + Name: "NewValue", + SchemaName: "new_value", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (c *ChannelAdminLogEventActionChangeUsernames) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode channelAdminLogEventActionChangeUsernames#f04fb3a9 as nil") + } + b.PutID(ChannelAdminLogEventActionChangeUsernamesTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *ChannelAdminLogEventActionChangeUsernames) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode channelAdminLogEventActionChangeUsernames#f04fb3a9 as nil") + } + b.PutVectorHeader(len(c.PrevValue)) + for _, v := range c.PrevValue { + b.PutString(v) + } + b.PutVectorHeader(len(c.NewValue)) + for _, v := range c.NewValue { + b.PutString(v) + } + return nil +} + +// Decode implements bin.Decoder. +func (c *ChannelAdminLogEventActionChangeUsernames) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode channelAdminLogEventActionChangeUsernames#f04fb3a9 to nil") + } + if err := b.ConsumeID(ChannelAdminLogEventActionChangeUsernamesTypeID); err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionChangeUsernames#f04fb3a9: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *ChannelAdminLogEventActionChangeUsernames) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode channelAdminLogEventActionChangeUsernames#f04fb3a9 to nil") + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionChangeUsernames#f04fb3a9: field prev_value: %w", err) + } + + if headerLen > 0 { + c.PrevValue = make([]string, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionChangeUsernames#f04fb3a9: field prev_value: %w", err) + } + c.PrevValue = append(c.PrevValue, value) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionChangeUsernames#f04fb3a9: field new_value: %w", err) + } + + if headerLen > 0 { + c.NewValue = make([]string, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionChangeUsernames#f04fb3a9: field new_value: %w", err) + } + c.NewValue = append(c.NewValue, value) + } + } + return nil +} + +// GetPrevValue returns value of PrevValue field. +func (c *ChannelAdminLogEventActionChangeUsernames) GetPrevValue() (value []string) { + if c == nil { + return + } + return c.PrevValue +} + +// GetNewValue returns value of NewValue field. +func (c *ChannelAdminLogEventActionChangeUsernames) GetNewValue() (value []string) { + if c == nil { + return + } + return c.NewValue +} + +// ChannelAdminLogEventActionToggleForum represents TL type `channelAdminLogEventActionToggleForum#2cc6383`. +// +// See https://core.telegram.org/constructor/channelAdminLogEventActionToggleForum for reference. +type ChannelAdminLogEventActionToggleForum struct { + // NewValue field of ChannelAdminLogEventActionToggleForum. + NewValue bool +} + +// ChannelAdminLogEventActionToggleForumTypeID is TL type id of ChannelAdminLogEventActionToggleForum. +const ChannelAdminLogEventActionToggleForumTypeID = 0x2cc6383 + +// construct implements constructor of ChannelAdminLogEventActionClass. +func (c ChannelAdminLogEventActionToggleForum) construct() ChannelAdminLogEventActionClass { return &c } + +// Ensuring interfaces in compile-time for ChannelAdminLogEventActionToggleForum. +var ( + _ bin.Encoder = &ChannelAdminLogEventActionToggleForum{} + _ bin.Decoder = &ChannelAdminLogEventActionToggleForum{} + _ bin.BareEncoder = &ChannelAdminLogEventActionToggleForum{} + _ bin.BareDecoder = &ChannelAdminLogEventActionToggleForum{} + + _ ChannelAdminLogEventActionClass = &ChannelAdminLogEventActionToggleForum{} +) + +func (c *ChannelAdminLogEventActionToggleForum) Zero() bool { + if c == nil { + return true + } + if !(c.NewValue == false) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (c *ChannelAdminLogEventActionToggleForum) String() string { + if c == nil { + return "ChannelAdminLogEventActionToggleForum(nil)" + } + type Alias ChannelAdminLogEventActionToggleForum + return fmt.Sprintf("ChannelAdminLogEventActionToggleForum%+v", Alias(*c)) +} + +// FillFrom fills ChannelAdminLogEventActionToggleForum from given interface. +func (c *ChannelAdminLogEventActionToggleForum) FillFrom(from interface { + GetNewValue() (value bool) +}) { + c.NewValue = from.GetNewValue() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChannelAdminLogEventActionToggleForum) TypeID() uint32 { + return ChannelAdminLogEventActionToggleForumTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChannelAdminLogEventActionToggleForum) TypeName() string { + return "channelAdminLogEventActionToggleForum" +} + +// TypeInfo returns info about TL type. +func (c *ChannelAdminLogEventActionToggleForum) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "channelAdminLogEventActionToggleForum", + ID: ChannelAdminLogEventActionToggleForumTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "NewValue", + SchemaName: "new_value", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (c *ChannelAdminLogEventActionToggleForum) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode channelAdminLogEventActionToggleForum#2cc6383 as nil") + } + b.PutID(ChannelAdminLogEventActionToggleForumTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *ChannelAdminLogEventActionToggleForum) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode channelAdminLogEventActionToggleForum#2cc6383 as nil") + } + b.PutBool(c.NewValue) + return nil +} + +// Decode implements bin.Decoder. +func (c *ChannelAdminLogEventActionToggleForum) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode channelAdminLogEventActionToggleForum#2cc6383 to nil") + } + if err := b.ConsumeID(ChannelAdminLogEventActionToggleForumTypeID); err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionToggleForum#2cc6383: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *ChannelAdminLogEventActionToggleForum) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode channelAdminLogEventActionToggleForum#2cc6383 to nil") + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionToggleForum#2cc6383: field new_value: %w", err) + } + c.NewValue = value + } + return nil +} + +// GetNewValue returns value of NewValue field. +func (c *ChannelAdminLogEventActionToggleForum) GetNewValue() (value bool) { + if c == nil { + return + } + return c.NewValue +} + +// ChannelAdminLogEventActionCreateTopic represents TL type `channelAdminLogEventActionCreateTopic#58707d28`. +// +// See https://core.telegram.org/constructor/channelAdminLogEventActionCreateTopic for reference. +type ChannelAdminLogEventActionCreateTopic struct { + // Topic field of ChannelAdminLogEventActionCreateTopic. + Topic ForumTopicClass +} + +// ChannelAdminLogEventActionCreateTopicTypeID is TL type id of ChannelAdminLogEventActionCreateTopic. +const ChannelAdminLogEventActionCreateTopicTypeID = 0x58707d28 + +// construct implements constructor of ChannelAdminLogEventActionClass. +func (c ChannelAdminLogEventActionCreateTopic) construct() ChannelAdminLogEventActionClass { return &c } + +// Ensuring interfaces in compile-time for ChannelAdminLogEventActionCreateTopic. +var ( + _ bin.Encoder = &ChannelAdminLogEventActionCreateTopic{} + _ bin.Decoder = &ChannelAdminLogEventActionCreateTopic{} + _ bin.BareEncoder = &ChannelAdminLogEventActionCreateTopic{} + _ bin.BareDecoder = &ChannelAdminLogEventActionCreateTopic{} + + _ ChannelAdminLogEventActionClass = &ChannelAdminLogEventActionCreateTopic{} +) + +func (c *ChannelAdminLogEventActionCreateTopic) Zero() bool { + if c == nil { + return true + } + if !(c.Topic == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (c *ChannelAdminLogEventActionCreateTopic) String() string { + if c == nil { + return "ChannelAdminLogEventActionCreateTopic(nil)" + } + type Alias ChannelAdminLogEventActionCreateTopic + return fmt.Sprintf("ChannelAdminLogEventActionCreateTopic%+v", Alias(*c)) +} + +// FillFrom fills ChannelAdminLogEventActionCreateTopic from given interface. +func (c *ChannelAdminLogEventActionCreateTopic) FillFrom(from interface { + GetTopic() (value ForumTopicClass) +}) { + c.Topic = from.GetTopic() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChannelAdminLogEventActionCreateTopic) TypeID() uint32 { + return ChannelAdminLogEventActionCreateTopicTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChannelAdminLogEventActionCreateTopic) TypeName() string { + return "channelAdminLogEventActionCreateTopic" +} + +// TypeInfo returns info about TL type. +func (c *ChannelAdminLogEventActionCreateTopic) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "channelAdminLogEventActionCreateTopic", + ID: ChannelAdminLogEventActionCreateTopicTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Topic", + SchemaName: "topic", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (c *ChannelAdminLogEventActionCreateTopic) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode channelAdminLogEventActionCreateTopic#58707d28 as nil") + } + b.PutID(ChannelAdminLogEventActionCreateTopicTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *ChannelAdminLogEventActionCreateTopic) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode channelAdminLogEventActionCreateTopic#58707d28 as nil") + } + if c.Topic == nil { + return fmt.Errorf("unable to encode channelAdminLogEventActionCreateTopic#58707d28: field topic is nil") + } + if err := c.Topic.Encode(b); err != nil { + return fmt.Errorf("unable to encode channelAdminLogEventActionCreateTopic#58707d28: field topic: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (c *ChannelAdminLogEventActionCreateTopic) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode channelAdminLogEventActionCreateTopic#58707d28 to nil") + } + if err := b.ConsumeID(ChannelAdminLogEventActionCreateTopicTypeID); err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionCreateTopic#58707d28: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *ChannelAdminLogEventActionCreateTopic) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode channelAdminLogEventActionCreateTopic#58707d28 to nil") + } + { + value, err := DecodeForumTopic(b) + if err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionCreateTopic#58707d28: field topic: %w", err) + } + c.Topic = value + } + return nil +} + +// GetTopic returns value of Topic field. +func (c *ChannelAdminLogEventActionCreateTopic) GetTopic() (value ForumTopicClass) { + if c == nil { + return + } + return c.Topic +} + +// ChannelAdminLogEventActionEditTopic represents TL type `channelAdminLogEventActionEditTopic#f06fe208`. +// +// See https://core.telegram.org/constructor/channelAdminLogEventActionEditTopic for reference. +type ChannelAdminLogEventActionEditTopic struct { + // PrevTopic field of ChannelAdminLogEventActionEditTopic. + PrevTopic ForumTopicClass + // NewTopic field of ChannelAdminLogEventActionEditTopic. + NewTopic ForumTopicClass +} + +// ChannelAdminLogEventActionEditTopicTypeID is TL type id of ChannelAdminLogEventActionEditTopic. +const ChannelAdminLogEventActionEditTopicTypeID = 0xf06fe208 + +// construct implements constructor of ChannelAdminLogEventActionClass. +func (c ChannelAdminLogEventActionEditTopic) construct() ChannelAdminLogEventActionClass { return &c } + +// Ensuring interfaces in compile-time for ChannelAdminLogEventActionEditTopic. +var ( + _ bin.Encoder = &ChannelAdminLogEventActionEditTopic{} + _ bin.Decoder = &ChannelAdminLogEventActionEditTopic{} + _ bin.BareEncoder = &ChannelAdminLogEventActionEditTopic{} + _ bin.BareDecoder = &ChannelAdminLogEventActionEditTopic{} + + _ ChannelAdminLogEventActionClass = &ChannelAdminLogEventActionEditTopic{} +) + +func (c *ChannelAdminLogEventActionEditTopic) Zero() bool { + if c == nil { + return true + } + if !(c.PrevTopic == nil) { + return false + } + if !(c.NewTopic == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (c *ChannelAdminLogEventActionEditTopic) String() string { + if c == nil { + return "ChannelAdminLogEventActionEditTopic(nil)" + } + type Alias ChannelAdminLogEventActionEditTopic + return fmt.Sprintf("ChannelAdminLogEventActionEditTopic%+v", Alias(*c)) +} + +// FillFrom fills ChannelAdminLogEventActionEditTopic from given interface. +func (c *ChannelAdminLogEventActionEditTopic) FillFrom(from interface { + GetPrevTopic() (value ForumTopicClass) + GetNewTopic() (value ForumTopicClass) +}) { + c.PrevTopic = from.GetPrevTopic() + c.NewTopic = from.GetNewTopic() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChannelAdminLogEventActionEditTopic) TypeID() uint32 { + return ChannelAdminLogEventActionEditTopicTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChannelAdminLogEventActionEditTopic) TypeName() string { + return "channelAdminLogEventActionEditTopic" +} + +// TypeInfo returns info about TL type. +func (c *ChannelAdminLogEventActionEditTopic) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "channelAdminLogEventActionEditTopic", + ID: ChannelAdminLogEventActionEditTopicTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "PrevTopic", + SchemaName: "prev_topic", + }, + { + Name: "NewTopic", + SchemaName: "new_topic", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (c *ChannelAdminLogEventActionEditTopic) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode channelAdminLogEventActionEditTopic#f06fe208 as nil") + } + b.PutID(ChannelAdminLogEventActionEditTopicTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *ChannelAdminLogEventActionEditTopic) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode channelAdminLogEventActionEditTopic#f06fe208 as nil") + } + if c.PrevTopic == nil { + return fmt.Errorf("unable to encode channelAdminLogEventActionEditTopic#f06fe208: field prev_topic is nil") + } + if err := c.PrevTopic.Encode(b); err != nil { + return fmt.Errorf("unable to encode channelAdminLogEventActionEditTopic#f06fe208: field prev_topic: %w", err) + } + if c.NewTopic == nil { + return fmt.Errorf("unable to encode channelAdminLogEventActionEditTopic#f06fe208: field new_topic is nil") + } + if err := c.NewTopic.Encode(b); err != nil { + return fmt.Errorf("unable to encode channelAdminLogEventActionEditTopic#f06fe208: field new_topic: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (c *ChannelAdminLogEventActionEditTopic) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode channelAdminLogEventActionEditTopic#f06fe208 to nil") + } + if err := b.ConsumeID(ChannelAdminLogEventActionEditTopicTypeID); err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionEditTopic#f06fe208: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *ChannelAdminLogEventActionEditTopic) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode channelAdminLogEventActionEditTopic#f06fe208 to nil") + } + { + value, err := DecodeForumTopic(b) + if err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionEditTopic#f06fe208: field prev_topic: %w", err) + } + c.PrevTopic = value + } + { + value, err := DecodeForumTopic(b) + if err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionEditTopic#f06fe208: field new_topic: %w", err) + } + c.NewTopic = value + } + return nil +} + +// GetPrevTopic returns value of PrevTopic field. +func (c *ChannelAdminLogEventActionEditTopic) GetPrevTopic() (value ForumTopicClass) { + if c == nil { + return + } + return c.PrevTopic +} + +// GetNewTopic returns value of NewTopic field. +func (c *ChannelAdminLogEventActionEditTopic) GetNewTopic() (value ForumTopicClass) { + if c == nil { + return + } + return c.NewTopic +} + +// ChannelAdminLogEventActionDeleteTopic represents TL type `channelAdminLogEventActionDeleteTopic#ae168909`. +// +// See https://core.telegram.org/constructor/channelAdminLogEventActionDeleteTopic for reference. +type ChannelAdminLogEventActionDeleteTopic struct { + // Topic field of ChannelAdminLogEventActionDeleteTopic. + Topic ForumTopicClass +} + +// ChannelAdminLogEventActionDeleteTopicTypeID is TL type id of ChannelAdminLogEventActionDeleteTopic. +const ChannelAdminLogEventActionDeleteTopicTypeID = 0xae168909 + +// construct implements constructor of ChannelAdminLogEventActionClass. +func (c ChannelAdminLogEventActionDeleteTopic) construct() ChannelAdminLogEventActionClass { return &c } + +// Ensuring interfaces in compile-time for ChannelAdminLogEventActionDeleteTopic. +var ( + _ bin.Encoder = &ChannelAdminLogEventActionDeleteTopic{} + _ bin.Decoder = &ChannelAdminLogEventActionDeleteTopic{} + _ bin.BareEncoder = &ChannelAdminLogEventActionDeleteTopic{} + _ bin.BareDecoder = &ChannelAdminLogEventActionDeleteTopic{} + + _ ChannelAdminLogEventActionClass = &ChannelAdminLogEventActionDeleteTopic{} +) + +func (c *ChannelAdminLogEventActionDeleteTopic) Zero() bool { + if c == nil { + return true + } + if !(c.Topic == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (c *ChannelAdminLogEventActionDeleteTopic) String() string { + if c == nil { + return "ChannelAdminLogEventActionDeleteTopic(nil)" + } + type Alias ChannelAdminLogEventActionDeleteTopic + return fmt.Sprintf("ChannelAdminLogEventActionDeleteTopic%+v", Alias(*c)) +} + +// FillFrom fills ChannelAdminLogEventActionDeleteTopic from given interface. +func (c *ChannelAdminLogEventActionDeleteTopic) FillFrom(from interface { + GetTopic() (value ForumTopicClass) +}) { + c.Topic = from.GetTopic() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChannelAdminLogEventActionDeleteTopic) TypeID() uint32 { + return ChannelAdminLogEventActionDeleteTopicTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChannelAdminLogEventActionDeleteTopic) TypeName() string { + return "channelAdminLogEventActionDeleteTopic" +} + +// TypeInfo returns info about TL type. +func (c *ChannelAdminLogEventActionDeleteTopic) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "channelAdminLogEventActionDeleteTopic", + ID: ChannelAdminLogEventActionDeleteTopicTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Topic", + SchemaName: "topic", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (c *ChannelAdminLogEventActionDeleteTopic) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode channelAdminLogEventActionDeleteTopic#ae168909 as nil") + } + b.PutID(ChannelAdminLogEventActionDeleteTopicTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *ChannelAdminLogEventActionDeleteTopic) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode channelAdminLogEventActionDeleteTopic#ae168909 as nil") + } + if c.Topic == nil { + return fmt.Errorf("unable to encode channelAdminLogEventActionDeleteTopic#ae168909: field topic is nil") + } + if err := c.Topic.Encode(b); err != nil { + return fmt.Errorf("unable to encode channelAdminLogEventActionDeleteTopic#ae168909: field topic: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (c *ChannelAdminLogEventActionDeleteTopic) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode channelAdminLogEventActionDeleteTopic#ae168909 to nil") + } + if err := b.ConsumeID(ChannelAdminLogEventActionDeleteTopicTypeID); err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionDeleteTopic#ae168909: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *ChannelAdminLogEventActionDeleteTopic) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode channelAdminLogEventActionDeleteTopic#ae168909 to nil") + } + { + value, err := DecodeForumTopic(b) + if err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionDeleteTopic#ae168909: field topic: %w", err) + } + c.Topic = value + } + return nil +} + +// GetTopic returns value of Topic field. +func (c *ChannelAdminLogEventActionDeleteTopic) GetTopic() (value ForumTopicClass) { + if c == nil { + return + } + return c.Topic +} + +// ChannelAdminLogEventActionPinTopic represents TL type `channelAdminLogEventActionPinTopic#5d8d353b`. +// +// See https://core.telegram.org/constructor/channelAdminLogEventActionPinTopic for reference. +type ChannelAdminLogEventActionPinTopic struct { + // Flags field of ChannelAdminLogEventActionPinTopic. + Flags bin.Fields + // PrevTopic field of ChannelAdminLogEventActionPinTopic. + // + // Use SetPrevTopic and GetPrevTopic helpers. + PrevTopic ForumTopicClass + // NewTopic field of ChannelAdminLogEventActionPinTopic. + // + // Use SetNewTopic and GetNewTopic helpers. + NewTopic ForumTopicClass +} + +// ChannelAdminLogEventActionPinTopicTypeID is TL type id of ChannelAdminLogEventActionPinTopic. +const ChannelAdminLogEventActionPinTopicTypeID = 0x5d8d353b + +// construct implements constructor of ChannelAdminLogEventActionClass. +func (c ChannelAdminLogEventActionPinTopic) construct() ChannelAdminLogEventActionClass { return &c } + +// Ensuring interfaces in compile-time for ChannelAdminLogEventActionPinTopic. +var ( + _ bin.Encoder = &ChannelAdminLogEventActionPinTopic{} + _ bin.Decoder = &ChannelAdminLogEventActionPinTopic{} + _ bin.BareEncoder = &ChannelAdminLogEventActionPinTopic{} + _ bin.BareDecoder = &ChannelAdminLogEventActionPinTopic{} + + _ ChannelAdminLogEventActionClass = &ChannelAdminLogEventActionPinTopic{} +) + +func (c *ChannelAdminLogEventActionPinTopic) Zero() bool { + if c == nil { + return true + } + if !(c.Flags.Zero()) { + return false + } + if !(c.PrevTopic == nil) { + return false + } + if !(c.NewTopic == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (c *ChannelAdminLogEventActionPinTopic) String() string { + if c == nil { + return "ChannelAdminLogEventActionPinTopic(nil)" + } + type Alias ChannelAdminLogEventActionPinTopic + return fmt.Sprintf("ChannelAdminLogEventActionPinTopic%+v", Alias(*c)) +} + +// FillFrom fills ChannelAdminLogEventActionPinTopic from given interface. +func (c *ChannelAdminLogEventActionPinTopic) FillFrom(from interface { + GetPrevTopic() (value ForumTopicClass, ok bool) + GetNewTopic() (value ForumTopicClass, ok bool) +}) { + if val, ok := from.GetPrevTopic(); ok { + c.PrevTopic = val + } + + if val, ok := from.GetNewTopic(); ok { + c.NewTopic = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChannelAdminLogEventActionPinTopic) TypeID() uint32 { + return ChannelAdminLogEventActionPinTopicTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChannelAdminLogEventActionPinTopic) TypeName() string { + return "channelAdminLogEventActionPinTopic" +} + +// TypeInfo returns info about TL type. +func (c *ChannelAdminLogEventActionPinTopic) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "channelAdminLogEventActionPinTopic", + ID: ChannelAdminLogEventActionPinTopicTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "PrevTopic", + SchemaName: "prev_topic", + Null: !c.Flags.Has(0), + }, + { + Name: "NewTopic", + SchemaName: "new_topic", + Null: !c.Flags.Has(1), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (c *ChannelAdminLogEventActionPinTopic) SetFlags() { + if !(c.PrevTopic == nil) { + c.Flags.Set(0) + } + if !(c.NewTopic == nil) { + c.Flags.Set(1) + } +} + +// Encode implements bin.Encoder. +func (c *ChannelAdminLogEventActionPinTopic) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode channelAdminLogEventActionPinTopic#5d8d353b as nil") + } + b.PutID(ChannelAdminLogEventActionPinTopicTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *ChannelAdminLogEventActionPinTopic) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode channelAdminLogEventActionPinTopic#5d8d353b as nil") + } + c.SetFlags() + if err := c.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode channelAdminLogEventActionPinTopic#5d8d353b: field flags: %w", err) + } + if c.Flags.Has(0) { + if c.PrevTopic == nil { + return fmt.Errorf("unable to encode channelAdminLogEventActionPinTopic#5d8d353b: field prev_topic is nil") + } + if err := c.PrevTopic.Encode(b); err != nil { + return fmt.Errorf("unable to encode channelAdminLogEventActionPinTopic#5d8d353b: field prev_topic: %w", err) + } + } + if c.Flags.Has(1) { + if c.NewTopic == nil { + return fmt.Errorf("unable to encode channelAdminLogEventActionPinTopic#5d8d353b: field new_topic is nil") + } + if err := c.NewTopic.Encode(b); err != nil { + return fmt.Errorf("unable to encode channelAdminLogEventActionPinTopic#5d8d353b: field new_topic: %w", err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (c *ChannelAdminLogEventActionPinTopic) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode channelAdminLogEventActionPinTopic#5d8d353b to nil") + } + if err := b.ConsumeID(ChannelAdminLogEventActionPinTopicTypeID); err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionPinTopic#5d8d353b: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *ChannelAdminLogEventActionPinTopic) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode channelAdminLogEventActionPinTopic#5d8d353b to nil") + } + { + if err := c.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionPinTopic#5d8d353b: field flags: %w", err) + } + } + if c.Flags.Has(0) { + value, err := DecodeForumTopic(b) + if err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionPinTopic#5d8d353b: field prev_topic: %w", err) + } + c.PrevTopic = value + } + if c.Flags.Has(1) { + value, err := DecodeForumTopic(b) + if err != nil { + return fmt.Errorf("unable to decode channelAdminLogEventActionPinTopic#5d8d353b: field new_topic: %w", err) + } + c.NewTopic = value + } + return nil +} + +// SetPrevTopic sets value of PrevTopic conditional field. +func (c *ChannelAdminLogEventActionPinTopic) SetPrevTopic(value ForumTopicClass) { + c.Flags.Set(0) + c.PrevTopic = value +} + +// GetPrevTopic returns value of PrevTopic conditional field and +// boolean which is true if field was set. +func (c *ChannelAdminLogEventActionPinTopic) GetPrevTopic() (value ForumTopicClass, ok bool) { + if c == nil { + return + } + if !c.Flags.Has(0) { + return value, false + } + return c.PrevTopic, true +} + +// SetNewTopic sets value of NewTopic conditional field. +func (c *ChannelAdminLogEventActionPinTopic) SetNewTopic(value ForumTopicClass) { + c.Flags.Set(1) + c.NewTopic = value +} + +// GetNewTopic returns value of NewTopic conditional field and +// boolean which is true if field was set. +func (c *ChannelAdminLogEventActionPinTopic) GetNewTopic() (value ForumTopicClass, ok bool) { + if c == nil { + return + } + if !c.Flags.Has(1) { + return value, false + } + return c.NewTopic, true +} + // ChannelAdminLogEventActionClassName is schema name of ChannelAdminLogEventActionClass. const ChannelAdminLogEventActionClassName = "ChannelAdminLogEventAction" @@ -5522,6 +6525,12 @@ const ChannelAdminLogEventActionClassName = "ChannelAdminLogEventAction" // case *tg.ChannelAdminLogEventActionToggleNoForwards: // channelAdminLogEventActionToggleNoForwards#cb2ac766 // case *tg.ChannelAdminLogEventActionSendMessage: // channelAdminLogEventActionSendMessage#278f2868 // case *tg.ChannelAdminLogEventActionChangeAvailableReactions: // channelAdminLogEventActionChangeAvailableReactions#be4e0ef8 +// case *tg.ChannelAdminLogEventActionChangeUsernames: // channelAdminLogEventActionChangeUsernames#f04fb3a9 +// case *tg.ChannelAdminLogEventActionToggleForum: // channelAdminLogEventActionToggleForum#2cc6383 +// case *tg.ChannelAdminLogEventActionCreateTopic: // channelAdminLogEventActionCreateTopic#58707d28 +// case *tg.ChannelAdminLogEventActionEditTopic: // channelAdminLogEventActionEditTopic#f06fe208 +// case *tg.ChannelAdminLogEventActionDeleteTopic: // channelAdminLogEventActionDeleteTopic#ae168909 +// case *tg.ChannelAdminLogEventActionPinTopic: // channelAdminLogEventActionPinTopic#5d8d353b // default: panic(v) // } type ChannelAdminLogEventActionClass interface { @@ -5802,6 +6811,48 @@ func DecodeChannelAdminLogEventAction(buf *bin.Buffer) (ChannelAdminLogEventActi return nil, fmt.Errorf("unable to decode ChannelAdminLogEventActionClass: %w", err) } return &v, nil + case ChannelAdminLogEventActionChangeUsernamesTypeID: + // Decoding channelAdminLogEventActionChangeUsernames#f04fb3a9. + v := ChannelAdminLogEventActionChangeUsernames{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ChannelAdminLogEventActionClass: %w", err) + } + return &v, nil + case ChannelAdminLogEventActionToggleForumTypeID: + // Decoding channelAdminLogEventActionToggleForum#2cc6383. + v := ChannelAdminLogEventActionToggleForum{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ChannelAdminLogEventActionClass: %w", err) + } + return &v, nil + case ChannelAdminLogEventActionCreateTopicTypeID: + // Decoding channelAdminLogEventActionCreateTopic#58707d28. + v := ChannelAdminLogEventActionCreateTopic{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ChannelAdminLogEventActionClass: %w", err) + } + return &v, nil + case ChannelAdminLogEventActionEditTopicTypeID: + // Decoding channelAdminLogEventActionEditTopic#f06fe208. + v := ChannelAdminLogEventActionEditTopic{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ChannelAdminLogEventActionClass: %w", err) + } + return &v, nil + case ChannelAdminLogEventActionDeleteTopicTypeID: + // Decoding channelAdminLogEventActionDeleteTopic#ae168909. + v := ChannelAdminLogEventActionDeleteTopic{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ChannelAdminLogEventActionClass: %w", err) + } + return &v, nil + case ChannelAdminLogEventActionPinTopicTypeID: + // Decoding channelAdminLogEventActionPinTopic#5d8d353b. + v := ChannelAdminLogEventActionPinTopic{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ChannelAdminLogEventActionClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode ChannelAdminLogEventActionClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_channel_admin_log_event_action_slices_gen.go b/tg/tl_channel_admin_log_event_action_slices_gen.go index 39309311f4..1f598a3efe 100644 --- a/tg/tl_channel_admin_log_event_action_slices_gen.go +++ b/tg/tl_channel_admin_log_event_action_slices_gen.go @@ -558,6 +558,84 @@ func (s ChannelAdminLogEventActionClassArray) AsChannelAdminLogEventActionChange return to } +// AsChannelAdminLogEventActionChangeUsernames returns copy with only ChannelAdminLogEventActionChangeUsernames constructors. +func (s ChannelAdminLogEventActionClassArray) AsChannelAdminLogEventActionChangeUsernames() (to ChannelAdminLogEventActionChangeUsernamesArray) { + for _, elem := range s { + value, ok := elem.(*ChannelAdminLogEventActionChangeUsernames) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsChannelAdminLogEventActionToggleForum returns copy with only ChannelAdminLogEventActionToggleForum constructors. +func (s ChannelAdminLogEventActionClassArray) AsChannelAdminLogEventActionToggleForum() (to ChannelAdminLogEventActionToggleForumArray) { + for _, elem := range s { + value, ok := elem.(*ChannelAdminLogEventActionToggleForum) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsChannelAdminLogEventActionCreateTopic returns copy with only ChannelAdminLogEventActionCreateTopic constructors. +func (s ChannelAdminLogEventActionClassArray) AsChannelAdminLogEventActionCreateTopic() (to ChannelAdminLogEventActionCreateTopicArray) { + for _, elem := range s { + value, ok := elem.(*ChannelAdminLogEventActionCreateTopic) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsChannelAdminLogEventActionEditTopic returns copy with only ChannelAdminLogEventActionEditTopic constructors. +func (s ChannelAdminLogEventActionClassArray) AsChannelAdminLogEventActionEditTopic() (to ChannelAdminLogEventActionEditTopicArray) { + for _, elem := range s { + value, ok := elem.(*ChannelAdminLogEventActionEditTopic) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsChannelAdminLogEventActionDeleteTopic returns copy with only ChannelAdminLogEventActionDeleteTopic constructors. +func (s ChannelAdminLogEventActionClassArray) AsChannelAdminLogEventActionDeleteTopic() (to ChannelAdminLogEventActionDeleteTopicArray) { + for _, elem := range s { + value, ok := elem.(*ChannelAdminLogEventActionDeleteTopic) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsChannelAdminLogEventActionPinTopic returns copy with only ChannelAdminLogEventActionPinTopic constructors. +func (s ChannelAdminLogEventActionClassArray) AsChannelAdminLogEventActionPinTopic() (to ChannelAdminLogEventActionPinTopicArray) { + for _, elem := range s { + value, ok := elem.(*ChannelAdminLogEventActionPinTopic) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // ChannelAdminLogEventActionChangeTitleArray is adapter for slice of ChannelAdminLogEventActionChangeTitle. type ChannelAdminLogEventActionChangeTitleArray []ChannelAdminLogEventActionChangeTitle @@ -3345,3 +3423,495 @@ func (s *ChannelAdminLogEventActionChangeAvailableReactionsArray) Pop() (v Chann return v, true } + +// ChannelAdminLogEventActionChangeUsernamesArray is adapter for slice of ChannelAdminLogEventActionChangeUsernames. +type ChannelAdminLogEventActionChangeUsernamesArray []ChannelAdminLogEventActionChangeUsernames + +// Sort sorts slice of ChannelAdminLogEventActionChangeUsernames. +func (s ChannelAdminLogEventActionChangeUsernamesArray) Sort(less func(a, b ChannelAdminLogEventActionChangeUsernames) bool) ChannelAdminLogEventActionChangeUsernamesArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ChannelAdminLogEventActionChangeUsernames. +func (s ChannelAdminLogEventActionChangeUsernamesArray) SortStable(less func(a, b ChannelAdminLogEventActionChangeUsernames) bool) ChannelAdminLogEventActionChangeUsernamesArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ChannelAdminLogEventActionChangeUsernames. +func (s ChannelAdminLogEventActionChangeUsernamesArray) Retain(keep func(x ChannelAdminLogEventActionChangeUsernames) bool) ChannelAdminLogEventActionChangeUsernamesArray { + 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 ChannelAdminLogEventActionChangeUsernamesArray) First() (v ChannelAdminLogEventActionChangeUsernames, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ChannelAdminLogEventActionChangeUsernamesArray) Last() (v ChannelAdminLogEventActionChangeUsernames, 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 *ChannelAdminLogEventActionChangeUsernamesArray) PopFirst() (v ChannelAdminLogEventActionChangeUsernames, 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 ChannelAdminLogEventActionChangeUsernames + 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 *ChannelAdminLogEventActionChangeUsernamesArray) Pop() (v ChannelAdminLogEventActionChangeUsernames, 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 +} + +// ChannelAdminLogEventActionToggleForumArray is adapter for slice of ChannelAdminLogEventActionToggleForum. +type ChannelAdminLogEventActionToggleForumArray []ChannelAdminLogEventActionToggleForum + +// Sort sorts slice of ChannelAdminLogEventActionToggleForum. +func (s ChannelAdminLogEventActionToggleForumArray) Sort(less func(a, b ChannelAdminLogEventActionToggleForum) bool) ChannelAdminLogEventActionToggleForumArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ChannelAdminLogEventActionToggleForum. +func (s ChannelAdminLogEventActionToggleForumArray) SortStable(less func(a, b ChannelAdminLogEventActionToggleForum) bool) ChannelAdminLogEventActionToggleForumArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ChannelAdminLogEventActionToggleForum. +func (s ChannelAdminLogEventActionToggleForumArray) Retain(keep func(x ChannelAdminLogEventActionToggleForum) bool) ChannelAdminLogEventActionToggleForumArray { + 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 ChannelAdminLogEventActionToggleForumArray) First() (v ChannelAdminLogEventActionToggleForum, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ChannelAdminLogEventActionToggleForumArray) Last() (v ChannelAdminLogEventActionToggleForum, 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 *ChannelAdminLogEventActionToggleForumArray) PopFirst() (v ChannelAdminLogEventActionToggleForum, 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 ChannelAdminLogEventActionToggleForum + 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 *ChannelAdminLogEventActionToggleForumArray) Pop() (v ChannelAdminLogEventActionToggleForum, 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 +} + +// ChannelAdminLogEventActionCreateTopicArray is adapter for slice of ChannelAdminLogEventActionCreateTopic. +type ChannelAdminLogEventActionCreateTopicArray []ChannelAdminLogEventActionCreateTopic + +// Sort sorts slice of ChannelAdminLogEventActionCreateTopic. +func (s ChannelAdminLogEventActionCreateTopicArray) Sort(less func(a, b ChannelAdminLogEventActionCreateTopic) bool) ChannelAdminLogEventActionCreateTopicArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ChannelAdminLogEventActionCreateTopic. +func (s ChannelAdminLogEventActionCreateTopicArray) SortStable(less func(a, b ChannelAdminLogEventActionCreateTopic) bool) ChannelAdminLogEventActionCreateTopicArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ChannelAdminLogEventActionCreateTopic. +func (s ChannelAdminLogEventActionCreateTopicArray) Retain(keep func(x ChannelAdminLogEventActionCreateTopic) bool) ChannelAdminLogEventActionCreateTopicArray { + 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 ChannelAdminLogEventActionCreateTopicArray) First() (v ChannelAdminLogEventActionCreateTopic, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ChannelAdminLogEventActionCreateTopicArray) Last() (v ChannelAdminLogEventActionCreateTopic, 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 *ChannelAdminLogEventActionCreateTopicArray) PopFirst() (v ChannelAdminLogEventActionCreateTopic, 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 ChannelAdminLogEventActionCreateTopic + 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 *ChannelAdminLogEventActionCreateTopicArray) Pop() (v ChannelAdminLogEventActionCreateTopic, 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 +} + +// ChannelAdminLogEventActionEditTopicArray is adapter for slice of ChannelAdminLogEventActionEditTopic. +type ChannelAdminLogEventActionEditTopicArray []ChannelAdminLogEventActionEditTopic + +// Sort sorts slice of ChannelAdminLogEventActionEditTopic. +func (s ChannelAdminLogEventActionEditTopicArray) Sort(less func(a, b ChannelAdminLogEventActionEditTopic) bool) ChannelAdminLogEventActionEditTopicArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ChannelAdminLogEventActionEditTopic. +func (s ChannelAdminLogEventActionEditTopicArray) SortStable(less func(a, b ChannelAdminLogEventActionEditTopic) bool) ChannelAdminLogEventActionEditTopicArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ChannelAdminLogEventActionEditTopic. +func (s ChannelAdminLogEventActionEditTopicArray) Retain(keep func(x ChannelAdminLogEventActionEditTopic) bool) ChannelAdminLogEventActionEditTopicArray { + 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 ChannelAdminLogEventActionEditTopicArray) First() (v ChannelAdminLogEventActionEditTopic, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ChannelAdminLogEventActionEditTopicArray) Last() (v ChannelAdminLogEventActionEditTopic, 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 *ChannelAdminLogEventActionEditTopicArray) PopFirst() (v ChannelAdminLogEventActionEditTopic, 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 ChannelAdminLogEventActionEditTopic + 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 *ChannelAdminLogEventActionEditTopicArray) Pop() (v ChannelAdminLogEventActionEditTopic, 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 +} + +// ChannelAdminLogEventActionDeleteTopicArray is adapter for slice of ChannelAdminLogEventActionDeleteTopic. +type ChannelAdminLogEventActionDeleteTopicArray []ChannelAdminLogEventActionDeleteTopic + +// Sort sorts slice of ChannelAdminLogEventActionDeleteTopic. +func (s ChannelAdminLogEventActionDeleteTopicArray) Sort(less func(a, b ChannelAdminLogEventActionDeleteTopic) bool) ChannelAdminLogEventActionDeleteTopicArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ChannelAdminLogEventActionDeleteTopic. +func (s ChannelAdminLogEventActionDeleteTopicArray) SortStable(less func(a, b ChannelAdminLogEventActionDeleteTopic) bool) ChannelAdminLogEventActionDeleteTopicArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ChannelAdminLogEventActionDeleteTopic. +func (s ChannelAdminLogEventActionDeleteTopicArray) Retain(keep func(x ChannelAdminLogEventActionDeleteTopic) bool) ChannelAdminLogEventActionDeleteTopicArray { + 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 ChannelAdminLogEventActionDeleteTopicArray) First() (v ChannelAdminLogEventActionDeleteTopic, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ChannelAdminLogEventActionDeleteTopicArray) Last() (v ChannelAdminLogEventActionDeleteTopic, 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 *ChannelAdminLogEventActionDeleteTopicArray) PopFirst() (v ChannelAdminLogEventActionDeleteTopic, 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 ChannelAdminLogEventActionDeleteTopic + 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 *ChannelAdminLogEventActionDeleteTopicArray) Pop() (v ChannelAdminLogEventActionDeleteTopic, 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 +} + +// ChannelAdminLogEventActionPinTopicArray is adapter for slice of ChannelAdminLogEventActionPinTopic. +type ChannelAdminLogEventActionPinTopicArray []ChannelAdminLogEventActionPinTopic + +// Sort sorts slice of ChannelAdminLogEventActionPinTopic. +func (s ChannelAdminLogEventActionPinTopicArray) Sort(less func(a, b ChannelAdminLogEventActionPinTopic) bool) ChannelAdminLogEventActionPinTopicArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ChannelAdminLogEventActionPinTopic. +func (s ChannelAdminLogEventActionPinTopicArray) SortStable(less func(a, b ChannelAdminLogEventActionPinTopic) bool) ChannelAdminLogEventActionPinTopicArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ChannelAdminLogEventActionPinTopic. +func (s ChannelAdminLogEventActionPinTopicArray) Retain(keep func(x ChannelAdminLogEventActionPinTopic) bool) ChannelAdminLogEventActionPinTopicArray { + 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 ChannelAdminLogEventActionPinTopicArray) First() (v ChannelAdminLogEventActionPinTopic, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ChannelAdminLogEventActionPinTopicArray) Last() (v ChannelAdminLogEventActionPinTopic, 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 *ChannelAdminLogEventActionPinTopicArray) PopFirst() (v ChannelAdminLogEventActionPinTopic, 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 ChannelAdminLogEventActionPinTopic + 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 *ChannelAdminLogEventActionPinTopicArray) Pop() (v ChannelAdminLogEventActionPinTopic, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_channel_admin_log_events_filter_gen.go b/tg/tl_channel_admin_log_events_filter_gen.go index ece63d4232..aaa5ce9991 100644 --- a/tg/tl_channel_admin_log_events_filter_gen.go +++ b/tg/tl_channel_admin_log_events_filter_gen.go @@ -128,6 +128,8 @@ type ChannelAdminLogEventsFilter struct { Invites bool // A message was posted in a channel Send bool + // Forums field of ChannelAdminLogEventsFilter. + Forums bool } // ChannelAdminLogEventsFilterTypeID is TL type id of ChannelAdminLogEventsFilter. @@ -199,6 +201,9 @@ func (c *ChannelAdminLogEventsFilter) Zero() bool { if !(c.Send == false) { return false } + if !(c.Forums == false) { + return false + } return true } @@ -231,6 +236,7 @@ func (c *ChannelAdminLogEventsFilter) FillFrom(from interface { GetGroupCall() (value bool) GetInvites() (value bool) GetSend() (value bool) + GetForums() (value bool) }) { c.Join = from.GetJoin() c.Leave = from.GetLeave() @@ -249,6 +255,7 @@ func (c *ChannelAdminLogEventsFilter) FillFrom(from interface { c.GroupCall = from.GetGroupCall() c.Invites = from.GetInvites() c.Send = from.GetSend() + c.Forums = from.GetForums() } // TypeID returns type id in TL schema. @@ -359,6 +366,11 @@ func (c *ChannelAdminLogEventsFilter) TypeInfo() tdp.Type { SchemaName: "send", Null: !c.Flags.Has(16), }, + { + Name: "Forums", + SchemaName: "forums", + Null: !c.Flags.Has(17), + }, } return typ } @@ -416,6 +428,9 @@ func (c *ChannelAdminLogEventsFilter) SetFlags() { if !(c.Send == false) { c.Flags.Set(16) } + if !(c.Forums == false) { + c.Flags.Set(17) + } } // Encode implements bin.Encoder. @@ -477,6 +492,7 @@ func (c *ChannelAdminLogEventsFilter) DecodeBare(b *bin.Buffer) error { c.GroupCall = c.Flags.Has(14) c.Invites = c.Flags.Has(15) c.Send = c.Flags.Has(16) + c.Forums = c.Flags.Has(17) return nil } @@ -802,3 +818,22 @@ func (c *ChannelAdminLogEventsFilter) GetSend() (value bool) { } return c.Flags.Has(16) } + +// SetForums sets value of Forums conditional field. +func (c *ChannelAdminLogEventsFilter) SetForums(value bool) { + if value { + c.Flags.Set(17) + c.Forums = true + } else { + c.Flags.Unset(17) + c.Forums = false + } +} + +// GetForums returns value of Forums conditional field. +func (c *ChannelAdminLogEventsFilter) GetForums() (value bool) { + if c == nil { + return + } + return c.Flags.Has(17) +} diff --git a/tg/tl_channels_create_forum_topic_gen.go b/tg/tl_channels_create_forum_topic_gen.go new file mode 100644 index 0000000000..586eab2f1b --- /dev/null +++ b/tg/tl_channels_create_forum_topic_gen.go @@ -0,0 +1,404 @@ +// 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{} +) + +// ChannelsCreateForumTopicRequest represents TL type `channels.createForumTopic#f40c0224`. +// +// See https://core.telegram.org/method/channels.createForumTopic for reference. +type ChannelsCreateForumTopicRequest struct { + // Flags field of ChannelsCreateForumTopicRequest. + Flags bin.Fields + // Channel field of ChannelsCreateForumTopicRequest. + Channel InputChannelClass + // Title field of ChannelsCreateForumTopicRequest. + Title string + // IconColor field of ChannelsCreateForumTopicRequest. + // + // Use SetIconColor and GetIconColor helpers. + IconColor int + // IconEmojiID field of ChannelsCreateForumTopicRequest. + // + // Use SetIconEmojiID and GetIconEmojiID helpers. + IconEmojiID int64 + // RandomID field of ChannelsCreateForumTopicRequest. + RandomID int64 + // SendAs field of ChannelsCreateForumTopicRequest. + // + // Use SetSendAs and GetSendAs helpers. + SendAs InputPeerClass +} + +// ChannelsCreateForumTopicRequestTypeID is TL type id of ChannelsCreateForumTopicRequest. +const ChannelsCreateForumTopicRequestTypeID = 0xf40c0224 + +// Ensuring interfaces in compile-time for ChannelsCreateForumTopicRequest. +var ( + _ bin.Encoder = &ChannelsCreateForumTopicRequest{} + _ bin.Decoder = &ChannelsCreateForumTopicRequest{} + _ bin.BareEncoder = &ChannelsCreateForumTopicRequest{} + _ bin.BareDecoder = &ChannelsCreateForumTopicRequest{} +) + +func (c *ChannelsCreateForumTopicRequest) Zero() bool { + if c == nil { + return true + } + if !(c.Flags.Zero()) { + return false + } + if !(c.Channel == nil) { + return false + } + if !(c.Title == "") { + return false + } + if !(c.IconColor == 0) { + return false + } + if !(c.IconEmojiID == 0) { + return false + } + if !(c.RandomID == 0) { + return false + } + if !(c.SendAs == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (c *ChannelsCreateForumTopicRequest) String() string { + if c == nil { + return "ChannelsCreateForumTopicRequest(nil)" + } + type Alias ChannelsCreateForumTopicRequest + return fmt.Sprintf("ChannelsCreateForumTopicRequest%+v", Alias(*c)) +} + +// FillFrom fills ChannelsCreateForumTopicRequest from given interface. +func (c *ChannelsCreateForumTopicRequest) FillFrom(from interface { + GetChannel() (value InputChannelClass) + GetTitle() (value string) + GetIconColor() (value int, ok bool) + GetIconEmojiID() (value int64, ok bool) + GetRandomID() (value int64) + GetSendAs() (value InputPeerClass, ok bool) +}) { + c.Channel = from.GetChannel() + c.Title = from.GetTitle() + if val, ok := from.GetIconColor(); ok { + c.IconColor = val + } + + if val, ok := from.GetIconEmojiID(); ok { + c.IconEmojiID = val + } + + c.RandomID = from.GetRandomID() + if val, ok := from.GetSendAs(); ok { + c.SendAs = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChannelsCreateForumTopicRequest) TypeID() uint32 { + return ChannelsCreateForumTopicRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChannelsCreateForumTopicRequest) TypeName() string { + return "channels.createForumTopic" +} + +// TypeInfo returns info about TL type. +func (c *ChannelsCreateForumTopicRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "channels.createForumTopic", + ID: ChannelsCreateForumTopicRequestTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Channel", + SchemaName: "channel", + }, + { + Name: "Title", + SchemaName: "title", + }, + { + Name: "IconColor", + SchemaName: "icon_color", + Null: !c.Flags.Has(0), + }, + { + Name: "IconEmojiID", + SchemaName: "icon_emoji_id", + Null: !c.Flags.Has(3), + }, + { + Name: "RandomID", + SchemaName: "random_id", + }, + { + Name: "SendAs", + SchemaName: "send_as", + Null: !c.Flags.Has(2), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (c *ChannelsCreateForumTopicRequest) SetFlags() { + if !(c.IconColor == 0) { + c.Flags.Set(0) + } + if !(c.IconEmojiID == 0) { + c.Flags.Set(3) + } + if !(c.SendAs == nil) { + c.Flags.Set(2) + } +} + +// Encode implements bin.Encoder. +func (c *ChannelsCreateForumTopicRequest) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode channels.createForumTopic#f40c0224 as nil") + } + b.PutID(ChannelsCreateForumTopicRequestTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *ChannelsCreateForumTopicRequest) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode channels.createForumTopic#f40c0224 as nil") + } + c.SetFlags() + if err := c.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode channels.createForumTopic#f40c0224: field flags: %w", err) + } + if c.Channel == nil { + return fmt.Errorf("unable to encode channels.createForumTopic#f40c0224: field channel is nil") + } + if err := c.Channel.Encode(b); err != nil { + return fmt.Errorf("unable to encode channels.createForumTopic#f40c0224: field channel: %w", err) + } + b.PutString(c.Title) + if c.Flags.Has(0) { + b.PutInt(c.IconColor) + } + if c.Flags.Has(3) { + b.PutLong(c.IconEmojiID) + } + b.PutLong(c.RandomID) + if c.Flags.Has(2) { + if c.SendAs == nil { + return fmt.Errorf("unable to encode channels.createForumTopic#f40c0224: field send_as is nil") + } + if err := c.SendAs.Encode(b); err != nil { + return fmt.Errorf("unable to encode channels.createForumTopic#f40c0224: field send_as: %w", err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (c *ChannelsCreateForumTopicRequest) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode channels.createForumTopic#f40c0224 to nil") + } + if err := b.ConsumeID(ChannelsCreateForumTopicRequestTypeID); err != nil { + return fmt.Errorf("unable to decode channels.createForumTopic#f40c0224: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *ChannelsCreateForumTopicRequest) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode channels.createForumTopic#f40c0224 to nil") + } + { + if err := c.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode channels.createForumTopic#f40c0224: field flags: %w", err) + } + } + { + value, err := DecodeInputChannel(b) + if err != nil { + return fmt.Errorf("unable to decode channels.createForumTopic#f40c0224: field channel: %w", err) + } + c.Channel = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode channels.createForumTopic#f40c0224: field title: %w", err) + } + c.Title = value + } + if c.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode channels.createForumTopic#f40c0224: field icon_color: %w", err) + } + c.IconColor = value + } + if c.Flags.Has(3) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode channels.createForumTopic#f40c0224: field icon_emoji_id: %w", err) + } + c.IconEmojiID = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode channels.createForumTopic#f40c0224: field random_id: %w", err) + } + c.RandomID = value + } + if c.Flags.Has(2) { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode channels.createForumTopic#f40c0224: field send_as: %w", err) + } + c.SendAs = value + } + return nil +} + +// GetChannel returns value of Channel field. +func (c *ChannelsCreateForumTopicRequest) GetChannel() (value InputChannelClass) { + if c == nil { + return + } + return c.Channel +} + +// GetTitle returns value of Title field. +func (c *ChannelsCreateForumTopicRequest) GetTitle() (value string) { + if c == nil { + return + } + return c.Title +} + +// SetIconColor sets value of IconColor conditional field. +func (c *ChannelsCreateForumTopicRequest) SetIconColor(value int) { + c.Flags.Set(0) + c.IconColor = value +} + +// GetIconColor returns value of IconColor conditional field and +// boolean which is true if field was set. +func (c *ChannelsCreateForumTopicRequest) GetIconColor() (value int, ok bool) { + if c == nil { + return + } + if !c.Flags.Has(0) { + return value, false + } + return c.IconColor, true +} + +// SetIconEmojiID sets value of IconEmojiID conditional field. +func (c *ChannelsCreateForumTopicRequest) SetIconEmojiID(value int64) { + c.Flags.Set(3) + c.IconEmojiID = value +} + +// GetIconEmojiID returns value of IconEmojiID conditional field and +// boolean which is true if field was set. +func (c *ChannelsCreateForumTopicRequest) GetIconEmojiID() (value int64, ok bool) { + if c == nil { + return + } + if !c.Flags.Has(3) { + return value, false + } + return c.IconEmojiID, true +} + +// GetRandomID returns value of RandomID field. +func (c *ChannelsCreateForumTopicRequest) GetRandomID() (value int64) { + if c == nil { + return + } + return c.RandomID +} + +// SetSendAs sets value of SendAs conditional field. +func (c *ChannelsCreateForumTopicRequest) SetSendAs(value InputPeerClass) { + c.Flags.Set(2) + c.SendAs = value +} + +// GetSendAs returns value of SendAs conditional field and +// boolean which is true if field was set. +func (c *ChannelsCreateForumTopicRequest) GetSendAs() (value InputPeerClass, ok bool) { + if c == nil { + return + } + if !c.Flags.Has(2) { + return value, false + } + return c.SendAs, true +} + +// GetChannelAsNotEmpty returns mapped value of Channel field. +func (c *ChannelsCreateForumTopicRequest) GetChannelAsNotEmpty() (NotEmptyInputChannel, bool) { + return c.Channel.AsNotEmpty() +} + +// ChannelsCreateForumTopic invokes method channels.createForumTopic#f40c0224 returning error if any. +// +// See https://core.telegram.org/method/channels.createForumTopic for reference. +func (c *Client) ChannelsCreateForumTopic(ctx context.Context, request *ChannelsCreateForumTopicRequest) (UpdatesClass, error) { + var result UpdatesBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.Updates, nil +} diff --git a/tg/tl_channels_create_forum_topic_slices_gen.go b/tg/tl_channels_create_forum_topic_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_channels_create_forum_topic_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_deactivate_all_usernames_gen.go b/tg/tl_channels_deactivate_all_usernames_gen.go new file mode 100644 index 0000000000..a776694473 --- /dev/null +++ b/tg/tl_channels_deactivate_all_usernames_gen.go @@ -0,0 +1,187 @@ +// 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{} +) + +// ChannelsDeactivateAllUsernamesRequest represents TL type `channels.deactivateAllUsernames#a245dd3`. +// +// See https://core.telegram.org/method/channels.deactivateAllUsernames for reference. +type ChannelsDeactivateAllUsernamesRequest struct { + // Channel field of ChannelsDeactivateAllUsernamesRequest. + Channel InputChannelClass +} + +// ChannelsDeactivateAllUsernamesRequestTypeID is TL type id of ChannelsDeactivateAllUsernamesRequest. +const ChannelsDeactivateAllUsernamesRequestTypeID = 0xa245dd3 + +// Ensuring interfaces in compile-time for ChannelsDeactivateAllUsernamesRequest. +var ( + _ bin.Encoder = &ChannelsDeactivateAllUsernamesRequest{} + _ bin.Decoder = &ChannelsDeactivateAllUsernamesRequest{} + _ bin.BareEncoder = &ChannelsDeactivateAllUsernamesRequest{} + _ bin.BareDecoder = &ChannelsDeactivateAllUsernamesRequest{} +) + +func (d *ChannelsDeactivateAllUsernamesRequest) Zero() bool { + if d == nil { + return true + } + if !(d.Channel == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (d *ChannelsDeactivateAllUsernamesRequest) String() string { + if d == nil { + return "ChannelsDeactivateAllUsernamesRequest(nil)" + } + type Alias ChannelsDeactivateAllUsernamesRequest + return fmt.Sprintf("ChannelsDeactivateAllUsernamesRequest%+v", Alias(*d)) +} + +// FillFrom fills ChannelsDeactivateAllUsernamesRequest from given interface. +func (d *ChannelsDeactivateAllUsernamesRequest) FillFrom(from interface { + GetChannel() (value InputChannelClass) +}) { + d.Channel = from.GetChannel() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChannelsDeactivateAllUsernamesRequest) TypeID() uint32 { + return ChannelsDeactivateAllUsernamesRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChannelsDeactivateAllUsernamesRequest) TypeName() string { + return "channels.deactivateAllUsernames" +} + +// TypeInfo returns info about TL type. +func (d *ChannelsDeactivateAllUsernamesRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "channels.deactivateAllUsernames", + ID: ChannelsDeactivateAllUsernamesRequestTypeID, + } + if d == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Channel", + SchemaName: "channel", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (d *ChannelsDeactivateAllUsernamesRequest) Encode(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't encode channels.deactivateAllUsernames#a245dd3 as nil") + } + b.PutID(ChannelsDeactivateAllUsernamesRequestTypeID) + return d.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (d *ChannelsDeactivateAllUsernamesRequest) EncodeBare(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't encode channels.deactivateAllUsernames#a245dd3 as nil") + } + if d.Channel == nil { + return fmt.Errorf("unable to encode channels.deactivateAllUsernames#a245dd3: field channel is nil") + } + if err := d.Channel.Encode(b); err != nil { + return fmt.Errorf("unable to encode channels.deactivateAllUsernames#a245dd3: field channel: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (d *ChannelsDeactivateAllUsernamesRequest) Decode(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't decode channels.deactivateAllUsernames#a245dd3 to nil") + } + if err := b.ConsumeID(ChannelsDeactivateAllUsernamesRequestTypeID); err != nil { + return fmt.Errorf("unable to decode channels.deactivateAllUsernames#a245dd3: %w", err) + } + return d.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (d *ChannelsDeactivateAllUsernamesRequest) DecodeBare(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't decode channels.deactivateAllUsernames#a245dd3 to nil") + } + { + value, err := DecodeInputChannel(b) + if err != nil { + return fmt.Errorf("unable to decode channels.deactivateAllUsernames#a245dd3: field channel: %w", err) + } + d.Channel = value + } + return nil +} + +// GetChannel returns value of Channel field. +func (d *ChannelsDeactivateAllUsernamesRequest) GetChannel() (value InputChannelClass) { + if d == nil { + return + } + return d.Channel +} + +// GetChannelAsNotEmpty returns mapped value of Channel field. +func (d *ChannelsDeactivateAllUsernamesRequest) GetChannelAsNotEmpty() (NotEmptyInputChannel, bool) { + return d.Channel.AsNotEmpty() +} + +// ChannelsDeactivateAllUsernames invokes method channels.deactivateAllUsernames#a245dd3 returning error if any. +// +// See https://core.telegram.org/method/channels.deactivateAllUsernames for reference. +func (c *Client) ChannelsDeactivateAllUsernames(ctx context.Context, channel InputChannelClass) (bool, error) { + var result BoolBox + + request := &ChannelsDeactivateAllUsernamesRequest{ + Channel: channel, + } + 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_channels_deactivate_all_usernames_slices_gen.go b/tg/tl_channels_deactivate_all_usernames_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_channels_deactivate_all_usernames_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_delete_topic_history_gen.go b/tg/tl_channels_delete_topic_history_gen.go new file mode 100644 index 0000000000..3b102ea53b --- /dev/null +++ b/tg/tl_channels_delete_topic_history_gen.go @@ -0,0 +1,210 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// ChannelsDeleteTopicHistoryRequest represents TL type `channels.deleteTopicHistory#34435f2d`. +// +// See https://core.telegram.org/method/channels.deleteTopicHistory for reference. +type ChannelsDeleteTopicHistoryRequest struct { + // Channel field of ChannelsDeleteTopicHistoryRequest. + Channel InputChannelClass + // TopMsgID field of ChannelsDeleteTopicHistoryRequest. + TopMsgID int +} + +// ChannelsDeleteTopicHistoryRequestTypeID is TL type id of ChannelsDeleteTopicHistoryRequest. +const ChannelsDeleteTopicHistoryRequestTypeID = 0x34435f2d + +// Ensuring interfaces in compile-time for ChannelsDeleteTopicHistoryRequest. +var ( + _ bin.Encoder = &ChannelsDeleteTopicHistoryRequest{} + _ bin.Decoder = &ChannelsDeleteTopicHistoryRequest{} + _ bin.BareEncoder = &ChannelsDeleteTopicHistoryRequest{} + _ bin.BareDecoder = &ChannelsDeleteTopicHistoryRequest{} +) + +func (d *ChannelsDeleteTopicHistoryRequest) Zero() bool { + if d == nil { + return true + } + if !(d.Channel == nil) { + return false + } + if !(d.TopMsgID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (d *ChannelsDeleteTopicHistoryRequest) String() string { + if d == nil { + return "ChannelsDeleteTopicHistoryRequest(nil)" + } + type Alias ChannelsDeleteTopicHistoryRequest + return fmt.Sprintf("ChannelsDeleteTopicHistoryRequest%+v", Alias(*d)) +} + +// FillFrom fills ChannelsDeleteTopicHistoryRequest from given interface. +func (d *ChannelsDeleteTopicHistoryRequest) FillFrom(from interface { + GetChannel() (value InputChannelClass) + GetTopMsgID() (value int) +}) { + d.Channel = from.GetChannel() + d.TopMsgID = from.GetTopMsgID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChannelsDeleteTopicHistoryRequest) TypeID() uint32 { + return ChannelsDeleteTopicHistoryRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChannelsDeleteTopicHistoryRequest) TypeName() string { + return "channels.deleteTopicHistory" +} + +// TypeInfo returns info about TL type. +func (d *ChannelsDeleteTopicHistoryRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "channels.deleteTopicHistory", + ID: ChannelsDeleteTopicHistoryRequestTypeID, + } + if d == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Channel", + SchemaName: "channel", + }, + { + Name: "TopMsgID", + SchemaName: "top_msg_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (d *ChannelsDeleteTopicHistoryRequest) Encode(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't encode channels.deleteTopicHistory#34435f2d as nil") + } + b.PutID(ChannelsDeleteTopicHistoryRequestTypeID) + return d.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (d *ChannelsDeleteTopicHistoryRequest) EncodeBare(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't encode channels.deleteTopicHistory#34435f2d as nil") + } + if d.Channel == nil { + return fmt.Errorf("unable to encode channels.deleteTopicHistory#34435f2d: field channel is nil") + } + if err := d.Channel.Encode(b); err != nil { + return fmt.Errorf("unable to encode channels.deleteTopicHistory#34435f2d: field channel: %w", err) + } + b.PutInt(d.TopMsgID) + return nil +} + +// Decode implements bin.Decoder. +func (d *ChannelsDeleteTopicHistoryRequest) Decode(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't decode channels.deleteTopicHistory#34435f2d to nil") + } + if err := b.ConsumeID(ChannelsDeleteTopicHistoryRequestTypeID); err != nil { + return fmt.Errorf("unable to decode channels.deleteTopicHistory#34435f2d: %w", err) + } + return d.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (d *ChannelsDeleteTopicHistoryRequest) DecodeBare(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't decode channels.deleteTopicHistory#34435f2d to nil") + } + { + value, err := DecodeInputChannel(b) + if err != nil { + return fmt.Errorf("unable to decode channels.deleteTopicHistory#34435f2d: field channel: %w", err) + } + d.Channel = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode channels.deleteTopicHistory#34435f2d: field top_msg_id: %w", err) + } + d.TopMsgID = value + } + return nil +} + +// GetChannel returns value of Channel field. +func (d *ChannelsDeleteTopicHistoryRequest) GetChannel() (value InputChannelClass) { + if d == nil { + return + } + return d.Channel +} + +// GetTopMsgID returns value of TopMsgID field. +func (d *ChannelsDeleteTopicHistoryRequest) GetTopMsgID() (value int) { + if d == nil { + return + } + return d.TopMsgID +} + +// GetChannelAsNotEmpty returns mapped value of Channel field. +func (d *ChannelsDeleteTopicHistoryRequest) GetChannelAsNotEmpty() (NotEmptyInputChannel, bool) { + return d.Channel.AsNotEmpty() +} + +// ChannelsDeleteTopicHistory invokes method channels.deleteTopicHistory#34435f2d returning error if any. +// +// See https://core.telegram.org/method/channels.deleteTopicHistory for reference. +func (c *Client) ChannelsDeleteTopicHistory(ctx context.Context, request *ChannelsDeleteTopicHistoryRequest) (*MessagesAffectedHistory, error) { + var result MessagesAffectedHistory + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_channels_delete_topic_history_slices_gen.go b/tg/tl_channels_delete_topic_history_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_channels_delete_topic_history_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_edit_forum_topic_gen.go b/tg/tl_channels_edit_forum_topic_gen.go new file mode 100644 index 0000000000..5ebed9d228 --- /dev/null +++ b/tg/tl_channels_edit_forum_topic_gen.go @@ -0,0 +1,372 @@ +// 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{} +) + +// ChannelsEditForumTopicRequest represents TL type `channels.editForumTopic#6c883e2d`. +// +// See https://core.telegram.org/method/channels.editForumTopic for reference. +type ChannelsEditForumTopicRequest struct { + // Flags field of ChannelsEditForumTopicRequest. + Flags bin.Fields + // Channel field of ChannelsEditForumTopicRequest. + Channel InputChannelClass + // TopicID field of ChannelsEditForumTopicRequest. + TopicID int + // Title field of ChannelsEditForumTopicRequest. + // + // Use SetTitle and GetTitle helpers. + Title string + // IconEmojiID field of ChannelsEditForumTopicRequest. + // + // Use SetIconEmojiID and GetIconEmojiID helpers. + IconEmojiID int64 + // Closed field of ChannelsEditForumTopicRequest. + // + // Use SetClosed and GetClosed helpers. + Closed bool +} + +// ChannelsEditForumTopicRequestTypeID is TL type id of ChannelsEditForumTopicRequest. +const ChannelsEditForumTopicRequestTypeID = 0x6c883e2d + +// Ensuring interfaces in compile-time for ChannelsEditForumTopicRequest. +var ( + _ bin.Encoder = &ChannelsEditForumTopicRequest{} + _ bin.Decoder = &ChannelsEditForumTopicRequest{} + _ bin.BareEncoder = &ChannelsEditForumTopicRequest{} + _ bin.BareDecoder = &ChannelsEditForumTopicRequest{} +) + +func (e *ChannelsEditForumTopicRequest) Zero() bool { + if e == nil { + return true + } + if !(e.Flags.Zero()) { + return false + } + if !(e.Channel == nil) { + return false + } + if !(e.TopicID == 0) { + return false + } + if !(e.Title == "") { + return false + } + if !(e.IconEmojiID == 0) { + return false + } + if !(e.Closed == false) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (e *ChannelsEditForumTopicRequest) String() string { + if e == nil { + return "ChannelsEditForumTopicRequest(nil)" + } + type Alias ChannelsEditForumTopicRequest + return fmt.Sprintf("ChannelsEditForumTopicRequest%+v", Alias(*e)) +} + +// FillFrom fills ChannelsEditForumTopicRequest from given interface. +func (e *ChannelsEditForumTopicRequest) FillFrom(from interface { + GetChannel() (value InputChannelClass) + GetTopicID() (value int) + GetTitle() (value string, ok bool) + GetIconEmojiID() (value int64, ok bool) + GetClosed() (value bool, ok bool) +}) { + e.Channel = from.GetChannel() + e.TopicID = from.GetTopicID() + if val, ok := from.GetTitle(); ok { + e.Title = val + } + + if val, ok := from.GetIconEmojiID(); ok { + e.IconEmojiID = val + } + + if val, ok := from.GetClosed(); ok { + e.Closed = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChannelsEditForumTopicRequest) TypeID() uint32 { + return ChannelsEditForumTopicRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChannelsEditForumTopicRequest) TypeName() string { + return "channels.editForumTopic" +} + +// TypeInfo returns info about TL type. +func (e *ChannelsEditForumTopicRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "channels.editForumTopic", + ID: ChannelsEditForumTopicRequestTypeID, + } + if e == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Channel", + SchemaName: "channel", + }, + { + Name: "TopicID", + SchemaName: "topic_id", + }, + { + Name: "Title", + SchemaName: "title", + Null: !e.Flags.Has(0), + }, + { + Name: "IconEmojiID", + SchemaName: "icon_emoji_id", + Null: !e.Flags.Has(1), + }, + { + Name: "Closed", + SchemaName: "closed", + Null: !e.Flags.Has(2), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (e *ChannelsEditForumTopicRequest) SetFlags() { + if !(e.Title == "") { + e.Flags.Set(0) + } + if !(e.IconEmojiID == 0) { + e.Flags.Set(1) + } + if !(e.Closed == false) { + e.Flags.Set(2) + } +} + +// Encode implements bin.Encoder. +func (e *ChannelsEditForumTopicRequest) Encode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode channels.editForumTopic#6c883e2d as nil") + } + b.PutID(ChannelsEditForumTopicRequestTypeID) + return e.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (e *ChannelsEditForumTopicRequest) EncodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode channels.editForumTopic#6c883e2d as nil") + } + e.SetFlags() + if err := e.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode channels.editForumTopic#6c883e2d: field flags: %w", err) + } + if e.Channel == nil { + return fmt.Errorf("unable to encode channels.editForumTopic#6c883e2d: field channel is nil") + } + if err := e.Channel.Encode(b); err != nil { + return fmt.Errorf("unable to encode channels.editForumTopic#6c883e2d: field channel: %w", err) + } + b.PutInt(e.TopicID) + if e.Flags.Has(0) { + b.PutString(e.Title) + } + if e.Flags.Has(1) { + b.PutLong(e.IconEmojiID) + } + if e.Flags.Has(2) { + b.PutBool(e.Closed) + } + return nil +} + +// Decode implements bin.Decoder. +func (e *ChannelsEditForumTopicRequest) Decode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode channels.editForumTopic#6c883e2d to nil") + } + if err := b.ConsumeID(ChannelsEditForumTopicRequestTypeID); err != nil { + return fmt.Errorf("unable to decode channels.editForumTopic#6c883e2d: %w", err) + } + return e.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (e *ChannelsEditForumTopicRequest) DecodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode channels.editForumTopic#6c883e2d to nil") + } + { + if err := e.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode channels.editForumTopic#6c883e2d: field flags: %w", err) + } + } + { + value, err := DecodeInputChannel(b) + if err != nil { + return fmt.Errorf("unable to decode channels.editForumTopic#6c883e2d: field channel: %w", err) + } + e.Channel = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode channels.editForumTopic#6c883e2d: field topic_id: %w", err) + } + e.TopicID = value + } + if e.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode channels.editForumTopic#6c883e2d: field title: %w", err) + } + e.Title = value + } + if e.Flags.Has(1) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode channels.editForumTopic#6c883e2d: field icon_emoji_id: %w", err) + } + e.IconEmojiID = value + } + if e.Flags.Has(2) { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode channels.editForumTopic#6c883e2d: field closed: %w", err) + } + e.Closed = value + } + return nil +} + +// GetChannel returns value of Channel field. +func (e *ChannelsEditForumTopicRequest) GetChannel() (value InputChannelClass) { + if e == nil { + return + } + return e.Channel +} + +// GetTopicID returns value of TopicID field. +func (e *ChannelsEditForumTopicRequest) GetTopicID() (value int) { + if e == nil { + return + } + return e.TopicID +} + +// SetTitle sets value of Title conditional field. +func (e *ChannelsEditForumTopicRequest) SetTitle(value string) { + e.Flags.Set(0) + e.Title = value +} + +// GetTitle returns value of Title conditional field and +// boolean which is true if field was set. +func (e *ChannelsEditForumTopicRequest) GetTitle() (value string, ok bool) { + if e == nil { + return + } + if !e.Flags.Has(0) { + return value, false + } + return e.Title, true +} + +// SetIconEmojiID sets value of IconEmojiID conditional field. +func (e *ChannelsEditForumTopicRequest) SetIconEmojiID(value int64) { + e.Flags.Set(1) + e.IconEmojiID = value +} + +// GetIconEmojiID returns value of IconEmojiID conditional field and +// boolean which is true if field was set. +func (e *ChannelsEditForumTopicRequest) GetIconEmojiID() (value int64, ok bool) { + if e == nil { + return + } + if !e.Flags.Has(1) { + return value, false + } + return e.IconEmojiID, true +} + +// SetClosed sets value of Closed conditional field. +func (e *ChannelsEditForumTopicRequest) SetClosed(value bool) { + e.Flags.Set(2) + e.Closed = value +} + +// GetClosed returns value of Closed conditional field and +// boolean which is true if field was set. +func (e *ChannelsEditForumTopicRequest) GetClosed() (value bool, ok bool) { + if e == nil { + return + } + if !e.Flags.Has(2) { + return value, false + } + return e.Closed, true +} + +// GetChannelAsNotEmpty returns mapped value of Channel field. +func (e *ChannelsEditForumTopicRequest) GetChannelAsNotEmpty() (NotEmptyInputChannel, bool) { + return e.Channel.AsNotEmpty() +} + +// ChannelsEditForumTopic invokes method channels.editForumTopic#6c883e2d returning error if any. +// +// See https://core.telegram.org/method/channels.editForumTopic for reference. +func (c *Client) ChannelsEditForumTopic(ctx context.Context, request *ChannelsEditForumTopicRequest) (UpdatesClass, error) { + var result UpdatesBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.Updates, nil +} diff --git a/tg/tl_channels_edit_forum_topic_slices_gen.go b/tg/tl_channels_edit_forum_topic_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_channels_edit_forum_topic_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_forum_topics_by_id_gen.go b/tg/tl_channels_get_forum_topics_by_id_gen.go new file mode 100644 index 0000000000..37f59f7e0d --- /dev/null +++ b/tg/tl_channels_get_forum_topics_by_id_gen.go @@ -0,0 +1,223 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// ChannelsGetForumTopicsByIDRequest represents TL type `channels.getForumTopicsByID#b0831eb9`. +// +// See https://core.telegram.org/method/channels.getForumTopicsByID for reference. +type ChannelsGetForumTopicsByIDRequest struct { + // Channel field of ChannelsGetForumTopicsByIDRequest. + Channel InputChannelClass + // Topics field of ChannelsGetForumTopicsByIDRequest. + Topics []int +} + +// ChannelsGetForumTopicsByIDRequestTypeID is TL type id of ChannelsGetForumTopicsByIDRequest. +const ChannelsGetForumTopicsByIDRequestTypeID = 0xb0831eb9 + +// Ensuring interfaces in compile-time for ChannelsGetForumTopicsByIDRequest. +var ( + _ bin.Encoder = &ChannelsGetForumTopicsByIDRequest{} + _ bin.Decoder = &ChannelsGetForumTopicsByIDRequest{} + _ bin.BareEncoder = &ChannelsGetForumTopicsByIDRequest{} + _ bin.BareDecoder = &ChannelsGetForumTopicsByIDRequest{} +) + +func (g *ChannelsGetForumTopicsByIDRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Channel == nil) { + return false + } + if !(g.Topics == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *ChannelsGetForumTopicsByIDRequest) String() string { + if g == nil { + return "ChannelsGetForumTopicsByIDRequest(nil)" + } + type Alias ChannelsGetForumTopicsByIDRequest + return fmt.Sprintf("ChannelsGetForumTopicsByIDRequest%+v", Alias(*g)) +} + +// FillFrom fills ChannelsGetForumTopicsByIDRequest from given interface. +func (g *ChannelsGetForumTopicsByIDRequest) FillFrom(from interface { + GetChannel() (value InputChannelClass) + GetTopics() (value []int) +}) { + g.Channel = from.GetChannel() + g.Topics = from.GetTopics() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChannelsGetForumTopicsByIDRequest) TypeID() uint32 { + return ChannelsGetForumTopicsByIDRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChannelsGetForumTopicsByIDRequest) TypeName() string { + return "channels.getForumTopicsByID" +} + +// TypeInfo returns info about TL type. +func (g *ChannelsGetForumTopicsByIDRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "channels.getForumTopicsByID", + ID: ChannelsGetForumTopicsByIDRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Channel", + SchemaName: "channel", + }, + { + Name: "Topics", + SchemaName: "topics", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *ChannelsGetForumTopicsByIDRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode channels.getForumTopicsByID#b0831eb9 as nil") + } + b.PutID(ChannelsGetForumTopicsByIDRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *ChannelsGetForumTopicsByIDRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode channels.getForumTopicsByID#b0831eb9 as nil") + } + if g.Channel == nil { + return fmt.Errorf("unable to encode channels.getForumTopicsByID#b0831eb9: field channel is nil") + } + if err := g.Channel.Encode(b); err != nil { + return fmt.Errorf("unable to encode channels.getForumTopicsByID#b0831eb9: field channel: %w", err) + } + b.PutVectorHeader(len(g.Topics)) + for _, v := range g.Topics { + b.PutInt(v) + } + return nil +} + +// Decode implements bin.Decoder. +func (g *ChannelsGetForumTopicsByIDRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode channels.getForumTopicsByID#b0831eb9 to nil") + } + if err := b.ConsumeID(ChannelsGetForumTopicsByIDRequestTypeID); err != nil { + return fmt.Errorf("unable to decode channels.getForumTopicsByID#b0831eb9: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *ChannelsGetForumTopicsByIDRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode channels.getForumTopicsByID#b0831eb9 to nil") + } + { + value, err := DecodeInputChannel(b) + if err != nil { + return fmt.Errorf("unable to decode channels.getForumTopicsByID#b0831eb9: field channel: %w", err) + } + g.Channel = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode channels.getForumTopicsByID#b0831eb9: field topics: %w", err) + } + + if headerLen > 0 { + g.Topics = 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 channels.getForumTopicsByID#b0831eb9: field topics: %w", err) + } + g.Topics = append(g.Topics, value) + } + } + return nil +} + +// GetChannel returns value of Channel field. +func (g *ChannelsGetForumTopicsByIDRequest) GetChannel() (value InputChannelClass) { + if g == nil { + return + } + return g.Channel +} + +// GetTopics returns value of Topics field. +func (g *ChannelsGetForumTopicsByIDRequest) GetTopics() (value []int) { + if g == nil { + return + } + return g.Topics +} + +// GetChannelAsNotEmpty returns mapped value of Channel field. +func (g *ChannelsGetForumTopicsByIDRequest) GetChannelAsNotEmpty() (NotEmptyInputChannel, bool) { + return g.Channel.AsNotEmpty() +} + +// ChannelsGetForumTopicsByID invokes method channels.getForumTopicsByID#b0831eb9 returning error if any. +// +// See https://core.telegram.org/method/channels.getForumTopicsByID for reference. +func (c *Client) ChannelsGetForumTopicsByID(ctx context.Context, request *ChannelsGetForumTopicsByIDRequest) (*MessagesForumTopics, error) { + var result MessagesForumTopics + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_channels_get_forum_topics_by_id_slices_gen.go b/tg/tl_channels_get_forum_topics_by_id_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_channels_get_forum_topics_by_id_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_forum_topics_gen.go b/tg/tl_channels_get_forum_topics_gen.go new file mode 100644 index 0000000000..894fe17203 --- /dev/null +++ b/tg/tl_channels_get_forum_topics_gen.go @@ -0,0 +1,357 @@ +// 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{} +) + +// ChannelsGetForumTopicsRequest represents TL type `channels.getForumTopics#de560d1`. +// +// See https://core.telegram.org/method/channels.getForumTopics for reference. +type ChannelsGetForumTopicsRequest struct { + // Flags field of ChannelsGetForumTopicsRequest. + Flags bin.Fields + // Channel field of ChannelsGetForumTopicsRequest. + Channel InputChannelClass + // Q field of ChannelsGetForumTopicsRequest. + // + // Use SetQ and GetQ helpers. + Q string + // OffsetDate field of ChannelsGetForumTopicsRequest. + OffsetDate int + // OffsetID field of ChannelsGetForumTopicsRequest. + OffsetID int + // OffsetTopic field of ChannelsGetForumTopicsRequest. + OffsetTopic int + // Limit field of ChannelsGetForumTopicsRequest. + Limit int +} + +// ChannelsGetForumTopicsRequestTypeID is TL type id of ChannelsGetForumTopicsRequest. +const ChannelsGetForumTopicsRequestTypeID = 0xde560d1 + +// Ensuring interfaces in compile-time for ChannelsGetForumTopicsRequest. +var ( + _ bin.Encoder = &ChannelsGetForumTopicsRequest{} + _ bin.Decoder = &ChannelsGetForumTopicsRequest{} + _ bin.BareEncoder = &ChannelsGetForumTopicsRequest{} + _ bin.BareDecoder = &ChannelsGetForumTopicsRequest{} +) + +func (g *ChannelsGetForumTopicsRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Flags.Zero()) { + return false + } + if !(g.Channel == nil) { + return false + } + if !(g.Q == "") { + return false + } + if !(g.OffsetDate == 0) { + return false + } + if !(g.OffsetID == 0) { + return false + } + if !(g.OffsetTopic == 0) { + return false + } + if !(g.Limit == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *ChannelsGetForumTopicsRequest) String() string { + if g == nil { + return "ChannelsGetForumTopicsRequest(nil)" + } + type Alias ChannelsGetForumTopicsRequest + return fmt.Sprintf("ChannelsGetForumTopicsRequest%+v", Alias(*g)) +} + +// FillFrom fills ChannelsGetForumTopicsRequest from given interface. +func (g *ChannelsGetForumTopicsRequest) FillFrom(from interface { + GetChannel() (value InputChannelClass) + GetQ() (value string, ok bool) + GetOffsetDate() (value int) + GetOffsetID() (value int) + GetOffsetTopic() (value int) + GetLimit() (value int) +}) { + g.Channel = from.GetChannel() + if val, ok := from.GetQ(); ok { + g.Q = val + } + + g.OffsetDate = from.GetOffsetDate() + g.OffsetID = from.GetOffsetID() + g.OffsetTopic = from.GetOffsetTopic() + g.Limit = from.GetLimit() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChannelsGetForumTopicsRequest) TypeID() uint32 { + return ChannelsGetForumTopicsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChannelsGetForumTopicsRequest) TypeName() string { + return "channels.getForumTopics" +} + +// TypeInfo returns info about TL type. +func (g *ChannelsGetForumTopicsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "channels.getForumTopics", + ID: ChannelsGetForumTopicsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Channel", + SchemaName: "channel", + }, + { + Name: "Q", + SchemaName: "q", + Null: !g.Flags.Has(0), + }, + { + Name: "OffsetDate", + SchemaName: "offset_date", + }, + { + Name: "OffsetID", + SchemaName: "offset_id", + }, + { + Name: "OffsetTopic", + SchemaName: "offset_topic", + }, + { + Name: "Limit", + SchemaName: "limit", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (g *ChannelsGetForumTopicsRequest) SetFlags() { + if !(g.Q == "") { + g.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (g *ChannelsGetForumTopicsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode channels.getForumTopics#de560d1 as nil") + } + b.PutID(ChannelsGetForumTopicsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *ChannelsGetForumTopicsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode channels.getForumTopics#de560d1 as nil") + } + g.SetFlags() + if err := g.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode channels.getForumTopics#de560d1: field flags: %w", err) + } + if g.Channel == nil { + return fmt.Errorf("unable to encode channels.getForumTopics#de560d1: field channel is nil") + } + if err := g.Channel.Encode(b); err != nil { + return fmt.Errorf("unable to encode channels.getForumTopics#de560d1: field channel: %w", err) + } + if g.Flags.Has(0) { + b.PutString(g.Q) + } + b.PutInt(g.OffsetDate) + b.PutInt(g.OffsetID) + b.PutInt(g.OffsetTopic) + b.PutInt(g.Limit) + return nil +} + +// Decode implements bin.Decoder. +func (g *ChannelsGetForumTopicsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode channels.getForumTopics#de560d1 to nil") + } + if err := b.ConsumeID(ChannelsGetForumTopicsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode channels.getForumTopics#de560d1: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *ChannelsGetForumTopicsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode channels.getForumTopics#de560d1 to nil") + } + { + if err := g.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode channels.getForumTopics#de560d1: field flags: %w", err) + } + } + { + value, err := DecodeInputChannel(b) + if err != nil { + return fmt.Errorf("unable to decode channels.getForumTopics#de560d1: field channel: %w", err) + } + g.Channel = value + } + if g.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode channels.getForumTopics#de560d1: field q: %w", err) + } + g.Q = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode channels.getForumTopics#de560d1: field offset_date: %w", err) + } + g.OffsetDate = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode channels.getForumTopics#de560d1: field offset_id: %w", err) + } + g.OffsetID = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode channels.getForumTopics#de560d1: field offset_topic: %w", err) + } + g.OffsetTopic = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode channels.getForumTopics#de560d1: field limit: %w", err) + } + g.Limit = value + } + return nil +} + +// GetChannel returns value of Channel field. +func (g *ChannelsGetForumTopicsRequest) GetChannel() (value InputChannelClass) { + if g == nil { + return + } + return g.Channel +} + +// SetQ sets value of Q conditional field. +func (g *ChannelsGetForumTopicsRequest) SetQ(value string) { + g.Flags.Set(0) + g.Q = value +} + +// GetQ returns value of Q conditional field and +// boolean which is true if field was set. +func (g *ChannelsGetForumTopicsRequest) GetQ() (value string, ok bool) { + if g == nil { + return + } + if !g.Flags.Has(0) { + return value, false + } + return g.Q, true +} + +// GetOffsetDate returns value of OffsetDate field. +func (g *ChannelsGetForumTopicsRequest) GetOffsetDate() (value int) { + if g == nil { + return + } + return g.OffsetDate +} + +// GetOffsetID returns value of OffsetID field. +func (g *ChannelsGetForumTopicsRequest) GetOffsetID() (value int) { + if g == nil { + return + } + return g.OffsetID +} + +// GetOffsetTopic returns value of OffsetTopic field. +func (g *ChannelsGetForumTopicsRequest) GetOffsetTopic() (value int) { + if g == nil { + return + } + return g.OffsetTopic +} + +// GetLimit returns value of Limit field. +func (g *ChannelsGetForumTopicsRequest) GetLimit() (value int) { + if g == nil { + return + } + return g.Limit +} + +// GetChannelAsNotEmpty returns mapped value of Channel field. +func (g *ChannelsGetForumTopicsRequest) GetChannelAsNotEmpty() (NotEmptyInputChannel, bool) { + return g.Channel.AsNotEmpty() +} + +// ChannelsGetForumTopics invokes method channels.getForumTopics#de560d1 returning error if any. +// +// See https://core.telegram.org/method/channels.getForumTopics for reference. +func (c *Client) ChannelsGetForumTopics(ctx context.Context, request *ChannelsGetForumTopicsRequest) (*MessagesForumTopics, error) { + var result MessagesForumTopics + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_channels_get_forum_topics_slices_gen.go b/tg/tl_channels_get_forum_topics_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_channels_get_forum_topics_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_sponsored_messages_gen.go b/tg/tl_channels_get_sponsored_messages_gen.go index 6400989d83..b6c9deebc8 100644 --- a/tg/tl_channels_get_sponsored_messages_gen.go +++ b/tg/tl_channels_get_sponsored_messages_gen.go @@ -181,8 +181,8 @@ func (g *ChannelsGetSponsoredMessagesRequest) GetChannelAsNotEmpty() (NotEmptyIn // 400 MSG_ID_INVALID: Invalid message ID provided. // // See https://core.telegram.org/method/channels.getSponsoredMessages for reference. -func (c *Client) ChannelsGetSponsoredMessages(ctx context.Context, channel InputChannelClass) (*MessagesSponsoredMessages, error) { - var result MessagesSponsoredMessages +func (c *Client) ChannelsGetSponsoredMessages(ctx context.Context, channel InputChannelClass) (MessagesSponsoredMessagesClass, error) { + var result MessagesSponsoredMessagesBox request := &ChannelsGetSponsoredMessagesRequest{ Channel: channel, @@ -190,5 +190,5 @@ func (c *Client) ChannelsGetSponsoredMessages(ctx context.Context, channel Input if err := c.rpc.Invoke(ctx, request, &result); err != nil { return nil, err } - return &result, nil + return result.SponsoredMessages, nil } diff --git a/tg/tl_channels_reorder_usernames_gen.go b/tg/tl_channels_reorder_usernames_gen.go new file mode 100644 index 0000000000..01771882aa --- /dev/null +++ b/tg/tl_channels_reorder_usernames_gen.go @@ -0,0 +1,224 @@ +// 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{} +) + +// ChannelsReorderUsernamesRequest represents TL type `channels.reorderUsernames#b45ced1d`. +// +// See https://core.telegram.org/method/channels.reorderUsernames for reference. +type ChannelsReorderUsernamesRequest struct { + // Channel field of ChannelsReorderUsernamesRequest. + Channel InputChannelClass + // Order field of ChannelsReorderUsernamesRequest. + Order []string +} + +// ChannelsReorderUsernamesRequestTypeID is TL type id of ChannelsReorderUsernamesRequest. +const ChannelsReorderUsernamesRequestTypeID = 0xb45ced1d + +// Ensuring interfaces in compile-time for ChannelsReorderUsernamesRequest. +var ( + _ bin.Encoder = &ChannelsReorderUsernamesRequest{} + _ bin.Decoder = &ChannelsReorderUsernamesRequest{} + _ bin.BareEncoder = &ChannelsReorderUsernamesRequest{} + _ bin.BareDecoder = &ChannelsReorderUsernamesRequest{} +) + +func (r *ChannelsReorderUsernamesRequest) Zero() bool { + if r == nil { + return true + } + if !(r.Channel == nil) { + return false + } + if !(r.Order == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (r *ChannelsReorderUsernamesRequest) String() string { + if r == nil { + return "ChannelsReorderUsernamesRequest(nil)" + } + type Alias ChannelsReorderUsernamesRequest + return fmt.Sprintf("ChannelsReorderUsernamesRequest%+v", Alias(*r)) +} + +// FillFrom fills ChannelsReorderUsernamesRequest from given interface. +func (r *ChannelsReorderUsernamesRequest) FillFrom(from interface { + GetChannel() (value InputChannelClass) + GetOrder() (value []string) +}) { + r.Channel = from.GetChannel() + r.Order = from.GetOrder() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChannelsReorderUsernamesRequest) TypeID() uint32 { + return ChannelsReorderUsernamesRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChannelsReorderUsernamesRequest) TypeName() string { + return "channels.reorderUsernames" +} + +// TypeInfo returns info about TL type. +func (r *ChannelsReorderUsernamesRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "channels.reorderUsernames", + ID: ChannelsReorderUsernamesRequestTypeID, + } + if r == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Channel", + SchemaName: "channel", + }, + { + Name: "Order", + SchemaName: "order", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (r *ChannelsReorderUsernamesRequest) Encode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode channels.reorderUsernames#b45ced1d as nil") + } + b.PutID(ChannelsReorderUsernamesRequestTypeID) + return r.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (r *ChannelsReorderUsernamesRequest) EncodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode channels.reorderUsernames#b45ced1d as nil") + } + if r.Channel == nil { + return fmt.Errorf("unable to encode channels.reorderUsernames#b45ced1d: field channel is nil") + } + if err := r.Channel.Encode(b); err != nil { + return fmt.Errorf("unable to encode channels.reorderUsernames#b45ced1d: field channel: %w", err) + } + b.PutVectorHeader(len(r.Order)) + for _, v := range r.Order { + b.PutString(v) + } + return nil +} + +// Decode implements bin.Decoder. +func (r *ChannelsReorderUsernamesRequest) Decode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode channels.reorderUsernames#b45ced1d to nil") + } + if err := b.ConsumeID(ChannelsReorderUsernamesRequestTypeID); err != nil { + return fmt.Errorf("unable to decode channels.reorderUsernames#b45ced1d: %w", err) + } + return r.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (r *ChannelsReorderUsernamesRequest) DecodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode channels.reorderUsernames#b45ced1d to nil") + } + { + value, err := DecodeInputChannel(b) + if err != nil { + return fmt.Errorf("unable to decode channels.reorderUsernames#b45ced1d: field channel: %w", err) + } + r.Channel = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode channels.reorderUsernames#b45ced1d: field order: %w", err) + } + + if headerLen > 0 { + r.Order = make([]string, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode channels.reorderUsernames#b45ced1d: field order: %w", err) + } + r.Order = append(r.Order, value) + } + } + return nil +} + +// GetChannel returns value of Channel field. +func (r *ChannelsReorderUsernamesRequest) GetChannel() (value InputChannelClass) { + if r == nil { + return + } + return r.Channel +} + +// GetOrder returns value of Order field. +func (r *ChannelsReorderUsernamesRequest) GetOrder() (value []string) { + if r == nil { + return + } + return r.Order +} + +// GetChannelAsNotEmpty returns mapped value of Channel field. +func (r *ChannelsReorderUsernamesRequest) GetChannelAsNotEmpty() (NotEmptyInputChannel, bool) { + return r.Channel.AsNotEmpty() +} + +// ChannelsReorderUsernames invokes method channels.reorderUsernames#b45ced1d returning error if any. +// +// See https://core.telegram.org/method/channels.reorderUsernames for reference. +func (c *Client) ChannelsReorderUsernames(ctx context.Context, request *ChannelsReorderUsernamesRequest) (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_channels_reorder_usernames_slices_gen.go b/tg/tl_channels_reorder_usernames_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_channels_reorder_usernames_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_toggle_forum_gen.go b/tg/tl_channels_toggle_forum_gen.go new file mode 100644 index 0000000000..a843000b34 --- /dev/null +++ b/tg/tl_channels_toggle_forum_gen.go @@ -0,0 +1,210 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// ChannelsToggleForumRequest represents TL type `channels.toggleForum#a4298b29`. +// +// See https://core.telegram.org/method/channels.toggleForum for reference. +type ChannelsToggleForumRequest struct { + // Channel field of ChannelsToggleForumRequest. + Channel InputChannelClass + // Enabled field of ChannelsToggleForumRequest. + Enabled bool +} + +// ChannelsToggleForumRequestTypeID is TL type id of ChannelsToggleForumRequest. +const ChannelsToggleForumRequestTypeID = 0xa4298b29 + +// Ensuring interfaces in compile-time for ChannelsToggleForumRequest. +var ( + _ bin.Encoder = &ChannelsToggleForumRequest{} + _ bin.Decoder = &ChannelsToggleForumRequest{} + _ bin.BareEncoder = &ChannelsToggleForumRequest{} + _ bin.BareDecoder = &ChannelsToggleForumRequest{} +) + +func (t *ChannelsToggleForumRequest) Zero() bool { + if t == nil { + return true + } + if !(t.Channel == nil) { + return false + } + if !(t.Enabled == false) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (t *ChannelsToggleForumRequest) String() string { + if t == nil { + return "ChannelsToggleForumRequest(nil)" + } + type Alias ChannelsToggleForumRequest + return fmt.Sprintf("ChannelsToggleForumRequest%+v", Alias(*t)) +} + +// FillFrom fills ChannelsToggleForumRequest from given interface. +func (t *ChannelsToggleForumRequest) FillFrom(from interface { + GetChannel() (value InputChannelClass) + GetEnabled() (value bool) +}) { + t.Channel = from.GetChannel() + t.Enabled = from.GetEnabled() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChannelsToggleForumRequest) TypeID() uint32 { + return ChannelsToggleForumRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChannelsToggleForumRequest) TypeName() string { + return "channels.toggleForum" +} + +// TypeInfo returns info about TL type. +func (t *ChannelsToggleForumRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "channels.toggleForum", + ID: ChannelsToggleForumRequestTypeID, + } + if t == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Channel", + SchemaName: "channel", + }, + { + Name: "Enabled", + SchemaName: "enabled", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (t *ChannelsToggleForumRequest) Encode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode channels.toggleForum#a4298b29 as nil") + } + b.PutID(ChannelsToggleForumRequestTypeID) + return t.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (t *ChannelsToggleForumRequest) EncodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode channels.toggleForum#a4298b29 as nil") + } + if t.Channel == nil { + return fmt.Errorf("unable to encode channels.toggleForum#a4298b29: field channel is nil") + } + if err := t.Channel.Encode(b); err != nil { + return fmt.Errorf("unable to encode channels.toggleForum#a4298b29: field channel: %w", err) + } + b.PutBool(t.Enabled) + return nil +} + +// Decode implements bin.Decoder. +func (t *ChannelsToggleForumRequest) Decode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode channels.toggleForum#a4298b29 to nil") + } + if err := b.ConsumeID(ChannelsToggleForumRequestTypeID); err != nil { + return fmt.Errorf("unable to decode channels.toggleForum#a4298b29: %w", err) + } + return t.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (t *ChannelsToggleForumRequest) DecodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode channels.toggleForum#a4298b29 to nil") + } + { + value, err := DecodeInputChannel(b) + if err != nil { + return fmt.Errorf("unable to decode channels.toggleForum#a4298b29: field channel: %w", err) + } + t.Channel = value + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode channels.toggleForum#a4298b29: field enabled: %w", err) + } + t.Enabled = value + } + return nil +} + +// GetChannel returns value of Channel field. +func (t *ChannelsToggleForumRequest) GetChannel() (value InputChannelClass) { + if t == nil { + return + } + return t.Channel +} + +// GetEnabled returns value of Enabled field. +func (t *ChannelsToggleForumRequest) GetEnabled() (value bool) { + if t == nil { + return + } + return t.Enabled +} + +// GetChannelAsNotEmpty returns mapped value of Channel field. +func (t *ChannelsToggleForumRequest) GetChannelAsNotEmpty() (NotEmptyInputChannel, bool) { + return t.Channel.AsNotEmpty() +} + +// ChannelsToggleForum invokes method channels.toggleForum#a4298b29 returning error if any. +// +// See https://core.telegram.org/method/channels.toggleForum for reference. +func (c *Client) ChannelsToggleForum(ctx context.Context, request *ChannelsToggleForumRequest) (UpdatesClass, error) { + var result UpdatesBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.Updates, nil +} diff --git a/tg/tl_channels_toggle_forum_slices_gen.go b/tg/tl_channels_toggle_forum_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_channels_toggle_forum_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_toggle_username_gen.go b/tg/tl_channels_toggle_username_gen.go new file mode 100644 index 0000000000..55f1f59758 --- /dev/null +++ b/tg/tl_channels_toggle_username_gen.go @@ -0,0 +1,238 @@ +// 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{} +) + +// ChannelsToggleUsernameRequest represents TL type `channels.toggleUsername#50f24105`. +// +// See https://core.telegram.org/method/channels.toggleUsername for reference. +type ChannelsToggleUsernameRequest struct { + // Channel field of ChannelsToggleUsernameRequest. + Channel InputChannelClass + // Username field of ChannelsToggleUsernameRequest. + Username string + // Active field of ChannelsToggleUsernameRequest. + Active bool +} + +// ChannelsToggleUsernameRequestTypeID is TL type id of ChannelsToggleUsernameRequest. +const ChannelsToggleUsernameRequestTypeID = 0x50f24105 + +// Ensuring interfaces in compile-time for ChannelsToggleUsernameRequest. +var ( + _ bin.Encoder = &ChannelsToggleUsernameRequest{} + _ bin.Decoder = &ChannelsToggleUsernameRequest{} + _ bin.BareEncoder = &ChannelsToggleUsernameRequest{} + _ bin.BareDecoder = &ChannelsToggleUsernameRequest{} +) + +func (t *ChannelsToggleUsernameRequest) Zero() bool { + if t == nil { + return true + } + if !(t.Channel == nil) { + return false + } + if !(t.Username == "") { + return false + } + if !(t.Active == false) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (t *ChannelsToggleUsernameRequest) String() string { + if t == nil { + return "ChannelsToggleUsernameRequest(nil)" + } + type Alias ChannelsToggleUsernameRequest + return fmt.Sprintf("ChannelsToggleUsernameRequest%+v", Alias(*t)) +} + +// FillFrom fills ChannelsToggleUsernameRequest from given interface. +func (t *ChannelsToggleUsernameRequest) FillFrom(from interface { + GetChannel() (value InputChannelClass) + GetUsername() (value string) + GetActive() (value bool) +}) { + t.Channel = from.GetChannel() + t.Username = from.GetUsername() + t.Active = from.GetActive() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChannelsToggleUsernameRequest) TypeID() uint32 { + return ChannelsToggleUsernameRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChannelsToggleUsernameRequest) TypeName() string { + return "channels.toggleUsername" +} + +// TypeInfo returns info about TL type. +func (t *ChannelsToggleUsernameRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "channels.toggleUsername", + ID: ChannelsToggleUsernameRequestTypeID, + } + if t == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Channel", + SchemaName: "channel", + }, + { + Name: "Username", + SchemaName: "username", + }, + { + Name: "Active", + SchemaName: "active", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (t *ChannelsToggleUsernameRequest) Encode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode channels.toggleUsername#50f24105 as nil") + } + b.PutID(ChannelsToggleUsernameRequestTypeID) + return t.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (t *ChannelsToggleUsernameRequest) EncodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode channels.toggleUsername#50f24105 as nil") + } + if t.Channel == nil { + return fmt.Errorf("unable to encode channels.toggleUsername#50f24105: field channel is nil") + } + if err := t.Channel.Encode(b); err != nil { + return fmt.Errorf("unable to encode channels.toggleUsername#50f24105: field channel: %w", err) + } + b.PutString(t.Username) + b.PutBool(t.Active) + return nil +} + +// Decode implements bin.Decoder. +func (t *ChannelsToggleUsernameRequest) Decode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode channels.toggleUsername#50f24105 to nil") + } + if err := b.ConsumeID(ChannelsToggleUsernameRequestTypeID); err != nil { + return fmt.Errorf("unable to decode channels.toggleUsername#50f24105: %w", err) + } + return t.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (t *ChannelsToggleUsernameRequest) DecodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode channels.toggleUsername#50f24105 to nil") + } + { + value, err := DecodeInputChannel(b) + if err != nil { + return fmt.Errorf("unable to decode channels.toggleUsername#50f24105: field channel: %w", err) + } + t.Channel = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode channels.toggleUsername#50f24105: field username: %w", err) + } + t.Username = value + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode channels.toggleUsername#50f24105: field active: %w", err) + } + t.Active = value + } + return nil +} + +// GetChannel returns value of Channel field. +func (t *ChannelsToggleUsernameRequest) GetChannel() (value InputChannelClass) { + if t == nil { + return + } + return t.Channel +} + +// GetUsername returns value of Username field. +func (t *ChannelsToggleUsernameRequest) GetUsername() (value string) { + if t == nil { + return + } + return t.Username +} + +// GetActive returns value of Active field. +func (t *ChannelsToggleUsernameRequest) GetActive() (value bool) { + if t == nil { + return + } + return t.Active +} + +// GetChannelAsNotEmpty returns mapped value of Channel field. +func (t *ChannelsToggleUsernameRequest) GetChannelAsNotEmpty() (NotEmptyInputChannel, bool) { + return t.Channel.AsNotEmpty() +} + +// ChannelsToggleUsername invokes method channels.toggleUsername#50f24105 returning error if any. +// +// See https://core.telegram.org/method/channels.toggleUsername for reference. +func (c *Client) ChannelsToggleUsername(ctx context.Context, request *ChannelsToggleUsernameRequest) (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_channels_toggle_username_slices_gen.go b/tg/tl_channels_toggle_username_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_channels_toggle_username_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_update_pinned_forum_topic_gen.go b/tg/tl_channels_update_pinned_forum_topic_gen.go new file mode 100644 index 0000000000..6a33c99f3d --- /dev/null +++ b/tg/tl_channels_update_pinned_forum_topic_gen.go @@ -0,0 +1,237 @@ +// 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{} +) + +// ChannelsUpdatePinnedForumTopicRequest represents TL type `channels.updatePinnedForumTopic#6c2d9026`. +// +// See https://core.telegram.org/method/channels.updatePinnedForumTopic for reference. +type ChannelsUpdatePinnedForumTopicRequest struct { + // Channel field of ChannelsUpdatePinnedForumTopicRequest. + Channel InputChannelClass + // TopicID field of ChannelsUpdatePinnedForumTopicRequest. + TopicID int + // Pinned field of ChannelsUpdatePinnedForumTopicRequest. + Pinned bool +} + +// ChannelsUpdatePinnedForumTopicRequestTypeID is TL type id of ChannelsUpdatePinnedForumTopicRequest. +const ChannelsUpdatePinnedForumTopicRequestTypeID = 0x6c2d9026 + +// Ensuring interfaces in compile-time for ChannelsUpdatePinnedForumTopicRequest. +var ( + _ bin.Encoder = &ChannelsUpdatePinnedForumTopicRequest{} + _ bin.Decoder = &ChannelsUpdatePinnedForumTopicRequest{} + _ bin.BareEncoder = &ChannelsUpdatePinnedForumTopicRequest{} + _ bin.BareDecoder = &ChannelsUpdatePinnedForumTopicRequest{} +) + +func (u *ChannelsUpdatePinnedForumTopicRequest) Zero() bool { + if u == nil { + return true + } + if !(u.Channel == nil) { + return false + } + if !(u.TopicID == 0) { + return false + } + if !(u.Pinned == false) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *ChannelsUpdatePinnedForumTopicRequest) String() string { + if u == nil { + return "ChannelsUpdatePinnedForumTopicRequest(nil)" + } + type Alias ChannelsUpdatePinnedForumTopicRequest + return fmt.Sprintf("ChannelsUpdatePinnedForumTopicRequest%+v", Alias(*u)) +} + +// FillFrom fills ChannelsUpdatePinnedForumTopicRequest from given interface. +func (u *ChannelsUpdatePinnedForumTopicRequest) FillFrom(from interface { + GetChannel() (value InputChannelClass) + GetTopicID() (value int) + GetPinned() (value bool) +}) { + u.Channel = from.GetChannel() + u.TopicID = from.GetTopicID() + u.Pinned = from.GetPinned() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChannelsUpdatePinnedForumTopicRequest) TypeID() uint32 { + return ChannelsUpdatePinnedForumTopicRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChannelsUpdatePinnedForumTopicRequest) TypeName() string { + return "channels.updatePinnedForumTopic" +} + +// TypeInfo returns info about TL type. +func (u *ChannelsUpdatePinnedForumTopicRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "channels.updatePinnedForumTopic", + ID: ChannelsUpdatePinnedForumTopicRequestTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Channel", + SchemaName: "channel", + }, + { + Name: "TopicID", + SchemaName: "topic_id", + }, + { + Name: "Pinned", + SchemaName: "pinned", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (u *ChannelsUpdatePinnedForumTopicRequest) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode channels.updatePinnedForumTopic#6c2d9026 as nil") + } + b.PutID(ChannelsUpdatePinnedForumTopicRequestTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *ChannelsUpdatePinnedForumTopicRequest) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode channels.updatePinnedForumTopic#6c2d9026 as nil") + } + if u.Channel == nil { + return fmt.Errorf("unable to encode channels.updatePinnedForumTopic#6c2d9026: field channel is nil") + } + if err := u.Channel.Encode(b); err != nil { + return fmt.Errorf("unable to encode channels.updatePinnedForumTopic#6c2d9026: field channel: %w", err) + } + b.PutInt(u.TopicID) + b.PutBool(u.Pinned) + return nil +} + +// Decode implements bin.Decoder. +func (u *ChannelsUpdatePinnedForumTopicRequest) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode channels.updatePinnedForumTopic#6c2d9026 to nil") + } + if err := b.ConsumeID(ChannelsUpdatePinnedForumTopicRequestTypeID); err != nil { + return fmt.Errorf("unable to decode channels.updatePinnedForumTopic#6c2d9026: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *ChannelsUpdatePinnedForumTopicRequest) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode channels.updatePinnedForumTopic#6c2d9026 to nil") + } + { + value, err := DecodeInputChannel(b) + if err != nil { + return fmt.Errorf("unable to decode channels.updatePinnedForumTopic#6c2d9026: field channel: %w", err) + } + u.Channel = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode channels.updatePinnedForumTopic#6c2d9026: field topic_id: %w", err) + } + u.TopicID = value + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode channels.updatePinnedForumTopic#6c2d9026: field pinned: %w", err) + } + u.Pinned = value + } + return nil +} + +// GetChannel returns value of Channel field. +func (u *ChannelsUpdatePinnedForumTopicRequest) GetChannel() (value InputChannelClass) { + if u == nil { + return + } + return u.Channel +} + +// GetTopicID returns value of TopicID field. +func (u *ChannelsUpdatePinnedForumTopicRequest) GetTopicID() (value int) { + if u == nil { + return + } + return u.TopicID +} + +// GetPinned returns value of Pinned field. +func (u *ChannelsUpdatePinnedForumTopicRequest) GetPinned() (value bool) { + if u == nil { + return + } + return u.Pinned +} + +// GetChannelAsNotEmpty returns mapped value of Channel field. +func (u *ChannelsUpdatePinnedForumTopicRequest) GetChannelAsNotEmpty() (NotEmptyInputChannel, bool) { + return u.Channel.AsNotEmpty() +} + +// ChannelsUpdatePinnedForumTopic invokes method channels.updatePinnedForumTopic#6c2d9026 returning error if any. +// +// See https://core.telegram.org/method/channels.updatePinnedForumTopic for reference. +func (c *Client) ChannelsUpdatePinnedForumTopic(ctx context.Context, request *ChannelsUpdatePinnedForumTopicRequest) (UpdatesClass, error) { + var result UpdatesBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.Updates, nil +} diff --git a/tg/tl_channels_update_pinned_forum_topic_slices_gen.go b/tg/tl_channels_update_pinned_forum_topic_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_channels_update_pinned_forum_topic_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_chat_admin_rights_gen.go b/tg/tl_chat_admin_rights_gen.go index c2e0bed770..2c8f0b99b7 100644 --- a/tg/tl_chat_admin_rights_gen.go +++ b/tg/tl_chat_admin_rights_gen.go @@ -99,6 +99,8 @@ type ChatAdminRights struct { // 2) https://core.telegram.org/api/stats // 3) https://core.telegram.org/api/stats Other bool + // ManageTopics field of ChatAdminRights. + ManageTopics bool } // ChatAdminRightsTypeID is TL type id of ChatAdminRights. @@ -152,6 +154,9 @@ func (c *ChatAdminRights) Zero() bool { if !(c.Other == false) { return false } + if !(c.ManageTopics == false) { + return false + } return true } @@ -178,6 +183,7 @@ func (c *ChatAdminRights) FillFrom(from interface { GetAnonymous() (value bool) GetManageCall() (value bool) GetOther() (value bool) + GetManageTopics() (value bool) }) { c.ChangeInfo = from.GetChangeInfo() c.PostMessages = from.GetPostMessages() @@ -190,6 +196,7 @@ func (c *ChatAdminRights) FillFrom(from interface { c.Anonymous = from.GetAnonymous() c.ManageCall = from.GetManageCall() c.Other = from.GetOther() + c.ManageTopics = from.GetManageTopics() } // TypeID returns type id in TL schema. @@ -270,6 +277,11 @@ func (c *ChatAdminRights) TypeInfo() tdp.Type { SchemaName: "other", Null: !c.Flags.Has(12), }, + { + Name: "ManageTopics", + SchemaName: "manage_topics", + Null: !c.Flags.Has(13), + }, } return typ } @@ -309,6 +321,9 @@ func (c *ChatAdminRights) SetFlags() { if !(c.Other == false) { c.Flags.Set(12) } + if !(c.ManageTopics == false) { + c.Flags.Set(13) + } } // Encode implements bin.Encoder. @@ -364,6 +379,7 @@ func (c *ChatAdminRights) DecodeBare(b *bin.Buffer) error { c.Anonymous = c.Flags.Has(10) c.ManageCall = c.Flags.Has(11) c.Other = c.Flags.Has(12) + c.ManageTopics = c.Flags.Has(13) return nil } @@ -575,3 +591,22 @@ func (c *ChatAdminRights) GetOther() (value bool) { } return c.Flags.Has(12) } + +// SetManageTopics sets value of ManageTopics conditional field. +func (c *ChatAdminRights) SetManageTopics(value bool) { + if value { + c.Flags.Set(13) + c.ManageTopics = true + } else { + c.Flags.Unset(13) + c.ManageTopics = false + } +} + +// GetManageTopics returns value of ManageTopics conditional field. +func (c *ChatAdminRights) GetManageTopics() (value bool) { + if c == nil { + return + } + return c.Flags.Has(13) +} diff --git a/tg/tl_chat_banned_rights_gen.go b/tg/tl_chat_banned_rights_gen.go index 409888aa74..955c2bd289 100644 --- a/tg/tl_chat_banned_rights_gen.go +++ b/tg/tl_chat_banned_rights_gen.go @@ -105,6 +105,8 @@ type ChatBannedRights struct { // Links: // 1) https://core.telegram.org/api/channel PinMessages bool + // ManageTopics field of ChatBannedRights. + ManageTopics bool // Validity of said permissions (it is considered forever any value less then 30 seconds // or more then 366 days). UntilDate int @@ -164,6 +166,9 @@ func (c *ChatBannedRights) Zero() bool { if !(c.PinMessages == false) { return false } + if !(c.ManageTopics == false) { + return false + } if !(c.UntilDate == 0) { return false } @@ -194,6 +199,7 @@ func (c *ChatBannedRights) FillFrom(from interface { GetChangeInfo() (value bool) GetInviteUsers() (value bool) GetPinMessages() (value bool) + GetManageTopics() (value bool) GetUntilDate() (value int) }) { c.ViewMessages = from.GetViewMessages() @@ -208,6 +214,7 @@ func (c *ChatBannedRights) FillFrom(from interface { c.ChangeInfo = from.GetChangeInfo() c.InviteUsers = from.GetInviteUsers() c.PinMessages = from.GetPinMessages() + c.ManageTopics = from.GetManageTopics() c.UntilDate = from.GetUntilDate() } @@ -294,6 +301,11 @@ func (c *ChatBannedRights) TypeInfo() tdp.Type { SchemaName: "pin_messages", Null: !c.Flags.Has(17), }, + { + Name: "ManageTopics", + SchemaName: "manage_topics", + Null: !c.Flags.Has(18), + }, { Name: "UntilDate", SchemaName: "until_date", @@ -340,6 +352,9 @@ func (c *ChatBannedRights) SetFlags() { if !(c.PinMessages == false) { c.Flags.Set(17) } + if !(c.ManageTopics == false) { + c.Flags.Set(18) + } } // Encode implements bin.Encoder. @@ -397,6 +412,7 @@ func (c *ChatBannedRights) DecodeBare(b *bin.Buffer) error { c.ChangeInfo = c.Flags.Has(10) c.InviteUsers = c.Flags.Has(15) c.PinMessages = c.Flags.Has(17) + c.ManageTopics = c.Flags.Has(18) { value, err := b.Int() if err != nil { @@ -635,6 +651,25 @@ func (c *ChatBannedRights) GetPinMessages() (value bool) { return c.Flags.Has(17) } +// SetManageTopics sets value of ManageTopics conditional field. +func (c *ChatBannedRights) SetManageTopics(value bool) { + if value { + c.Flags.Set(18) + c.ManageTopics = true + } else { + c.Flags.Unset(18) + c.ManageTopics = false + } +} + +// GetManageTopics returns value of ManageTopics conditional field. +func (c *ChatBannedRights) GetManageTopics() (value bool) { + if c == nil { + return + } + return c.Flags.Has(18) +} + // GetUntilDate returns value of UntilDate field. func (c *ChatBannedRights) GetUntilDate() (value int) { if c == nil { diff --git a/tg/tl_chat_gen.go b/tg/tl_chat_gen.go index 457e3974eb..5874dfc46f 100644 --- a/tg/tl_chat_gen.go +++ b/tg/tl_chat_gen.go @@ -999,7 +999,7 @@ func (c *ChatForbidden) GetTitle() (value string) { return c.Title } -// Channel represents TL type `channel#8261ac61`. +// Channel represents TL type `channel#83259464`. // Channel/supergroup info // // See https://core.telegram.org/constructor/channel for reference. @@ -1071,6 +1071,10 @@ type Channel struct { // 1) https://core.telegram.org/api/invites#join-requests // 2) https://core.telegram.org/method/channels.toggleJoinRequest JoinRequest bool + // Forum field of Channel. + Forum bool + // Flags2 field of Channel. + Flags2 bin.Fields // ID of the channel ID int64 // Access hash @@ -1117,10 +1121,14 @@ type Channel struct { // // Use SetParticipantsCount and GetParticipantsCount helpers. ParticipantsCount int + // Usernames field of Channel. + // + // Use SetUsernames and GetUsernames helpers. + Usernames []Username } // ChannelTypeID is TL type id of Channel. -const ChannelTypeID = 0x8261ac61 +const ChannelTypeID = 0x83259464 // construct implements constructor of ChatClass. func (c Channel) construct() ChatClass { return &c } @@ -1199,6 +1207,12 @@ func (c *Channel) Zero() bool { if !(c.JoinRequest == false) { return false } + if !(c.Forum == false) { + return false + } + if !(c.Flags2.Zero()) { + return false + } if !(c.ID == 0) { return false } @@ -1232,6 +1246,9 @@ func (c *Channel) Zero() bool { if !(c.ParticipantsCount == 0) { return false } + if !(c.Usernames == nil) { + return false + } return true } @@ -1266,6 +1283,7 @@ func (c *Channel) FillFrom(from interface { GetNoforwards() (value bool) GetJoinToSend() (value bool) GetJoinRequest() (value bool) + GetForum() (value bool) GetID() (value int64) GetAccessHash() (value int64, ok bool) GetTitle() (value string) @@ -1277,6 +1295,7 @@ func (c *Channel) FillFrom(from interface { GetBannedRights() (value ChatBannedRights, ok bool) GetDefaultBannedRights() (value ChatBannedRights, ok bool) GetParticipantsCount() (value int, ok bool) + GetUsernames() (value []Username, ok bool) }) { c.Creator = from.GetCreator() c.Left = from.GetLeft() @@ -1297,6 +1316,7 @@ func (c *Channel) FillFrom(from interface { c.Noforwards = from.GetNoforwards() c.JoinToSend = from.GetJoinToSend() c.JoinRequest = from.GetJoinRequest() + c.Forum = from.GetForum() c.ID = from.GetID() if val, ok := from.GetAccessHash(); ok { c.AccessHash = val @@ -1329,6 +1349,10 @@ func (c *Channel) FillFrom(from interface { c.ParticipantsCount = val } + if val, ok := from.GetUsernames(); ok { + c.Usernames = val + } + } // TypeID returns type id in TL schema. @@ -1449,6 +1473,11 @@ func (c *Channel) TypeInfo() tdp.Type { SchemaName: "join_request", Null: !c.Flags.Has(29), }, + { + Name: "Forum", + SchemaName: "forum", + Null: !c.Flags.Has(30), + }, { Name: "ID", SchemaName: "id", @@ -1500,6 +1529,11 @@ func (c *Channel) TypeInfo() tdp.Type { SchemaName: "participants_count", Null: !c.Flags.Has(17), }, + { + Name: "Usernames", + SchemaName: "usernames", + Null: !c.Flags2.Has(0), + }, } return typ } @@ -1563,6 +1597,9 @@ func (c *Channel) SetFlags() { if !(c.JoinRequest == false) { c.Flags.Set(29) } + if !(c.Forum == false) { + c.Flags.Set(30) + } if !(c.AccessHash == 0) { c.Flags.Set(13) } @@ -1584,12 +1621,15 @@ func (c *Channel) SetFlags() { if !(c.ParticipantsCount == 0) { c.Flags.Set(17) } + if !(c.Usernames == nil) { + c.Flags2.Set(0) + } } // Encode implements bin.Encoder. func (c *Channel) Encode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode channel#8261ac61 as nil") + return fmt.Errorf("can't encode channel#83259464 as nil") } b.PutID(ChannelTypeID) return c.EncodeBare(b) @@ -1598,11 +1638,14 @@ func (c *Channel) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (c *Channel) EncodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode channel#8261ac61 as nil") + return fmt.Errorf("can't encode channel#83259464 as nil") } c.SetFlags() if err := c.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode channel#8261ac61: field flags: %w", err) + return fmt.Errorf("unable to encode channel#83259464: field flags: %w", err) + } + if err := c.Flags2.Encode(b); err != nil { + return fmt.Errorf("unable to encode channel#83259464: field flags2: %w", err) } b.PutLong(c.ID) if c.Flags.Has(13) { @@ -1613,48 +1656,56 @@ func (c *Channel) EncodeBare(b *bin.Buffer) error { b.PutString(c.Username) } if c.Photo == nil { - return fmt.Errorf("unable to encode channel#8261ac61: field photo is nil") + return fmt.Errorf("unable to encode channel#83259464: field photo is nil") } if err := c.Photo.Encode(b); err != nil { - return fmt.Errorf("unable to encode channel#8261ac61: field photo: %w", err) + return fmt.Errorf("unable to encode channel#83259464: field photo: %w", err) } b.PutInt(c.Date) if c.Flags.Has(9) { b.PutVectorHeader(len(c.RestrictionReason)) for idx, v := range c.RestrictionReason { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode channel#8261ac61: field restriction_reason element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode channel#83259464: field restriction_reason element with index %d: %w", idx, err) } } } if c.Flags.Has(14) { if err := c.AdminRights.Encode(b); err != nil { - return fmt.Errorf("unable to encode channel#8261ac61: field admin_rights: %w", err) + return fmt.Errorf("unable to encode channel#83259464: field admin_rights: %w", err) } } if c.Flags.Has(15) { if err := c.BannedRights.Encode(b); err != nil { - return fmt.Errorf("unable to encode channel#8261ac61: field banned_rights: %w", err) + return fmt.Errorf("unable to encode channel#83259464: field banned_rights: %w", err) } } if c.Flags.Has(18) { if err := c.DefaultBannedRights.Encode(b); err != nil { - return fmt.Errorf("unable to encode channel#8261ac61: field default_banned_rights: %w", err) + return fmt.Errorf("unable to encode channel#83259464: field default_banned_rights: %w", err) } } if c.Flags.Has(17) { b.PutInt(c.ParticipantsCount) } + if c.Flags2.Has(0) { + b.PutVectorHeader(len(c.Usernames)) + for idx, v := range c.Usernames { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode channel#83259464: field usernames element with index %d: %w", idx, err) + } + } + } return nil } // Decode implements bin.Decoder. func (c *Channel) Decode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode channel#8261ac61 to nil") + return fmt.Errorf("can't decode channel#83259464 to nil") } if err := b.ConsumeID(ChannelTypeID); err != nil { - return fmt.Errorf("unable to decode channel#8261ac61: %w", err) + return fmt.Errorf("unable to decode channel#83259464: %w", err) } return c.DecodeBare(b) } @@ -1662,11 +1713,11 @@ func (c *Channel) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (c *Channel) DecodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode channel#8261ac61 to nil") + return fmt.Errorf("can't decode channel#83259464 to nil") } { if err := c.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode channel#8261ac61: field flags: %w", err) + return fmt.Errorf("unable to decode channel#83259464: field flags: %w", err) } } c.Creator = c.Flags.Has(0) @@ -1688,52 +1739,58 @@ func (c *Channel) DecodeBare(b *bin.Buffer) error { c.Noforwards = c.Flags.Has(27) c.JoinToSend = c.Flags.Has(28) c.JoinRequest = c.Flags.Has(29) + c.Forum = c.Flags.Has(30) + { + if err := c.Flags2.Decode(b); err != nil { + return fmt.Errorf("unable to decode channel#83259464: field flags2: %w", err) + } + } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode channel#8261ac61: field id: %w", err) + return fmt.Errorf("unable to decode channel#83259464: field id: %w", err) } c.ID = value } if c.Flags.Has(13) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode channel#8261ac61: field access_hash: %w", err) + return fmt.Errorf("unable to decode channel#83259464: field access_hash: %w", err) } c.AccessHash = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode channel#8261ac61: field title: %w", err) + return fmt.Errorf("unable to decode channel#83259464: field title: %w", err) } c.Title = value } if c.Flags.Has(6) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode channel#8261ac61: field username: %w", err) + return fmt.Errorf("unable to decode channel#83259464: field username: %w", err) } c.Username = value } { value, err := DecodeChatPhoto(b) if err != nil { - return fmt.Errorf("unable to decode channel#8261ac61: field photo: %w", err) + return fmt.Errorf("unable to decode channel#83259464: field photo: %w", err) } c.Photo = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channel#8261ac61: field date: %w", err) + return fmt.Errorf("unable to decode channel#83259464: field date: %w", err) } c.Date = value } if c.Flags.Has(9) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode channel#8261ac61: field restriction_reason: %w", err) + return fmt.Errorf("unable to decode channel#83259464: field restriction_reason: %w", err) } if headerLen > 0 { @@ -1742,33 +1799,50 @@ func (c *Channel) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value RestrictionReason if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode channel#8261ac61: field restriction_reason: %w", err) + return fmt.Errorf("unable to decode channel#83259464: field restriction_reason: %w", err) } c.RestrictionReason = append(c.RestrictionReason, value) } } if c.Flags.Has(14) { if err := c.AdminRights.Decode(b); err != nil { - return fmt.Errorf("unable to decode channel#8261ac61: field admin_rights: %w", err) + return fmt.Errorf("unable to decode channel#83259464: field admin_rights: %w", err) } } if c.Flags.Has(15) { if err := c.BannedRights.Decode(b); err != nil { - return fmt.Errorf("unable to decode channel#8261ac61: field banned_rights: %w", err) + return fmt.Errorf("unable to decode channel#83259464: field banned_rights: %w", err) } } if c.Flags.Has(18) { if err := c.DefaultBannedRights.Decode(b); err != nil { - return fmt.Errorf("unable to decode channel#8261ac61: field default_banned_rights: %w", err) + return fmt.Errorf("unable to decode channel#83259464: field default_banned_rights: %w", err) } } if c.Flags.Has(17) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channel#8261ac61: field participants_count: %w", err) + return fmt.Errorf("unable to decode channel#83259464: field participants_count: %w", err) } c.ParticipantsCount = value } + if c.Flags2.Has(0) { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode channel#83259464: field usernames: %w", err) + } + + if headerLen > 0 { + c.Usernames = make([]Username, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value Username + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode channel#83259464: field usernames: %w", err) + } + c.Usernames = append(c.Usernames, value) + } + } return nil } @@ -2133,6 +2207,25 @@ func (c *Channel) GetJoinRequest() (value bool) { return c.Flags.Has(29) } +// SetForum sets value of Forum conditional field. +func (c *Channel) SetForum(value bool) { + if value { + c.Flags.Set(30) + c.Forum = true + } else { + c.Flags.Unset(30) + c.Forum = false + } +} + +// GetForum returns value of Forum conditional field. +func (c *Channel) GetForum() (value bool) { + if c == nil { + return + } + return c.Flags.Has(30) +} + // GetID returns value of ID field. func (c *Channel) GetID() (value int64) { if c == nil { @@ -2291,6 +2384,24 @@ func (c *Channel) GetParticipantsCount() (value int, ok bool) { return c.ParticipantsCount, true } +// SetUsernames sets value of Usernames conditional field. +func (c *Channel) SetUsernames(value []Username) { + c.Flags2.Set(0) + c.Usernames = value +} + +// GetUsernames returns value of Usernames conditional field and +// boolean which is true if field was set. +func (c *Channel) GetUsernames() (value []Username, ok bool) { + if c == nil { + return + } + if !c.Flags2.Has(0) { + return value, false + } + return c.Usernames, true +} + // ChannelForbidden represents TL type `channelForbidden#17d493d5`. // Indicates a channel/supergroup we can't access because we were banned, or for some // other reason. @@ -2637,7 +2748,7 @@ const ChatClassName = "Chat" // case *tg.ChatEmpty: // chatEmpty#29562865 // case *tg.Chat: // chat#41cbf256 // case *tg.ChatForbidden: // chatForbidden#6592a1a7 -// case *tg.Channel: // channel#8261ac61 +// case *tg.Channel: // channel#83259464 // case *tg.ChannelForbidden: // channelForbidden#17d493d5 // default: panic(v) // } @@ -2930,7 +3041,7 @@ func DecodeChat(buf *bin.Buffer) (ChatClass, error) { } return &v, nil case ChannelTypeID: - // Decoding channel#8261ac61. + // Decoding channel#83259464. v := Channel{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode ChatClass: %w", err) diff --git a/tg/tl_forum_topic_gen.go b/tg/tl_forum_topic_gen.go new file mode 100644 index 0000000000..1c5ff34b88 --- /dev/null +++ b/tg/tl_forum_topic_gen.go @@ -0,0 +1,918 @@ +// 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{} +) + +// ForumTopicDeleted represents TL type `forumTopicDeleted#23f109b`. +// +// See https://core.telegram.org/constructor/forumTopicDeleted for reference. +type ForumTopicDeleted struct { + // ID field of ForumTopicDeleted. + ID int +} + +// ForumTopicDeletedTypeID is TL type id of ForumTopicDeleted. +const ForumTopicDeletedTypeID = 0x23f109b + +// construct implements constructor of ForumTopicClass. +func (f ForumTopicDeleted) construct() ForumTopicClass { return &f } + +// Ensuring interfaces in compile-time for ForumTopicDeleted. +var ( + _ bin.Encoder = &ForumTopicDeleted{} + _ bin.Decoder = &ForumTopicDeleted{} + _ bin.BareEncoder = &ForumTopicDeleted{} + _ bin.BareDecoder = &ForumTopicDeleted{} + + _ ForumTopicClass = &ForumTopicDeleted{} +) + +func (f *ForumTopicDeleted) Zero() bool { + if f == nil { + return true + } + if !(f.ID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (f *ForumTopicDeleted) String() string { + if f == nil { + return "ForumTopicDeleted(nil)" + } + type Alias ForumTopicDeleted + return fmt.Sprintf("ForumTopicDeleted%+v", Alias(*f)) +} + +// FillFrom fills ForumTopicDeleted from given interface. +func (f *ForumTopicDeleted) FillFrom(from interface { + GetID() (value int) +}) { + f.ID = from.GetID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ForumTopicDeleted) TypeID() uint32 { + return ForumTopicDeletedTypeID +} + +// TypeName returns name of type in TL schema. +func (*ForumTopicDeleted) TypeName() string { + return "forumTopicDeleted" +} + +// TypeInfo returns info about TL type. +func (f *ForumTopicDeleted) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "forumTopicDeleted", + ID: ForumTopicDeletedTypeID, + } + if f == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ID", + SchemaName: "id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (f *ForumTopicDeleted) Encode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode forumTopicDeleted#23f109b as nil") + } + b.PutID(ForumTopicDeletedTypeID) + return f.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (f *ForumTopicDeleted) EncodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode forumTopicDeleted#23f109b as nil") + } + b.PutInt(f.ID) + return nil +} + +// Decode implements bin.Decoder. +func (f *ForumTopicDeleted) Decode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode forumTopicDeleted#23f109b to nil") + } + if err := b.ConsumeID(ForumTopicDeletedTypeID); err != nil { + return fmt.Errorf("unable to decode forumTopicDeleted#23f109b: %w", err) + } + return f.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (f *ForumTopicDeleted) DecodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode forumTopicDeleted#23f109b to nil") + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode forumTopicDeleted#23f109b: field id: %w", err) + } + f.ID = value + } + return nil +} + +// GetID returns value of ID field. +func (f *ForumTopicDeleted) GetID() (value int) { + if f == nil { + return + } + return f.ID +} + +// ForumTopic represents TL type `forumTopic#71701da9`. +// +// See https://core.telegram.org/constructor/forumTopic for reference. +type ForumTopic struct { + // Flags field of ForumTopic. + Flags bin.Fields + // My field of ForumTopic. + My bool + // Closed field of ForumTopic. + Closed bool + // Pinned field of ForumTopic. + Pinned bool + // ID field of ForumTopic. + ID int + // Date field of ForumTopic. + Date int + // Title field of ForumTopic. + Title string + // IconColor field of ForumTopic. + IconColor int + // IconEmojiID field of ForumTopic. + // + // Use SetIconEmojiID and GetIconEmojiID helpers. + IconEmojiID int64 + // TopMessage field of ForumTopic. + TopMessage int + // ReadInboxMaxID field of ForumTopic. + ReadInboxMaxID int + // ReadOutboxMaxID field of ForumTopic. + ReadOutboxMaxID int + // UnreadCount field of ForumTopic. + UnreadCount int + // UnreadMentionsCount field of ForumTopic. + UnreadMentionsCount int + // UnreadReactionsCount field of ForumTopic. + UnreadReactionsCount int + // FromID field of ForumTopic. + FromID PeerClass + // NotifySettings field of ForumTopic. + NotifySettings PeerNotifySettings + // Draft field of ForumTopic. + // + // Use SetDraft and GetDraft helpers. + Draft DraftMessageClass +} + +// ForumTopicTypeID is TL type id of ForumTopic. +const ForumTopicTypeID = 0x71701da9 + +// construct implements constructor of ForumTopicClass. +func (f ForumTopic) construct() ForumTopicClass { return &f } + +// Ensuring interfaces in compile-time for ForumTopic. +var ( + _ bin.Encoder = &ForumTopic{} + _ bin.Decoder = &ForumTopic{} + _ bin.BareEncoder = &ForumTopic{} + _ bin.BareDecoder = &ForumTopic{} + + _ ForumTopicClass = &ForumTopic{} +) + +func (f *ForumTopic) Zero() bool { + if f == nil { + return true + } + if !(f.Flags.Zero()) { + return false + } + if !(f.My == false) { + return false + } + if !(f.Closed == false) { + return false + } + if !(f.Pinned == false) { + return false + } + if !(f.ID == 0) { + return false + } + if !(f.Date == 0) { + return false + } + if !(f.Title == "") { + return false + } + if !(f.IconColor == 0) { + return false + } + if !(f.IconEmojiID == 0) { + return false + } + if !(f.TopMessage == 0) { + return false + } + if !(f.ReadInboxMaxID == 0) { + return false + } + if !(f.ReadOutboxMaxID == 0) { + return false + } + if !(f.UnreadCount == 0) { + return false + } + if !(f.UnreadMentionsCount == 0) { + return false + } + if !(f.UnreadReactionsCount == 0) { + return false + } + if !(f.FromID == nil) { + return false + } + if !(f.NotifySettings.Zero()) { + return false + } + if !(f.Draft == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (f *ForumTopic) String() string { + if f == nil { + return "ForumTopic(nil)" + } + type Alias ForumTopic + return fmt.Sprintf("ForumTopic%+v", Alias(*f)) +} + +// FillFrom fills ForumTopic from given interface. +func (f *ForumTopic) FillFrom(from interface { + GetMy() (value bool) + GetClosed() (value bool) + GetPinned() (value bool) + GetID() (value int) + GetDate() (value int) + GetTitle() (value string) + GetIconColor() (value int) + GetIconEmojiID() (value int64, ok bool) + GetTopMessage() (value int) + GetReadInboxMaxID() (value int) + GetReadOutboxMaxID() (value int) + GetUnreadCount() (value int) + GetUnreadMentionsCount() (value int) + GetUnreadReactionsCount() (value int) + GetFromID() (value PeerClass) + GetNotifySettings() (value PeerNotifySettings) + GetDraft() (value DraftMessageClass, ok bool) +}) { + f.My = from.GetMy() + f.Closed = from.GetClosed() + f.Pinned = from.GetPinned() + f.ID = from.GetID() + f.Date = from.GetDate() + f.Title = from.GetTitle() + f.IconColor = from.GetIconColor() + if val, ok := from.GetIconEmojiID(); ok { + f.IconEmojiID = val + } + + f.TopMessage = from.GetTopMessage() + f.ReadInboxMaxID = from.GetReadInboxMaxID() + f.ReadOutboxMaxID = from.GetReadOutboxMaxID() + f.UnreadCount = from.GetUnreadCount() + f.UnreadMentionsCount = from.GetUnreadMentionsCount() + f.UnreadReactionsCount = from.GetUnreadReactionsCount() + f.FromID = from.GetFromID() + f.NotifySettings = from.GetNotifySettings() + if val, ok := from.GetDraft(); ok { + f.Draft = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ForumTopic) TypeID() uint32 { + return ForumTopicTypeID +} + +// TypeName returns name of type in TL schema. +func (*ForumTopic) TypeName() string { + return "forumTopic" +} + +// TypeInfo returns info about TL type. +func (f *ForumTopic) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "forumTopic", + ID: ForumTopicTypeID, + } + if f == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "My", + SchemaName: "my", + Null: !f.Flags.Has(1), + }, + { + Name: "Closed", + SchemaName: "closed", + Null: !f.Flags.Has(2), + }, + { + Name: "Pinned", + SchemaName: "pinned", + Null: !f.Flags.Has(3), + }, + { + Name: "ID", + SchemaName: "id", + }, + { + Name: "Date", + SchemaName: "date", + }, + { + Name: "Title", + SchemaName: "title", + }, + { + Name: "IconColor", + SchemaName: "icon_color", + }, + { + Name: "IconEmojiID", + SchemaName: "icon_emoji_id", + Null: !f.Flags.Has(0), + }, + { + Name: "TopMessage", + SchemaName: "top_message", + }, + { + Name: "ReadInboxMaxID", + SchemaName: "read_inbox_max_id", + }, + { + Name: "ReadOutboxMaxID", + SchemaName: "read_outbox_max_id", + }, + { + Name: "UnreadCount", + SchemaName: "unread_count", + }, + { + Name: "UnreadMentionsCount", + SchemaName: "unread_mentions_count", + }, + { + Name: "UnreadReactionsCount", + SchemaName: "unread_reactions_count", + }, + { + Name: "FromID", + SchemaName: "from_id", + }, + { + Name: "NotifySettings", + SchemaName: "notify_settings", + }, + { + Name: "Draft", + SchemaName: "draft", + Null: !f.Flags.Has(4), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (f *ForumTopic) SetFlags() { + if !(f.My == false) { + f.Flags.Set(1) + } + if !(f.Closed == false) { + f.Flags.Set(2) + } + if !(f.Pinned == false) { + f.Flags.Set(3) + } + if !(f.IconEmojiID == 0) { + f.Flags.Set(0) + } + if !(f.Draft == nil) { + f.Flags.Set(4) + } +} + +// Encode implements bin.Encoder. +func (f *ForumTopic) Encode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode forumTopic#71701da9 as nil") + } + b.PutID(ForumTopicTypeID) + return f.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (f *ForumTopic) EncodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode forumTopic#71701da9 as nil") + } + f.SetFlags() + if err := f.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode forumTopic#71701da9: field flags: %w", err) + } + b.PutInt(f.ID) + b.PutInt(f.Date) + b.PutString(f.Title) + b.PutInt(f.IconColor) + if f.Flags.Has(0) { + b.PutLong(f.IconEmojiID) + } + b.PutInt(f.TopMessage) + b.PutInt(f.ReadInboxMaxID) + b.PutInt(f.ReadOutboxMaxID) + b.PutInt(f.UnreadCount) + b.PutInt(f.UnreadMentionsCount) + b.PutInt(f.UnreadReactionsCount) + if f.FromID == nil { + return fmt.Errorf("unable to encode forumTopic#71701da9: field from_id is nil") + } + if err := f.FromID.Encode(b); err != nil { + return fmt.Errorf("unable to encode forumTopic#71701da9: field from_id: %w", err) + } + if err := f.NotifySettings.Encode(b); err != nil { + return fmt.Errorf("unable to encode forumTopic#71701da9: field notify_settings: %w", err) + } + if f.Flags.Has(4) { + if f.Draft == nil { + return fmt.Errorf("unable to encode forumTopic#71701da9: field draft is nil") + } + if err := f.Draft.Encode(b); err != nil { + return fmt.Errorf("unable to encode forumTopic#71701da9: field draft: %w", err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (f *ForumTopic) Decode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode forumTopic#71701da9 to nil") + } + if err := b.ConsumeID(ForumTopicTypeID); err != nil { + return fmt.Errorf("unable to decode forumTopic#71701da9: %w", err) + } + return f.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (f *ForumTopic) DecodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode forumTopic#71701da9 to nil") + } + { + if err := f.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode forumTopic#71701da9: field flags: %w", err) + } + } + f.My = f.Flags.Has(1) + f.Closed = f.Flags.Has(2) + f.Pinned = f.Flags.Has(3) + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode forumTopic#71701da9: field id: %w", err) + } + f.ID = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode forumTopic#71701da9: field date: %w", err) + } + f.Date = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode forumTopic#71701da9: field title: %w", err) + } + f.Title = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode forumTopic#71701da9: field icon_color: %w", err) + } + f.IconColor = value + } + if f.Flags.Has(0) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode forumTopic#71701da9: field icon_emoji_id: %w", err) + } + f.IconEmojiID = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode forumTopic#71701da9: field top_message: %w", err) + } + f.TopMessage = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode forumTopic#71701da9: field read_inbox_max_id: %w", err) + } + f.ReadInboxMaxID = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode forumTopic#71701da9: field read_outbox_max_id: %w", err) + } + f.ReadOutboxMaxID = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode forumTopic#71701da9: field unread_count: %w", err) + } + f.UnreadCount = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode forumTopic#71701da9: field unread_mentions_count: %w", err) + } + f.UnreadMentionsCount = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode forumTopic#71701da9: field unread_reactions_count: %w", err) + } + f.UnreadReactionsCount = value + } + { + value, err := DecodePeer(b) + if err != nil { + return fmt.Errorf("unable to decode forumTopic#71701da9: field from_id: %w", err) + } + f.FromID = value + } + { + if err := f.NotifySettings.Decode(b); err != nil { + return fmt.Errorf("unable to decode forumTopic#71701da9: field notify_settings: %w", err) + } + } + if f.Flags.Has(4) { + value, err := DecodeDraftMessage(b) + if err != nil { + return fmt.Errorf("unable to decode forumTopic#71701da9: field draft: %w", err) + } + f.Draft = value + } + return nil +} + +// SetMy sets value of My conditional field. +func (f *ForumTopic) SetMy(value bool) { + if value { + f.Flags.Set(1) + f.My = true + } else { + f.Flags.Unset(1) + f.My = false + } +} + +// GetMy returns value of My conditional field. +func (f *ForumTopic) GetMy() (value bool) { + if f == nil { + return + } + return f.Flags.Has(1) +} + +// SetClosed sets value of Closed conditional field. +func (f *ForumTopic) SetClosed(value bool) { + if value { + f.Flags.Set(2) + f.Closed = true + } else { + f.Flags.Unset(2) + f.Closed = false + } +} + +// GetClosed returns value of Closed conditional field. +func (f *ForumTopic) GetClosed() (value bool) { + if f == nil { + return + } + return f.Flags.Has(2) +} + +// SetPinned sets value of Pinned conditional field. +func (f *ForumTopic) SetPinned(value bool) { + if value { + f.Flags.Set(3) + f.Pinned = true + } else { + f.Flags.Unset(3) + f.Pinned = false + } +} + +// GetPinned returns value of Pinned conditional field. +func (f *ForumTopic) GetPinned() (value bool) { + if f == nil { + return + } + return f.Flags.Has(3) +} + +// GetID returns value of ID field. +func (f *ForumTopic) GetID() (value int) { + if f == nil { + return + } + return f.ID +} + +// GetDate returns value of Date field. +func (f *ForumTopic) GetDate() (value int) { + if f == nil { + return + } + return f.Date +} + +// GetTitle returns value of Title field. +func (f *ForumTopic) GetTitle() (value string) { + if f == nil { + return + } + return f.Title +} + +// GetIconColor returns value of IconColor field. +func (f *ForumTopic) GetIconColor() (value int) { + if f == nil { + return + } + return f.IconColor +} + +// SetIconEmojiID sets value of IconEmojiID conditional field. +func (f *ForumTopic) SetIconEmojiID(value int64) { + f.Flags.Set(0) + f.IconEmojiID = value +} + +// GetIconEmojiID returns value of IconEmojiID conditional field and +// boolean which is true if field was set. +func (f *ForumTopic) GetIconEmojiID() (value int64, ok bool) { + if f == nil { + return + } + if !f.Flags.Has(0) { + return value, false + } + return f.IconEmojiID, true +} + +// GetTopMessage returns value of TopMessage field. +func (f *ForumTopic) GetTopMessage() (value int) { + if f == nil { + return + } + return f.TopMessage +} + +// GetReadInboxMaxID returns value of ReadInboxMaxID field. +func (f *ForumTopic) GetReadInboxMaxID() (value int) { + if f == nil { + return + } + return f.ReadInboxMaxID +} + +// GetReadOutboxMaxID returns value of ReadOutboxMaxID field. +func (f *ForumTopic) GetReadOutboxMaxID() (value int) { + if f == nil { + return + } + return f.ReadOutboxMaxID +} + +// GetUnreadCount returns value of UnreadCount field. +func (f *ForumTopic) GetUnreadCount() (value int) { + if f == nil { + return + } + return f.UnreadCount +} + +// GetUnreadMentionsCount returns value of UnreadMentionsCount field. +func (f *ForumTopic) GetUnreadMentionsCount() (value int) { + if f == nil { + return + } + return f.UnreadMentionsCount +} + +// GetUnreadReactionsCount returns value of UnreadReactionsCount field. +func (f *ForumTopic) GetUnreadReactionsCount() (value int) { + if f == nil { + return + } + return f.UnreadReactionsCount +} + +// GetFromID returns value of FromID field. +func (f *ForumTopic) GetFromID() (value PeerClass) { + if f == nil { + return + } + return f.FromID +} + +// GetNotifySettings returns value of NotifySettings field. +func (f *ForumTopic) GetNotifySettings() (value PeerNotifySettings) { + if f == nil { + return + } + return f.NotifySettings +} + +// SetDraft sets value of Draft conditional field. +func (f *ForumTopic) SetDraft(value DraftMessageClass) { + f.Flags.Set(4) + f.Draft = value +} + +// GetDraft returns value of Draft conditional field and +// boolean which is true if field was set. +func (f *ForumTopic) GetDraft() (value DraftMessageClass, ok bool) { + if f == nil { + return + } + if !f.Flags.Has(4) { + return value, false + } + return f.Draft, true +} + +// ForumTopicClassName is schema name of ForumTopicClass. +const ForumTopicClassName = "ForumTopic" + +// ForumTopicClass represents ForumTopic generic type. +// +// See https://core.telegram.org/type/ForumTopic for reference. +// +// Example: +// +// g, err := tg.DecodeForumTopic(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.ForumTopicDeleted: // forumTopicDeleted#23f109b +// case *tg.ForumTopic: // forumTopic#71701da9 +// default: panic(v) +// } +type ForumTopicClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() ForumTopicClass + + // 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 + + // ID field of ForumTopicDeleted. + GetID() (value int) +} + +// DecodeForumTopic implements binary de-serialization for ForumTopicClass. +func DecodeForumTopic(buf *bin.Buffer) (ForumTopicClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case ForumTopicDeletedTypeID: + // Decoding forumTopicDeleted#23f109b. + v := ForumTopicDeleted{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ForumTopicClass: %w", err) + } + return &v, nil + case ForumTopicTypeID: + // Decoding forumTopic#71701da9. + v := ForumTopic{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ForumTopicClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode ForumTopicClass: %w", bin.NewUnexpectedID(id)) + } +} + +// ForumTopic boxes the ForumTopicClass providing a helper. +type ForumTopicBox struct { + ForumTopic ForumTopicClass +} + +// Decode implements bin.Decoder for ForumTopicBox. +func (b *ForumTopicBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode ForumTopicBox to nil") + } + v, err := DecodeForumTopic(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.ForumTopic = v + return nil +} + +// Encode implements bin.Encode for ForumTopicBox. +func (b *ForumTopicBox) Encode(buf *bin.Buffer) error { + if b == nil || b.ForumTopic == nil { + return fmt.Errorf("unable to encode ForumTopicClass as nil") + } + return b.ForumTopic.Encode(buf) +} diff --git a/tg/tl_forum_topic_slices_gen.go b/tg/tl_forum_topic_slices_gen.go new file mode 100644 index 0000000000..360ba7d1dc --- /dev/null +++ b/tg/tl_forum_topic_slices_gen.go @@ -0,0 +1,427 @@ +//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{} +) + +// ForumTopicClassArray is adapter for slice of ForumTopicClass. +type ForumTopicClassArray []ForumTopicClass + +// Sort sorts slice of ForumTopicClass. +func (s ForumTopicClassArray) Sort(less func(a, b ForumTopicClass) bool) ForumTopicClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ForumTopicClass. +func (s ForumTopicClassArray) SortStable(less func(a, b ForumTopicClass) bool) ForumTopicClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ForumTopicClass. +func (s ForumTopicClassArray) Retain(keep func(x ForumTopicClass) bool) ForumTopicClassArray { + 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 ForumTopicClassArray) First() (v ForumTopicClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ForumTopicClassArray) Last() (v ForumTopicClass, 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 *ForumTopicClassArray) PopFirst() (v ForumTopicClass, 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 ForumTopicClass + 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 *ForumTopicClassArray) Pop() (v ForumTopicClass, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + +// SortByID sorts slice of ForumTopicClass by ID. +func (s ForumTopicClassArray) SortByID() ForumTopicClassArray { + return s.Sort(func(a, b ForumTopicClass) bool { + return a.GetID() < b.GetID() + }) +} + +// SortStableByID sorts slice of ForumTopicClass by ID. +func (s ForumTopicClassArray) SortStableByID() ForumTopicClassArray { + return s.SortStable(func(a, b ForumTopicClass) bool { + return a.GetID() < b.GetID() + }) +} + +// FillForumTopicDeletedMap fills only ForumTopicDeleted constructors to given map. +func (s ForumTopicClassArray) FillForumTopicDeletedMap(to map[int]*ForumTopicDeleted) { + for _, elem := range s { + value, ok := elem.(*ForumTopicDeleted) + if !ok { + continue + } + to[value.GetID()] = value + } +} + +// ForumTopicDeletedToMap collects only ForumTopicDeleted constructors to map. +func (s ForumTopicClassArray) ForumTopicDeletedToMap() map[int]*ForumTopicDeleted { + r := make(map[int]*ForumTopicDeleted, len(s)) + s.FillForumTopicDeletedMap(r) + return r +} + +// AsForumTopicDeleted returns copy with only ForumTopicDeleted constructors. +func (s ForumTopicClassArray) AsForumTopicDeleted() (to ForumTopicDeletedArray) { + for _, elem := range s { + value, ok := elem.(*ForumTopicDeleted) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// FillForumTopicMap fills only ForumTopic constructors to given map. +func (s ForumTopicClassArray) FillForumTopicMap(to map[int]*ForumTopic) { + for _, elem := range s { + value, ok := elem.(*ForumTopic) + if !ok { + continue + } + to[value.GetID()] = value + } +} + +// ForumTopicToMap collects only ForumTopic constructors to map. +func (s ForumTopicClassArray) ForumTopicToMap() map[int]*ForumTopic { + r := make(map[int]*ForumTopic, len(s)) + s.FillForumTopicMap(r) + return r +} + +// AsForumTopic returns copy with only ForumTopic constructors. +func (s ForumTopicClassArray) AsForumTopic() (to ForumTopicArray) { + for _, elem := range s { + value, ok := elem.(*ForumTopic) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// ForumTopicDeletedArray is adapter for slice of ForumTopicDeleted. +type ForumTopicDeletedArray []ForumTopicDeleted + +// Sort sorts slice of ForumTopicDeleted. +func (s ForumTopicDeletedArray) Sort(less func(a, b ForumTopicDeleted) bool) ForumTopicDeletedArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ForumTopicDeleted. +func (s ForumTopicDeletedArray) SortStable(less func(a, b ForumTopicDeleted) bool) ForumTopicDeletedArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ForumTopicDeleted. +func (s ForumTopicDeletedArray) Retain(keep func(x ForumTopicDeleted) bool) ForumTopicDeletedArray { + 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 ForumTopicDeletedArray) First() (v ForumTopicDeleted, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ForumTopicDeletedArray) Last() (v ForumTopicDeleted, 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 *ForumTopicDeletedArray) PopFirst() (v ForumTopicDeleted, 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 ForumTopicDeleted + 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 *ForumTopicDeletedArray) Pop() (v ForumTopicDeleted, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + +// SortByID sorts slice of ForumTopicDeleted by ID. +func (s ForumTopicDeletedArray) SortByID() ForumTopicDeletedArray { + return s.Sort(func(a, b ForumTopicDeleted) bool { + return a.GetID() < b.GetID() + }) +} + +// SortStableByID sorts slice of ForumTopicDeleted by ID. +func (s ForumTopicDeletedArray) SortStableByID() ForumTopicDeletedArray { + return s.SortStable(func(a, b ForumTopicDeleted) bool { + return a.GetID() < b.GetID() + }) +} + +// FillMap fills constructors to given map. +func (s ForumTopicDeletedArray) FillMap(to map[int]ForumTopicDeleted) { + for _, value := range s { + to[value.GetID()] = value + } +} + +// ToMap collects constructors to map. +func (s ForumTopicDeletedArray) ToMap() map[int]ForumTopicDeleted { + r := make(map[int]ForumTopicDeleted, len(s)) + s.FillMap(r) + return r +} + +// ForumTopicArray is adapter for slice of ForumTopic. +type ForumTopicArray []ForumTopic + +// Sort sorts slice of ForumTopic. +func (s ForumTopicArray) Sort(less func(a, b ForumTopic) bool) ForumTopicArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ForumTopic. +func (s ForumTopicArray) SortStable(less func(a, b ForumTopic) bool) ForumTopicArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ForumTopic. +func (s ForumTopicArray) Retain(keep func(x ForumTopic) bool) ForumTopicArray { + 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 ForumTopicArray) First() (v ForumTopic, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ForumTopicArray) Last() (v ForumTopic, 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 *ForumTopicArray) PopFirst() (v ForumTopic, 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 ForumTopic + 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 *ForumTopicArray) Pop() (v ForumTopic, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + +// SortByID sorts slice of ForumTopic by ID. +func (s ForumTopicArray) SortByID() ForumTopicArray { + return s.Sort(func(a, b ForumTopic) bool { + return a.GetID() < b.GetID() + }) +} + +// SortStableByID sorts slice of ForumTopic by ID. +func (s ForumTopicArray) SortStableByID() ForumTopicArray { + return s.SortStable(func(a, b ForumTopic) bool { + return a.GetID() < b.GetID() + }) +} + +// SortByDate sorts slice of ForumTopic by Date. +func (s ForumTopicArray) SortByDate() ForumTopicArray { + return s.Sort(func(a, b ForumTopic) bool { + return a.GetDate() < b.GetDate() + }) +} + +// SortStableByDate sorts slice of ForumTopic by Date. +func (s ForumTopicArray) SortStableByDate() ForumTopicArray { + return s.SortStable(func(a, b ForumTopic) bool { + return a.GetDate() < b.GetDate() + }) +} + +// FillMap fills constructors to given map. +func (s ForumTopicArray) FillMap(to map[int]ForumTopic) { + for _, value := range s { + to[value.GetID()] = value + } +} + +// ToMap collects constructors to map. +func (s ForumTopicArray) ToMap() map[int]ForumTopic { + r := make(map[int]ForumTopic, len(s)) + s.FillMap(r) + return r +} diff --git a/tg/tl_handlers_gen.go b/tg/tl_handlers_gen.go index 1ef57e0e5c..9722162cb3 100644 --- a/tg/tl_handlers_gen.go +++ b/tg/tl_handlers_gen.go @@ -1175,3 +1175,13 @@ func (u UpdateDispatcher) OnMessageExtendedMedia(handler MessageExtendedMediaHan return handler(ctx, e, update.(*UpdateMessageExtendedMedia)) } } + +// ChannelPinnedTopicHandler is a ChannelPinnedTopic event handler. +type ChannelPinnedTopicHandler func(ctx context.Context, e Entities, update *UpdateChannelPinnedTopic) error + +// OnChannelPinnedTopic sets ChannelPinnedTopic handler. +func (u UpdateDispatcher) OnChannelPinnedTopic(handler ChannelPinnedTopicHandler) { + u.handlers[UpdateChannelPinnedTopicTypeID] = func(ctx context.Context, e Entities, update UpdateClass) error { + return handler(ctx, e, update.(*UpdateChannelPinnedTopic)) + } +} diff --git a/tg/tl_input_notify_peer_gen.go b/tg/tl_input_notify_peer_gen.go index a0824439fb..2c94fbf887 100644 --- a/tg/tl_input_notify_peer_gen.go +++ b/tg/tl_input_notify_peer_gen.go @@ -480,6 +480,172 @@ func (i *InputNotifyBroadcasts) DecodeBare(b *bin.Buffer) error { return nil } +// InputNotifyForumTopic represents TL type `inputNotifyForumTopic#5c467992`. +// +// See https://core.telegram.org/constructor/inputNotifyForumTopic for reference. +type InputNotifyForumTopic struct { + // Peer field of InputNotifyForumTopic. + Peer InputPeerClass + // TopMsgID field of InputNotifyForumTopic. + TopMsgID int +} + +// InputNotifyForumTopicTypeID is TL type id of InputNotifyForumTopic. +const InputNotifyForumTopicTypeID = 0x5c467992 + +// construct implements constructor of InputNotifyPeerClass. +func (i InputNotifyForumTopic) construct() InputNotifyPeerClass { return &i } + +// Ensuring interfaces in compile-time for InputNotifyForumTopic. +var ( + _ bin.Encoder = &InputNotifyForumTopic{} + _ bin.Decoder = &InputNotifyForumTopic{} + _ bin.BareEncoder = &InputNotifyForumTopic{} + _ bin.BareDecoder = &InputNotifyForumTopic{} + + _ InputNotifyPeerClass = &InputNotifyForumTopic{} +) + +func (i *InputNotifyForumTopic) Zero() bool { + if i == nil { + return true + } + if !(i.Peer == nil) { + return false + } + if !(i.TopMsgID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InputNotifyForumTopic) String() string { + if i == nil { + return "InputNotifyForumTopic(nil)" + } + type Alias InputNotifyForumTopic + return fmt.Sprintf("InputNotifyForumTopic%+v", Alias(*i)) +} + +// FillFrom fills InputNotifyForumTopic from given interface. +func (i *InputNotifyForumTopic) FillFrom(from interface { + GetPeer() (value InputPeerClass) + GetTopMsgID() (value int) +}) { + i.Peer = from.GetPeer() + i.TopMsgID = from.GetTopMsgID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InputNotifyForumTopic) TypeID() uint32 { + return InputNotifyForumTopicTypeID +} + +// TypeName returns name of type in TL schema. +func (*InputNotifyForumTopic) TypeName() string { + return "inputNotifyForumTopic" +} + +// TypeInfo returns info about TL type. +func (i *InputNotifyForumTopic) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inputNotifyForumTopic", + ID: InputNotifyForumTopicTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "TopMsgID", + SchemaName: "top_msg_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (i *InputNotifyForumTopic) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputNotifyForumTopic#5c467992 as nil") + } + b.PutID(InputNotifyForumTopicTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InputNotifyForumTopic) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputNotifyForumTopic#5c467992 as nil") + } + if i.Peer == nil { + return fmt.Errorf("unable to encode inputNotifyForumTopic#5c467992: field peer is nil") + } + if err := i.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputNotifyForumTopic#5c467992: field peer: %w", err) + } + b.PutInt(i.TopMsgID) + return nil +} + +// Decode implements bin.Decoder. +func (i *InputNotifyForumTopic) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputNotifyForumTopic#5c467992 to nil") + } + if err := b.ConsumeID(InputNotifyForumTopicTypeID); err != nil { + return fmt.Errorf("unable to decode inputNotifyForumTopic#5c467992: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InputNotifyForumTopic) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputNotifyForumTopic#5c467992 to nil") + } + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode inputNotifyForumTopic#5c467992: field peer: %w", err) + } + i.Peer = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode inputNotifyForumTopic#5c467992: field top_msg_id: %w", err) + } + i.TopMsgID = value + } + return nil +} + +// GetPeer returns value of Peer field. +func (i *InputNotifyForumTopic) GetPeer() (value InputPeerClass) { + if i == nil { + return + } + return i.Peer +} + +// GetTopMsgID returns value of TopMsgID field. +func (i *InputNotifyForumTopic) GetTopMsgID() (value int) { + if i == nil { + return + } + return i.TopMsgID +} + // InputNotifyPeerClassName is schema name of InputNotifyPeerClass. const InputNotifyPeerClassName = "InputNotifyPeer" @@ -498,6 +664,7 @@ const InputNotifyPeerClassName = "InputNotifyPeer" // case *tg.InputNotifyUsers: // inputNotifyUsers#193b4417 // case *tg.InputNotifyChats: // inputNotifyChats#4a95e84e // case *tg.InputNotifyBroadcasts: // inputNotifyBroadcasts#b1db7c7e +// case *tg.InputNotifyForumTopic: // inputNotifyForumTopic#5c467992 // default: panic(v) // } type InputNotifyPeerClass interface { @@ -554,6 +721,13 @@ func DecodeInputNotifyPeer(buf *bin.Buffer) (InputNotifyPeerClass, error) { return nil, fmt.Errorf("unable to decode InputNotifyPeerClass: %w", err) } return &v, nil + case InputNotifyForumTopicTypeID: + // Decoding inputNotifyForumTopic#5c467992. + v := InputNotifyForumTopic{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InputNotifyPeerClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode InputNotifyPeerClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_input_notify_peer_slices_gen.go b/tg/tl_input_notify_peer_slices_gen.go index ed38df0436..4736e424fd 100644 --- a/tg/tl_input_notify_peer_slices_gen.go +++ b/tg/tl_input_notify_peer_slices_gen.go @@ -129,6 +129,19 @@ func (s InputNotifyPeerClassArray) AsInputNotifyPeer() (to InputNotifyPeerArray) return to } +// AsInputNotifyForumTopic returns copy with only InputNotifyForumTopic constructors. +func (s InputNotifyPeerClassArray) AsInputNotifyForumTopic() (to InputNotifyForumTopicArray) { + for _, elem := range s { + value, ok := elem.(*InputNotifyForumTopic) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // InputNotifyPeerArray is adapter for slice of InputNotifyPeer. type InputNotifyPeerArray []InputNotifyPeer @@ -210,3 +223,85 @@ func (s *InputNotifyPeerArray) Pop() (v InputNotifyPeer, ok bool) { return v, true } + +// InputNotifyForumTopicArray is adapter for slice of InputNotifyForumTopic. +type InputNotifyForumTopicArray []InputNotifyForumTopic + +// Sort sorts slice of InputNotifyForumTopic. +func (s InputNotifyForumTopicArray) Sort(less func(a, b InputNotifyForumTopic) bool) InputNotifyForumTopicArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of InputNotifyForumTopic. +func (s InputNotifyForumTopicArray) SortStable(less func(a, b InputNotifyForumTopic) bool) InputNotifyForumTopicArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of InputNotifyForumTopic. +func (s InputNotifyForumTopicArray) Retain(keep func(x InputNotifyForumTopic) bool) InputNotifyForumTopicArray { + 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 InputNotifyForumTopicArray) First() (v InputNotifyForumTopic, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s InputNotifyForumTopicArray) Last() (v InputNotifyForumTopic, 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 *InputNotifyForumTopicArray) PopFirst() (v InputNotifyForumTopic, 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 InputNotifyForumTopic + 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 *InputNotifyForumTopicArray) Pop() (v InputNotifyForumTopic, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_input_sticker_set_gen.go b/tg/tl_input_sticker_set_gen.go index c4f1bfa50c..e78381c630 100644 --- a/tg/tl_input_sticker_set_gen.go +++ b/tg/tl_input_sticker_set_gen.go @@ -1083,6 +1083,107 @@ func (i *InputStickerSetEmojiDefaultStatuses) DecodeBare(b *bin.Buffer) error { return nil } +// InputStickerSetEmojiDefaultTopicIcons represents TL type `inputStickerSetEmojiDefaultTopicIcons#44c1f8e9`. +// +// See https://core.telegram.org/constructor/inputStickerSetEmojiDefaultTopicIcons for reference. +type InputStickerSetEmojiDefaultTopicIcons struct { +} + +// InputStickerSetEmojiDefaultTopicIconsTypeID is TL type id of InputStickerSetEmojiDefaultTopicIcons. +const InputStickerSetEmojiDefaultTopicIconsTypeID = 0x44c1f8e9 + +// construct implements constructor of InputStickerSetClass. +func (i InputStickerSetEmojiDefaultTopicIcons) construct() InputStickerSetClass { return &i } + +// Ensuring interfaces in compile-time for InputStickerSetEmojiDefaultTopicIcons. +var ( + _ bin.Encoder = &InputStickerSetEmojiDefaultTopicIcons{} + _ bin.Decoder = &InputStickerSetEmojiDefaultTopicIcons{} + _ bin.BareEncoder = &InputStickerSetEmojiDefaultTopicIcons{} + _ bin.BareDecoder = &InputStickerSetEmojiDefaultTopicIcons{} + + _ InputStickerSetClass = &InputStickerSetEmojiDefaultTopicIcons{} +) + +func (i *InputStickerSetEmojiDefaultTopicIcons) Zero() bool { + if i == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (i *InputStickerSetEmojiDefaultTopicIcons) String() string { + if i == nil { + return "InputStickerSetEmojiDefaultTopicIcons(nil)" + } + type Alias InputStickerSetEmojiDefaultTopicIcons + return fmt.Sprintf("InputStickerSetEmojiDefaultTopicIcons%+v", Alias(*i)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InputStickerSetEmojiDefaultTopicIcons) TypeID() uint32 { + return InputStickerSetEmojiDefaultTopicIconsTypeID +} + +// TypeName returns name of type in TL schema. +func (*InputStickerSetEmojiDefaultTopicIcons) TypeName() string { + return "inputStickerSetEmojiDefaultTopicIcons" +} + +// TypeInfo returns info about TL type. +func (i *InputStickerSetEmojiDefaultTopicIcons) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inputStickerSetEmojiDefaultTopicIcons", + ID: InputStickerSetEmojiDefaultTopicIconsTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (i *InputStickerSetEmojiDefaultTopicIcons) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputStickerSetEmojiDefaultTopicIcons#44c1f8e9 as nil") + } + b.PutID(InputStickerSetEmojiDefaultTopicIconsTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InputStickerSetEmojiDefaultTopicIcons) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputStickerSetEmojiDefaultTopicIcons#44c1f8e9 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (i *InputStickerSetEmojiDefaultTopicIcons) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputStickerSetEmojiDefaultTopicIcons#44c1f8e9 to nil") + } + if err := b.ConsumeID(InputStickerSetEmojiDefaultTopicIconsTypeID); err != nil { + return fmt.Errorf("unable to decode inputStickerSetEmojiDefaultTopicIcons#44c1f8e9: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InputStickerSetEmojiDefaultTopicIcons) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputStickerSetEmojiDefaultTopicIcons#44c1f8e9 to nil") + } + return nil +} + // InputStickerSetClassName is schema name of InputStickerSetClass. const InputStickerSetClassName = "InputStickerSet" @@ -1106,6 +1207,7 @@ const InputStickerSetClassName = "InputStickerSet" // case *tg.InputStickerSetPremiumGifts: // inputStickerSetPremiumGifts#c88b3b02 // case *tg.InputStickerSetEmojiGenericAnimations: // inputStickerSetEmojiGenericAnimations#4c4d4ce // case *tg.InputStickerSetEmojiDefaultStatuses: // inputStickerSetEmojiDefaultStatuses#29d0f5ee +// case *tg.InputStickerSetEmojiDefaultTopicIcons: // inputStickerSetEmojiDefaultTopicIcons#44c1f8e9 // default: panic(v) // } type InputStickerSetClass interface { @@ -1197,6 +1299,13 @@ func DecodeInputStickerSet(buf *bin.Buffer) (InputStickerSetClass, error) { return nil, fmt.Errorf("unable to decode InputStickerSetClass: %w", err) } return &v, nil + case InputStickerSetEmojiDefaultTopicIconsTypeID: + // Decoding inputStickerSetEmojiDefaultTopicIcons#44c1f8e9. + v := InputStickerSetEmojiDefaultTopicIcons{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InputStickerSetClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode InputStickerSetClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_message_action_gen.go b/tg/tl_message_action_gen.go index 2da7f1b0a4..061bb36aa8 100644 --- a/tg/tl_message_action_gen.go +++ b/tg/tl_message_action_gen.go @@ -5371,6 +5371,502 @@ func (m *MessageActionGiftPremium) GetMonths() (value int) { return m.Months } +// MessageActionTopicCreate represents TL type `messageActionTopicCreate#d999256`. +// +// See https://core.telegram.org/constructor/messageActionTopicCreate for reference. +type MessageActionTopicCreate struct { + // Flags field of MessageActionTopicCreate. + Flags bin.Fields + // Title field of MessageActionTopicCreate. + Title string + // IconColor field of MessageActionTopicCreate. + IconColor int + // IconEmojiID field of MessageActionTopicCreate. + // + // Use SetIconEmojiID and GetIconEmojiID helpers. + IconEmojiID int64 +} + +// MessageActionTopicCreateTypeID is TL type id of MessageActionTopicCreate. +const MessageActionTopicCreateTypeID = 0xd999256 + +// construct implements constructor of MessageActionClass. +func (m MessageActionTopicCreate) construct() MessageActionClass { return &m } + +// Ensuring interfaces in compile-time for MessageActionTopicCreate. +var ( + _ bin.Encoder = &MessageActionTopicCreate{} + _ bin.Decoder = &MessageActionTopicCreate{} + _ bin.BareEncoder = &MessageActionTopicCreate{} + _ bin.BareDecoder = &MessageActionTopicCreate{} + + _ MessageActionClass = &MessageActionTopicCreate{} +) + +func (m *MessageActionTopicCreate) Zero() bool { + if m == nil { + return true + } + if !(m.Flags.Zero()) { + return false + } + if !(m.Title == "") { + return false + } + if !(m.IconColor == 0) { + return false + } + if !(m.IconEmojiID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (m *MessageActionTopicCreate) String() string { + if m == nil { + return "MessageActionTopicCreate(nil)" + } + type Alias MessageActionTopicCreate + return fmt.Sprintf("MessageActionTopicCreate%+v", Alias(*m)) +} + +// FillFrom fills MessageActionTopicCreate from given interface. +func (m *MessageActionTopicCreate) FillFrom(from interface { + GetTitle() (value string) + GetIconColor() (value int) + GetIconEmojiID() (value int64, ok bool) +}) { + m.Title = from.GetTitle() + m.IconColor = from.GetIconColor() + if val, ok := from.GetIconEmojiID(); ok { + m.IconEmojiID = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessageActionTopicCreate) TypeID() uint32 { + return MessageActionTopicCreateTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessageActionTopicCreate) TypeName() string { + return "messageActionTopicCreate" +} + +// TypeInfo returns info about TL type. +func (m *MessageActionTopicCreate) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messageActionTopicCreate", + ID: MessageActionTopicCreateTypeID, + } + if m == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Title", + SchemaName: "title", + }, + { + Name: "IconColor", + SchemaName: "icon_color", + }, + { + Name: "IconEmojiID", + SchemaName: "icon_emoji_id", + Null: !m.Flags.Has(0), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (m *MessageActionTopicCreate) SetFlags() { + if !(m.IconEmojiID == 0) { + m.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (m *MessageActionTopicCreate) Encode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionTopicCreate#d999256 as nil") + } + b.PutID(MessageActionTopicCreateTypeID) + return m.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (m *MessageActionTopicCreate) EncodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionTopicCreate#d999256 as nil") + } + m.SetFlags() + if err := m.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messageActionTopicCreate#d999256: field flags: %w", err) + } + b.PutString(m.Title) + b.PutInt(m.IconColor) + if m.Flags.Has(0) { + b.PutLong(m.IconEmojiID) + } + return nil +} + +// Decode implements bin.Decoder. +func (m *MessageActionTopicCreate) Decode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionTopicCreate#d999256 to nil") + } + if err := b.ConsumeID(MessageActionTopicCreateTypeID); err != nil { + return fmt.Errorf("unable to decode messageActionTopicCreate#d999256: %w", err) + } + return m.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (m *MessageActionTopicCreate) DecodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionTopicCreate#d999256 to nil") + } + { + if err := m.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messageActionTopicCreate#d999256: field flags: %w", err) + } + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messageActionTopicCreate#d999256: field title: %w", err) + } + m.Title = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messageActionTopicCreate#d999256: field icon_color: %w", err) + } + m.IconColor = value + } + if m.Flags.Has(0) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messageActionTopicCreate#d999256: field icon_emoji_id: %w", err) + } + m.IconEmojiID = value + } + return nil +} + +// GetTitle returns value of Title field. +func (m *MessageActionTopicCreate) GetTitle() (value string) { + if m == nil { + return + } + return m.Title +} + +// GetIconColor returns value of IconColor field. +func (m *MessageActionTopicCreate) GetIconColor() (value int) { + if m == nil { + return + } + return m.IconColor +} + +// SetIconEmojiID sets value of IconEmojiID conditional field. +func (m *MessageActionTopicCreate) SetIconEmojiID(value int64) { + m.Flags.Set(0) + m.IconEmojiID = value +} + +// GetIconEmojiID returns value of IconEmojiID conditional field and +// boolean which is true if field was set. +func (m *MessageActionTopicCreate) GetIconEmojiID() (value int64, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(0) { + return value, false + } + return m.IconEmojiID, true +} + +// MessageActionTopicEdit represents TL type `messageActionTopicEdit#b18a431c`. +// +// See https://core.telegram.org/constructor/messageActionTopicEdit for reference. +type MessageActionTopicEdit struct { + // Flags field of MessageActionTopicEdit. + Flags bin.Fields + // Title field of MessageActionTopicEdit. + // + // Use SetTitle and GetTitle helpers. + Title string + // IconEmojiID field of MessageActionTopicEdit. + // + // Use SetIconEmojiID and GetIconEmojiID helpers. + IconEmojiID int64 + // Closed field of MessageActionTopicEdit. + // + // Use SetClosed and GetClosed helpers. + Closed bool +} + +// MessageActionTopicEditTypeID is TL type id of MessageActionTopicEdit. +const MessageActionTopicEditTypeID = 0xb18a431c + +// construct implements constructor of MessageActionClass. +func (m MessageActionTopicEdit) construct() MessageActionClass { return &m } + +// Ensuring interfaces in compile-time for MessageActionTopicEdit. +var ( + _ bin.Encoder = &MessageActionTopicEdit{} + _ bin.Decoder = &MessageActionTopicEdit{} + _ bin.BareEncoder = &MessageActionTopicEdit{} + _ bin.BareDecoder = &MessageActionTopicEdit{} + + _ MessageActionClass = &MessageActionTopicEdit{} +) + +func (m *MessageActionTopicEdit) Zero() bool { + if m == nil { + return true + } + if !(m.Flags.Zero()) { + return false + } + if !(m.Title == "") { + return false + } + if !(m.IconEmojiID == 0) { + return false + } + if !(m.Closed == false) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (m *MessageActionTopicEdit) String() string { + if m == nil { + return "MessageActionTopicEdit(nil)" + } + type Alias MessageActionTopicEdit + return fmt.Sprintf("MessageActionTopicEdit%+v", Alias(*m)) +} + +// FillFrom fills MessageActionTopicEdit from given interface. +func (m *MessageActionTopicEdit) FillFrom(from interface { + GetTitle() (value string, ok bool) + GetIconEmojiID() (value int64, ok bool) + GetClosed() (value bool, ok bool) +}) { + if val, ok := from.GetTitle(); ok { + m.Title = val + } + + if val, ok := from.GetIconEmojiID(); ok { + m.IconEmojiID = val + } + + if val, ok := from.GetClosed(); ok { + m.Closed = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessageActionTopicEdit) TypeID() uint32 { + return MessageActionTopicEditTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessageActionTopicEdit) TypeName() string { + return "messageActionTopicEdit" +} + +// TypeInfo returns info about TL type. +func (m *MessageActionTopicEdit) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messageActionTopicEdit", + ID: MessageActionTopicEditTypeID, + } + if m == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Title", + SchemaName: "title", + Null: !m.Flags.Has(0), + }, + { + Name: "IconEmojiID", + SchemaName: "icon_emoji_id", + Null: !m.Flags.Has(1), + }, + { + Name: "Closed", + SchemaName: "closed", + Null: !m.Flags.Has(2), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (m *MessageActionTopicEdit) SetFlags() { + if !(m.Title == "") { + m.Flags.Set(0) + } + if !(m.IconEmojiID == 0) { + m.Flags.Set(1) + } + if !(m.Closed == false) { + m.Flags.Set(2) + } +} + +// Encode implements bin.Encoder. +func (m *MessageActionTopicEdit) Encode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionTopicEdit#b18a431c as nil") + } + b.PutID(MessageActionTopicEditTypeID) + return m.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (m *MessageActionTopicEdit) EncodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionTopicEdit#b18a431c as nil") + } + m.SetFlags() + if err := m.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messageActionTopicEdit#b18a431c: field flags: %w", err) + } + if m.Flags.Has(0) { + b.PutString(m.Title) + } + if m.Flags.Has(1) { + b.PutLong(m.IconEmojiID) + } + if m.Flags.Has(2) { + b.PutBool(m.Closed) + } + return nil +} + +// Decode implements bin.Decoder. +func (m *MessageActionTopicEdit) Decode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionTopicEdit#b18a431c to nil") + } + if err := b.ConsumeID(MessageActionTopicEditTypeID); err != nil { + return fmt.Errorf("unable to decode messageActionTopicEdit#b18a431c: %w", err) + } + return m.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (m *MessageActionTopicEdit) DecodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionTopicEdit#b18a431c to nil") + } + { + if err := m.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messageActionTopicEdit#b18a431c: field flags: %w", err) + } + } + if m.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messageActionTopicEdit#b18a431c: field title: %w", err) + } + m.Title = value + } + if m.Flags.Has(1) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messageActionTopicEdit#b18a431c: field icon_emoji_id: %w", err) + } + m.IconEmojiID = value + } + if m.Flags.Has(2) { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode messageActionTopicEdit#b18a431c: field closed: %w", err) + } + m.Closed = value + } + return nil +} + +// SetTitle sets value of Title conditional field. +func (m *MessageActionTopicEdit) SetTitle(value string) { + m.Flags.Set(0) + m.Title = value +} + +// GetTitle returns value of Title conditional field and +// boolean which is true if field was set. +func (m *MessageActionTopicEdit) GetTitle() (value string, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(0) { + return value, false + } + return m.Title, true +} + +// SetIconEmojiID sets value of IconEmojiID conditional field. +func (m *MessageActionTopicEdit) SetIconEmojiID(value int64) { + m.Flags.Set(1) + m.IconEmojiID = value +} + +// GetIconEmojiID returns value of IconEmojiID conditional field and +// boolean which is true if field was set. +func (m *MessageActionTopicEdit) GetIconEmojiID() (value int64, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(1) { + return value, false + } + return m.IconEmojiID, true +} + +// SetClosed sets value of Closed conditional field. +func (m *MessageActionTopicEdit) SetClosed(value bool) { + m.Flags.Set(2) + m.Closed = value +} + +// GetClosed returns value of Closed conditional field and +// boolean which is true if field was set. +func (m *MessageActionTopicEdit) GetClosed() (value bool, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(2) { + return value, false + } + return m.Closed, true +} + // MessageActionClassName is schema name of MessageActionClass. const MessageActionClassName = "MessageAction" @@ -5418,6 +5914,8 @@ const MessageActionClassName = "MessageAction" // case *tg.MessageActionWebViewDataSentMe: // messageActionWebViewDataSentMe#47dd8079 // case *tg.MessageActionWebViewDataSent: // messageActionWebViewDataSent#b4c38cb5 // case *tg.MessageActionGiftPremium: // messageActionGiftPremium#aba0f5c6 +// case *tg.MessageActionTopicCreate: // messageActionTopicCreate#d999256 +// case *tg.MessageActionTopicEdit: // messageActionTopicEdit#b18a431c // default: panic(v) // } type MessageActionClass interface { @@ -5677,6 +6175,20 @@ func DecodeMessageAction(buf *bin.Buffer) (MessageActionClass, error) { return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err) } return &v, nil + case MessageActionTopicCreateTypeID: + // Decoding messageActionTopicCreate#d999256. + v := MessageActionTopicCreate{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err) + } + return &v, nil + case MessageActionTopicEditTypeID: + // Decoding messageActionTopicEdit#b18a431c. + v := MessageActionTopicEdit{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode MessageActionClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_message_action_slices_gen.go b/tg/tl_message_action_slices_gen.go index 469a69a45d..3abd3fb328 100644 --- a/tg/tl_message_action_slices_gen.go +++ b/tg/tl_message_action_slices_gen.go @@ -454,6 +454,32 @@ func (s MessageActionClassArray) AsMessageActionGiftPremium() (to MessageActionG return to } +// AsMessageActionTopicCreate returns copy with only MessageActionTopicCreate constructors. +func (s MessageActionClassArray) AsMessageActionTopicCreate() (to MessageActionTopicCreateArray) { + for _, elem := range s { + value, ok := elem.(*MessageActionTopicCreate) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsMessageActionTopicEdit returns copy with only MessageActionTopicEdit constructors. +func (s MessageActionClassArray) AsMessageActionTopicEdit() (to MessageActionTopicEditArray) { + for _, elem := range s { + value, ok := elem.(*MessageActionTopicEdit) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // MessageActionChatCreateArray is adapter for slice of MessageActionChatCreate. type MessageActionChatCreateArray []MessageActionChatCreate @@ -2585,3 +2611,167 @@ func (s *MessageActionGiftPremiumArray) Pop() (v MessageActionGiftPremium, ok bo return v, true } + +// MessageActionTopicCreateArray is adapter for slice of MessageActionTopicCreate. +type MessageActionTopicCreateArray []MessageActionTopicCreate + +// Sort sorts slice of MessageActionTopicCreate. +func (s MessageActionTopicCreateArray) Sort(less func(a, b MessageActionTopicCreate) bool) MessageActionTopicCreateArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessageActionTopicCreate. +func (s MessageActionTopicCreateArray) SortStable(less func(a, b MessageActionTopicCreate) bool) MessageActionTopicCreateArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessageActionTopicCreate. +func (s MessageActionTopicCreateArray) Retain(keep func(x MessageActionTopicCreate) bool) MessageActionTopicCreateArray { + 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 MessageActionTopicCreateArray) First() (v MessageActionTopicCreate, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessageActionTopicCreateArray) Last() (v MessageActionTopicCreate, 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 *MessageActionTopicCreateArray) PopFirst() (v MessageActionTopicCreate, 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 MessageActionTopicCreate + 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 *MessageActionTopicCreateArray) Pop() (v MessageActionTopicCreate, 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 +} + +// MessageActionTopicEditArray is adapter for slice of MessageActionTopicEdit. +type MessageActionTopicEditArray []MessageActionTopicEdit + +// Sort sorts slice of MessageActionTopicEdit. +func (s MessageActionTopicEditArray) Sort(less func(a, b MessageActionTopicEdit) bool) MessageActionTopicEditArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessageActionTopicEdit. +func (s MessageActionTopicEditArray) SortStable(less func(a, b MessageActionTopicEdit) bool) MessageActionTopicEditArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessageActionTopicEdit. +func (s MessageActionTopicEditArray) Retain(keep func(x MessageActionTopicEdit) bool) MessageActionTopicEditArray { + 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 MessageActionTopicEditArray) First() (v MessageActionTopicEdit, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessageActionTopicEditArray) Last() (v MessageActionTopicEdit, 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 *MessageActionTopicEditArray) PopFirst() (v MessageActionTopicEdit, 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 MessageActionTopicEdit + 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 *MessageActionTopicEditArray) Pop() (v MessageActionTopicEdit, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_message_reply_header_gen.go b/tg/tl_message_reply_header_gen.go index 86f24e802d..7b2eb90e25 100644 --- a/tg/tl_message_reply_header_gen.go +++ b/tg/tl_message_reply_header_gen.go @@ -46,6 +46,8 @@ type MessageReplyHeader struct { Flags bin.Fields // Whether this message replies to a scheduled message ReplyToScheduled bool + // ForumTopic field of MessageReplyHeader. + ForumTopic bool // ID of message to which this message is replying ReplyToMsgID int // For replies sent in channel discussion threads¹ of which the current user is not a @@ -86,6 +88,9 @@ func (m *MessageReplyHeader) Zero() bool { if !(m.ReplyToScheduled == false) { return false } + if !(m.ForumTopic == false) { + return false + } if !(m.ReplyToMsgID == 0) { return false } @@ -111,11 +116,13 @@ func (m *MessageReplyHeader) String() string { // FillFrom fills MessageReplyHeader from given interface. func (m *MessageReplyHeader) FillFrom(from interface { GetReplyToScheduled() (value bool) + GetForumTopic() (value bool) GetReplyToMsgID() (value int) GetReplyToPeerID() (value PeerClass, ok bool) GetReplyToTopID() (value int, ok bool) }) { m.ReplyToScheduled = from.GetReplyToScheduled() + m.ForumTopic = from.GetForumTopic() m.ReplyToMsgID = from.GetReplyToMsgID() if val, ok := from.GetReplyToPeerID(); ok { m.ReplyToPeerID = val @@ -155,6 +162,11 @@ func (m *MessageReplyHeader) TypeInfo() tdp.Type { SchemaName: "reply_to_scheduled", Null: !m.Flags.Has(2), }, + { + Name: "ForumTopic", + SchemaName: "forum_topic", + Null: !m.Flags.Has(3), + }, { Name: "ReplyToMsgID", SchemaName: "reply_to_msg_id", @@ -178,6 +190,9 @@ func (m *MessageReplyHeader) SetFlags() { if !(m.ReplyToScheduled == false) { m.Flags.Set(2) } + if !(m.ForumTopic == false) { + m.Flags.Set(3) + } if !(m.ReplyToPeerID == nil) { m.Flags.Set(0) } @@ -241,6 +256,7 @@ func (m *MessageReplyHeader) DecodeBare(b *bin.Buffer) error { } } m.ReplyToScheduled = m.Flags.Has(2) + m.ForumTopic = m.Flags.Has(3) { value, err := b.Int() if err != nil { @@ -284,6 +300,25 @@ func (m *MessageReplyHeader) GetReplyToScheduled() (value bool) { return m.Flags.Has(2) } +// SetForumTopic sets value of ForumTopic conditional field. +func (m *MessageReplyHeader) SetForumTopic(value bool) { + if value { + m.Flags.Set(3) + m.ForumTopic = true + } else { + m.Flags.Unset(3) + m.ForumTopic = false + } +} + +// GetForumTopic returns value of ForumTopic conditional field. +func (m *MessageReplyHeader) GetForumTopic() (value bool) { + if m == nil { + return + } + return m.Flags.Has(3) +} + // GetReplyToMsgID returns value of ReplyToMsgID field. func (m *MessageReplyHeader) GetReplyToMsgID() (value int) { if m == nil { diff --git a/tg/tl_messages_forum_topics_gen.go b/tg/tl_messages_forum_topics_gen.go new file mode 100644 index 0000000000..84c2238366 --- /dev/null +++ b/tg/tl_messages_forum_topics_gen.go @@ -0,0 +1,441 @@ +// 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{} +) + +// MessagesForumTopics represents TL type `messages.forumTopics#367617d3`. +// +// See https://core.telegram.org/constructor/messages.forumTopics for reference. +type MessagesForumTopics struct { + // Flags field of MessagesForumTopics. + Flags bin.Fields + // OrderByCreateDate field of MessagesForumTopics. + OrderByCreateDate bool + // Count field of MessagesForumTopics. + Count int + // Topics field of MessagesForumTopics. + Topics []ForumTopicClass + // Messages field of MessagesForumTopics. + Messages []MessageClass + // Chats field of MessagesForumTopics. + Chats []ChatClass + // Users field of MessagesForumTopics. + Users []UserClass + // Pts field of MessagesForumTopics. + Pts int +} + +// MessagesForumTopicsTypeID is TL type id of MessagesForumTopics. +const MessagesForumTopicsTypeID = 0x367617d3 + +// Ensuring interfaces in compile-time for MessagesForumTopics. +var ( + _ bin.Encoder = &MessagesForumTopics{} + _ bin.Decoder = &MessagesForumTopics{} + _ bin.BareEncoder = &MessagesForumTopics{} + _ bin.BareDecoder = &MessagesForumTopics{} +) + +func (f *MessagesForumTopics) Zero() bool { + if f == nil { + return true + } + if !(f.Flags.Zero()) { + return false + } + if !(f.OrderByCreateDate == false) { + return false + } + if !(f.Count == 0) { + return false + } + if !(f.Topics == nil) { + return false + } + if !(f.Messages == nil) { + return false + } + if !(f.Chats == nil) { + return false + } + if !(f.Users == nil) { + return false + } + if !(f.Pts == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (f *MessagesForumTopics) String() string { + if f == nil { + return "MessagesForumTopics(nil)" + } + type Alias MessagesForumTopics + return fmt.Sprintf("MessagesForumTopics%+v", Alias(*f)) +} + +// FillFrom fills MessagesForumTopics from given interface. +func (f *MessagesForumTopics) FillFrom(from interface { + GetOrderByCreateDate() (value bool) + GetCount() (value int) + GetTopics() (value []ForumTopicClass) + GetMessages() (value []MessageClass) + GetChats() (value []ChatClass) + GetUsers() (value []UserClass) + GetPts() (value int) +}) { + f.OrderByCreateDate = from.GetOrderByCreateDate() + f.Count = from.GetCount() + f.Topics = from.GetTopics() + f.Messages = from.GetMessages() + f.Chats = from.GetChats() + f.Users = from.GetUsers() + f.Pts = from.GetPts() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesForumTopics) TypeID() uint32 { + return MessagesForumTopicsTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesForumTopics) TypeName() string { + return "messages.forumTopics" +} + +// TypeInfo returns info about TL type. +func (f *MessagesForumTopics) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.forumTopics", + ID: MessagesForumTopicsTypeID, + } + if f == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "OrderByCreateDate", + SchemaName: "order_by_create_date", + Null: !f.Flags.Has(0), + }, + { + Name: "Count", + SchemaName: "count", + }, + { + Name: "Topics", + SchemaName: "topics", + }, + { + Name: "Messages", + SchemaName: "messages", + }, + { + Name: "Chats", + SchemaName: "chats", + }, + { + Name: "Users", + SchemaName: "users", + }, + { + Name: "Pts", + SchemaName: "pts", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (f *MessagesForumTopics) SetFlags() { + if !(f.OrderByCreateDate == false) { + f.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (f *MessagesForumTopics) Encode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode messages.forumTopics#367617d3 as nil") + } + b.PutID(MessagesForumTopicsTypeID) + return f.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (f *MessagesForumTopics) EncodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode messages.forumTopics#367617d3 as nil") + } + f.SetFlags() + if err := f.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.forumTopics#367617d3: field flags: %w", err) + } + b.PutInt(f.Count) + b.PutVectorHeader(len(f.Topics)) + for idx, v := range f.Topics { + if v == nil { + return fmt.Errorf("unable to encode messages.forumTopics#367617d3: field topics element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.forumTopics#367617d3: field topics element with index %d: %w", idx, err) + } + } + b.PutVectorHeader(len(f.Messages)) + for idx, v := range f.Messages { + if v == nil { + return fmt.Errorf("unable to encode messages.forumTopics#367617d3: field messages element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.forumTopics#367617d3: field messages element with index %d: %w", idx, err) + } + } + b.PutVectorHeader(len(f.Chats)) + for idx, v := range f.Chats { + if v == nil { + return fmt.Errorf("unable to encode messages.forumTopics#367617d3: field chats element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.forumTopics#367617d3: field chats element with index %d: %w", idx, err) + } + } + b.PutVectorHeader(len(f.Users)) + for idx, v := range f.Users { + if v == nil { + return fmt.Errorf("unable to encode messages.forumTopics#367617d3: field users element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.forumTopics#367617d3: field users element with index %d: %w", idx, err) + } + } + b.PutInt(f.Pts) + return nil +} + +// Decode implements bin.Decoder. +func (f *MessagesForumTopics) Decode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode messages.forumTopics#367617d3 to nil") + } + if err := b.ConsumeID(MessagesForumTopicsTypeID); err != nil { + return fmt.Errorf("unable to decode messages.forumTopics#367617d3: %w", err) + } + return f.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (f *MessagesForumTopics) DecodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode messages.forumTopics#367617d3 to nil") + } + { + if err := f.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.forumTopics#367617d3: field flags: %w", err) + } + } + f.OrderByCreateDate = f.Flags.Has(0) + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.forumTopics#367617d3: field count: %w", err) + } + f.Count = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode messages.forumTopics#367617d3: field topics: %w", err) + } + + if headerLen > 0 { + f.Topics = make([]ForumTopicClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeForumTopic(b) + if err != nil { + return fmt.Errorf("unable to decode messages.forumTopics#367617d3: field topics: %w", err) + } + f.Topics = append(f.Topics, value) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode messages.forumTopics#367617d3: field messages: %w", err) + } + + if headerLen > 0 { + f.Messages = make([]MessageClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeMessage(b) + if err != nil { + return fmt.Errorf("unable to decode messages.forumTopics#367617d3: field messages: %w", err) + } + f.Messages = append(f.Messages, value) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode messages.forumTopics#367617d3: field chats: %w", err) + } + + if headerLen > 0 { + f.Chats = make([]ChatClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeChat(b) + if err != nil { + return fmt.Errorf("unable to decode messages.forumTopics#367617d3: field chats: %w", err) + } + f.Chats = append(f.Chats, value) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode messages.forumTopics#367617d3: field users: %w", err) + } + + if headerLen > 0 { + f.Users = make([]UserClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeUser(b) + if err != nil { + return fmt.Errorf("unable to decode messages.forumTopics#367617d3: field users: %w", err) + } + f.Users = append(f.Users, value) + } + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.forumTopics#367617d3: field pts: %w", err) + } + f.Pts = value + } + return nil +} + +// SetOrderByCreateDate sets value of OrderByCreateDate conditional field. +func (f *MessagesForumTopics) SetOrderByCreateDate(value bool) { + if value { + f.Flags.Set(0) + f.OrderByCreateDate = true + } else { + f.Flags.Unset(0) + f.OrderByCreateDate = false + } +} + +// GetOrderByCreateDate returns value of OrderByCreateDate conditional field. +func (f *MessagesForumTopics) GetOrderByCreateDate() (value bool) { + if f == nil { + return + } + return f.Flags.Has(0) +} + +// GetCount returns value of Count field. +func (f *MessagesForumTopics) GetCount() (value int) { + if f == nil { + return + } + return f.Count +} + +// GetTopics returns value of Topics field. +func (f *MessagesForumTopics) GetTopics() (value []ForumTopicClass) { + if f == nil { + return + } + return f.Topics +} + +// GetMessages returns value of Messages field. +func (f *MessagesForumTopics) GetMessages() (value []MessageClass) { + if f == nil { + return + } + return f.Messages +} + +// GetChats returns value of Chats field. +func (f *MessagesForumTopics) GetChats() (value []ChatClass) { + if f == nil { + return + } + return f.Chats +} + +// GetUsers returns value of Users field. +func (f *MessagesForumTopics) GetUsers() (value []UserClass) { + if f == nil { + return + } + return f.Users +} + +// GetPts returns value of Pts field. +func (f *MessagesForumTopics) GetPts() (value int) { + if f == nil { + return + } + return f.Pts +} + +// MapTopics returns field Topics wrapped in ForumTopicClassArray helper. +func (f *MessagesForumTopics) MapTopics() (value ForumTopicClassArray) { + return ForumTopicClassArray(f.Topics) +} + +// MapMessages returns field Messages wrapped in MessageClassArray helper. +func (f *MessagesForumTopics) MapMessages() (value MessageClassArray) { + return MessageClassArray(f.Messages) +} + +// MapChats returns field Chats wrapped in ChatClassArray helper. +func (f *MessagesForumTopics) MapChats() (value ChatClassArray) { + return ChatClassArray(f.Chats) +} + +// MapUsers returns field Users wrapped in UserClassArray helper. +func (f *MessagesForumTopics) MapUsers() (value UserClassArray) { + return UserClassArray(f.Users) +} diff --git a/tg/tl_messages_forum_topics_slices_gen.go b/tg/tl_messages_forum_topics_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_forum_topics_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_messages_forward_messages_gen.go b/tg/tl_messages_forward_messages_gen.go index 10f236291b..2e7bcab30d 100644 --- a/tg/tl_messages_forward_messages_gen.go +++ b/tg/tl_messages_forward_messages_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesForwardMessagesRequest represents TL type `messages.forwardMessages#cc30290b`. +// MessagesForwardMessagesRequest represents TL type `messages.forwardMessages#c661bbc4`. // Forwards messages by their IDs. // // See https://core.telegram.org/method/messages.forwardMessages for reference. @@ -66,6 +66,10 @@ type MessagesForwardMessagesRequest struct { RandomID []int64 // Destination peer ToPeer InputPeerClass + // TopMsgID field of MessagesForwardMessagesRequest. + // + // Use SetTopMsgID and GetTopMsgID helpers. + TopMsgID int // Scheduled message date for scheduled messages // // Use SetScheduleDate and GetScheduleDate helpers. @@ -77,7 +81,7 @@ type MessagesForwardMessagesRequest struct { } // MessagesForwardMessagesRequestTypeID is TL type id of MessagesForwardMessagesRequest. -const MessagesForwardMessagesRequestTypeID = 0xcc30290b +const MessagesForwardMessagesRequestTypeID = 0xc661bbc4 // Ensuring interfaces in compile-time for MessagesForwardMessagesRequest. var ( @@ -124,6 +128,9 @@ func (f *MessagesForwardMessagesRequest) Zero() bool { if !(f.ToPeer == nil) { return false } + if !(f.TopMsgID == 0) { + return false + } if !(f.ScheduleDate == 0) { return false } @@ -155,6 +162,7 @@ func (f *MessagesForwardMessagesRequest) FillFrom(from interface { GetID() (value []int) GetRandomID() (value []int64) GetToPeer() (value InputPeerClass) + GetTopMsgID() (value int, ok bool) GetScheduleDate() (value int, ok bool) GetSendAs() (value InputPeerClass, ok bool) }) { @@ -168,6 +176,10 @@ func (f *MessagesForwardMessagesRequest) FillFrom(from interface { f.ID = from.GetID() f.RandomID = from.GetRandomID() f.ToPeer = from.GetToPeer() + if val, ok := from.GetTopMsgID(); ok { + f.TopMsgID = val + } + if val, ok := from.GetScheduleDate(); ok { f.ScheduleDate = val } @@ -247,6 +259,11 @@ func (f *MessagesForwardMessagesRequest) TypeInfo() tdp.Type { Name: "ToPeer", SchemaName: "to_peer", }, + { + Name: "TopMsgID", + SchemaName: "top_msg_id", + Null: !f.Flags.Has(9), + }, { Name: "ScheduleDate", SchemaName: "schedule_date", @@ -281,6 +298,9 @@ func (f *MessagesForwardMessagesRequest) SetFlags() { if !(f.Noforwards == false) { f.Flags.Set(14) } + if !(f.TopMsgID == 0) { + f.Flags.Set(9) + } if !(f.ScheduleDate == 0) { f.Flags.Set(10) } @@ -292,7 +312,7 @@ func (f *MessagesForwardMessagesRequest) SetFlags() { // Encode implements bin.Encoder. func (f *MessagesForwardMessagesRequest) Encode(b *bin.Buffer) error { if f == nil { - return fmt.Errorf("can't encode messages.forwardMessages#cc30290b as nil") + return fmt.Errorf("can't encode messages.forwardMessages#c661bbc4 as nil") } b.PutID(MessagesForwardMessagesRequestTypeID) return f.EncodeBare(b) @@ -301,17 +321,17 @@ func (f *MessagesForwardMessagesRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (f *MessagesForwardMessagesRequest) EncodeBare(b *bin.Buffer) error { if f == nil { - return fmt.Errorf("can't encode messages.forwardMessages#cc30290b as nil") + return fmt.Errorf("can't encode messages.forwardMessages#c661bbc4 as nil") } f.SetFlags() if err := f.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.forwardMessages#cc30290b: field flags: %w", err) + return fmt.Errorf("unable to encode messages.forwardMessages#c661bbc4: field flags: %w", err) } if f.FromPeer == nil { - return fmt.Errorf("unable to encode messages.forwardMessages#cc30290b: field from_peer is nil") + return fmt.Errorf("unable to encode messages.forwardMessages#c661bbc4: field from_peer is nil") } if err := f.FromPeer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.forwardMessages#cc30290b: field from_peer: %w", err) + return fmt.Errorf("unable to encode messages.forwardMessages#c661bbc4: field from_peer: %w", err) } b.PutVectorHeader(len(f.ID)) for _, v := range f.ID { @@ -322,20 +342,23 @@ func (f *MessagesForwardMessagesRequest) EncodeBare(b *bin.Buffer) error { b.PutLong(v) } if f.ToPeer == nil { - return fmt.Errorf("unable to encode messages.forwardMessages#cc30290b: field to_peer is nil") + return fmt.Errorf("unable to encode messages.forwardMessages#c661bbc4: field to_peer is nil") } if err := f.ToPeer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.forwardMessages#cc30290b: field to_peer: %w", err) + return fmt.Errorf("unable to encode messages.forwardMessages#c661bbc4: field to_peer: %w", err) + } + if f.Flags.Has(9) { + b.PutInt(f.TopMsgID) } if f.Flags.Has(10) { b.PutInt(f.ScheduleDate) } if f.Flags.Has(13) { if f.SendAs == nil { - return fmt.Errorf("unable to encode messages.forwardMessages#cc30290b: field send_as is nil") + return fmt.Errorf("unable to encode messages.forwardMessages#c661bbc4: field send_as is nil") } if err := f.SendAs.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.forwardMessages#cc30290b: field send_as: %w", err) + return fmt.Errorf("unable to encode messages.forwardMessages#c661bbc4: field send_as: %w", err) } } return nil @@ -344,10 +367,10 @@ func (f *MessagesForwardMessagesRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (f *MessagesForwardMessagesRequest) Decode(b *bin.Buffer) error { if f == nil { - return fmt.Errorf("can't decode messages.forwardMessages#cc30290b to nil") + return fmt.Errorf("can't decode messages.forwardMessages#c661bbc4 to nil") } if err := b.ConsumeID(MessagesForwardMessagesRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.forwardMessages#cc30290b: %w", err) + return fmt.Errorf("unable to decode messages.forwardMessages#c661bbc4: %w", err) } return f.DecodeBare(b) } @@ -355,11 +378,11 @@ func (f *MessagesForwardMessagesRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (f *MessagesForwardMessagesRequest) DecodeBare(b *bin.Buffer) error { if f == nil { - return fmt.Errorf("can't decode messages.forwardMessages#cc30290b to nil") + return fmt.Errorf("can't decode messages.forwardMessages#c661bbc4 to nil") } { if err := f.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.forwardMessages#cc30290b: field flags: %w", err) + return fmt.Errorf("unable to decode messages.forwardMessages#c661bbc4: field flags: %w", err) } } f.Silent = f.Flags.Has(5) @@ -371,14 +394,14 @@ func (f *MessagesForwardMessagesRequest) DecodeBare(b *bin.Buffer) error { { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.forwardMessages#cc30290b: field from_peer: %w", err) + return fmt.Errorf("unable to decode messages.forwardMessages#c661bbc4: field from_peer: %w", err) } f.FromPeer = value } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode messages.forwardMessages#cc30290b: field id: %w", err) + return fmt.Errorf("unable to decode messages.forwardMessages#c661bbc4: field id: %w", err) } if headerLen > 0 { @@ -387,7 +410,7 @@ func (f *MessagesForwardMessagesRequest) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.forwardMessages#cc30290b: field id: %w", err) + return fmt.Errorf("unable to decode messages.forwardMessages#c661bbc4: field id: %w", err) } f.ID = append(f.ID, value) } @@ -395,7 +418,7 @@ func (f *MessagesForwardMessagesRequest) DecodeBare(b *bin.Buffer) error { { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode messages.forwardMessages#cc30290b: field random_id: %w", err) + return fmt.Errorf("unable to decode messages.forwardMessages#c661bbc4: field random_id: %w", err) } if headerLen > 0 { @@ -404,7 +427,7 @@ func (f *MessagesForwardMessagesRequest) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode messages.forwardMessages#cc30290b: field random_id: %w", err) + return fmt.Errorf("unable to decode messages.forwardMessages#c661bbc4: field random_id: %w", err) } f.RandomID = append(f.RandomID, value) } @@ -412,21 +435,28 @@ func (f *MessagesForwardMessagesRequest) DecodeBare(b *bin.Buffer) error { { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.forwardMessages#cc30290b: field to_peer: %w", err) + return fmt.Errorf("unable to decode messages.forwardMessages#c661bbc4: field to_peer: %w", err) } f.ToPeer = value } + if f.Flags.Has(9) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.forwardMessages#c661bbc4: field top_msg_id: %w", err) + } + f.TopMsgID = value + } if f.Flags.Has(10) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.forwardMessages#cc30290b: field schedule_date: %w", err) + return fmt.Errorf("unable to decode messages.forwardMessages#c661bbc4: field schedule_date: %w", err) } f.ScheduleDate = value } if f.Flags.Has(13) { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.forwardMessages#cc30290b: field send_as: %w", err) + return fmt.Errorf("unable to decode messages.forwardMessages#c661bbc4: field send_as: %w", err) } f.SendAs = value } @@ -579,6 +609,24 @@ func (f *MessagesForwardMessagesRequest) GetToPeer() (value InputPeerClass) { return f.ToPeer } +// SetTopMsgID sets value of TopMsgID conditional field. +func (f *MessagesForwardMessagesRequest) SetTopMsgID(value int) { + f.Flags.Set(9) + f.TopMsgID = value +} + +// GetTopMsgID returns value of TopMsgID conditional field and +// boolean which is true if field was set. +func (f *MessagesForwardMessagesRequest) GetTopMsgID() (value int, ok bool) { + if f == nil { + return + } + if !f.Flags.Has(9) { + return value, false + } + return f.TopMsgID, true +} + // SetScheduleDate sets value of ScheduleDate conditional field. func (f *MessagesForwardMessagesRequest) SetScheduleDate(value int) { f.Flags.Set(10) @@ -615,7 +663,7 @@ func (f *MessagesForwardMessagesRequest) GetSendAs() (value InputPeerClass, ok b return f.SendAs, true } -// MessagesForwardMessages invokes method messages.forwardMessages#cc30290b returning error if any. +// MessagesForwardMessages invokes method messages.forwardMessages#c661bbc4 returning error if any. // Forwards messages by their IDs. // // Possible errors: diff --git a/tg/tl_messages_get_search_counters_gen.go b/tg/tl_messages_get_search_counters_gen.go index 8b79700b26..a6c5029365 100644 --- a/tg/tl_messages_get_search_counters_gen.go +++ b/tg/tl_messages_get_search_counters_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesGetSearchCountersRequest represents TL type `messages.getSearchCounters#732eef00`. +// MessagesGetSearchCountersRequest represents TL type `messages.getSearchCounters#ae7cc1`. // Get the number of results that would be found by a messages.search¹ call with the // same parameters // @@ -40,14 +40,20 @@ var ( // // See https://core.telegram.org/method/messages.getSearchCounters for reference. type MessagesGetSearchCountersRequest struct { + // Flags field of MessagesGetSearchCountersRequest. + Flags bin.Fields // Peer where to search Peer InputPeerClass + // TopMsgID field of MessagesGetSearchCountersRequest. + // + // Use SetTopMsgID and GetTopMsgID helpers. + TopMsgID int // Search filters Filters []MessagesFilterClass } // MessagesGetSearchCountersRequestTypeID is TL type id of MessagesGetSearchCountersRequest. -const MessagesGetSearchCountersRequestTypeID = 0x732eef00 +const MessagesGetSearchCountersRequestTypeID = 0xae7cc1 // Ensuring interfaces in compile-time for MessagesGetSearchCountersRequest. var ( @@ -61,9 +67,15 @@ func (g *MessagesGetSearchCountersRequest) Zero() bool { if g == nil { return true } + if !(g.Flags.Zero()) { + return false + } if !(g.Peer == nil) { return false } + if !(g.TopMsgID == 0) { + return false + } if !(g.Filters == nil) { return false } @@ -83,9 +95,14 @@ func (g *MessagesGetSearchCountersRequest) String() string { // FillFrom fills MessagesGetSearchCountersRequest from given interface. func (g *MessagesGetSearchCountersRequest) FillFrom(from interface { GetPeer() (value InputPeerClass) + GetTopMsgID() (value int, ok bool) GetFilters() (value []MessagesFilterClass) }) { g.Peer = from.GetPeer() + if val, ok := from.GetTopMsgID(); ok { + g.TopMsgID = val + } + g.Filters = from.GetFilters() } @@ -116,6 +133,11 @@ func (g *MessagesGetSearchCountersRequest) TypeInfo() tdp.Type { Name: "Peer", SchemaName: "peer", }, + { + Name: "TopMsgID", + SchemaName: "top_msg_id", + Null: !g.Flags.Has(0), + }, { Name: "Filters", SchemaName: "filters", @@ -124,10 +146,17 @@ func (g *MessagesGetSearchCountersRequest) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (g *MessagesGetSearchCountersRequest) SetFlags() { + if !(g.TopMsgID == 0) { + g.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (g *MessagesGetSearchCountersRequest) Encode(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't encode messages.getSearchCounters#732eef00 as nil") + return fmt.Errorf("can't encode messages.getSearchCounters#ae7cc1 as nil") } b.PutID(MessagesGetSearchCountersRequestTypeID) return g.EncodeBare(b) @@ -136,21 +165,28 @@ func (g *MessagesGetSearchCountersRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (g *MessagesGetSearchCountersRequest) EncodeBare(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't encode messages.getSearchCounters#732eef00 as nil") + return fmt.Errorf("can't encode messages.getSearchCounters#ae7cc1 as nil") + } + g.SetFlags() + if err := g.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.getSearchCounters#ae7cc1: field flags: %w", err) } if g.Peer == nil { - return fmt.Errorf("unable to encode messages.getSearchCounters#732eef00: field peer is nil") + return fmt.Errorf("unable to encode messages.getSearchCounters#ae7cc1: field peer is nil") } if err := g.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.getSearchCounters#732eef00: field peer: %w", err) + return fmt.Errorf("unable to encode messages.getSearchCounters#ae7cc1: field peer: %w", err) + } + if g.Flags.Has(0) { + b.PutInt(g.TopMsgID) } b.PutVectorHeader(len(g.Filters)) for idx, v := range g.Filters { if v == nil { - return fmt.Errorf("unable to encode messages.getSearchCounters#732eef00: field filters element with index %d is nil", idx) + return fmt.Errorf("unable to encode messages.getSearchCounters#ae7cc1: field filters element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.getSearchCounters#732eef00: field filters element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode messages.getSearchCounters#ae7cc1: field filters element with index %d: %w", idx, err) } } return nil @@ -159,10 +195,10 @@ func (g *MessagesGetSearchCountersRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (g *MessagesGetSearchCountersRequest) Decode(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't decode messages.getSearchCounters#732eef00 to nil") + return fmt.Errorf("can't decode messages.getSearchCounters#ae7cc1 to nil") } if err := b.ConsumeID(MessagesGetSearchCountersRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.getSearchCounters#732eef00: %w", err) + return fmt.Errorf("unable to decode messages.getSearchCounters#ae7cc1: %w", err) } return g.DecodeBare(b) } @@ -170,19 +206,31 @@ func (g *MessagesGetSearchCountersRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (g *MessagesGetSearchCountersRequest) DecodeBare(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't decode messages.getSearchCounters#732eef00 to nil") + return fmt.Errorf("can't decode messages.getSearchCounters#ae7cc1 to nil") + } + { + if err := g.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.getSearchCounters#ae7cc1: field flags: %w", err) + } } { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.getSearchCounters#732eef00: field peer: %w", err) + return fmt.Errorf("unable to decode messages.getSearchCounters#ae7cc1: field peer: %w", err) } g.Peer = value } + if g.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.getSearchCounters#ae7cc1: field top_msg_id: %w", err) + } + g.TopMsgID = value + } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode messages.getSearchCounters#732eef00: field filters: %w", err) + return fmt.Errorf("unable to decode messages.getSearchCounters#ae7cc1: field filters: %w", err) } if headerLen > 0 { @@ -191,7 +239,7 @@ func (g *MessagesGetSearchCountersRequest) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeMessagesFilter(b) if err != nil { - return fmt.Errorf("unable to decode messages.getSearchCounters#732eef00: field filters: %w", err) + return fmt.Errorf("unable to decode messages.getSearchCounters#ae7cc1: field filters: %w", err) } g.Filters = append(g.Filters, value) } @@ -207,6 +255,24 @@ func (g *MessagesGetSearchCountersRequest) GetPeer() (value InputPeerClass) { return g.Peer } +// SetTopMsgID sets value of TopMsgID conditional field. +func (g *MessagesGetSearchCountersRequest) SetTopMsgID(value int) { + g.Flags.Set(0) + g.TopMsgID = value +} + +// GetTopMsgID returns value of TopMsgID conditional field and +// boolean which is true if field was set. +func (g *MessagesGetSearchCountersRequest) GetTopMsgID() (value int, ok bool) { + if g == nil { + return + } + if !g.Flags.Has(0) { + return value, false + } + return g.TopMsgID, true +} + // GetFilters returns value of Filters field. func (g *MessagesGetSearchCountersRequest) GetFilters() (value []MessagesFilterClass) { if g == nil { @@ -220,7 +286,7 @@ func (g *MessagesGetSearchCountersRequest) MapFilters() (value MessagesFilterCla return MessagesFilterClassArray(g.Filters) } -// MessagesGetSearchCounters invokes method messages.getSearchCounters#732eef00 returning error if any. +// MessagesGetSearchCounters invokes method messages.getSearchCounters#ae7cc1 returning error if any. // Get the number of results that would be found by a messages.search¹ call with the // same parameters // diff --git a/tg/tl_messages_get_unread_mentions_gen.go b/tg/tl_messages_get_unread_mentions_gen.go index ca7478ff8e..c16a2a81bc 100644 --- a/tg/tl_messages_get_unread_mentions_gen.go +++ b/tg/tl_messages_get_unread_mentions_gen.go @@ -31,13 +31,19 @@ var ( _ = tdjson.Encoder{} ) -// MessagesGetUnreadMentionsRequest represents TL type `messages.getUnreadMentions#46578472`. +// MessagesGetUnreadMentionsRequest represents TL type `messages.getUnreadMentions#f107e790`. // Get unread messages where we were mentioned // // See https://core.telegram.org/method/messages.getUnreadMentions for reference. type MessagesGetUnreadMentionsRequest struct { + // Flags field of MessagesGetUnreadMentionsRequest. + Flags bin.Fields // Peer where to look for mentions Peer InputPeerClass + // TopMsgID field of MessagesGetUnreadMentionsRequest. + // + // Use SetTopMsgID and GetTopMsgID helpers. + TopMsgID int // Offsets for pagination, for more info click here¹ // // Links: @@ -66,7 +72,7 @@ type MessagesGetUnreadMentionsRequest struct { } // MessagesGetUnreadMentionsRequestTypeID is TL type id of MessagesGetUnreadMentionsRequest. -const MessagesGetUnreadMentionsRequestTypeID = 0x46578472 +const MessagesGetUnreadMentionsRequestTypeID = 0xf107e790 // Ensuring interfaces in compile-time for MessagesGetUnreadMentionsRequest. var ( @@ -80,9 +86,15 @@ func (g *MessagesGetUnreadMentionsRequest) Zero() bool { if g == nil { return true } + if !(g.Flags.Zero()) { + return false + } if !(g.Peer == nil) { return false } + if !(g.TopMsgID == 0) { + return false + } if !(g.OffsetID == 0) { return false } @@ -114,6 +126,7 @@ func (g *MessagesGetUnreadMentionsRequest) String() string { // FillFrom fills MessagesGetUnreadMentionsRequest from given interface. func (g *MessagesGetUnreadMentionsRequest) FillFrom(from interface { GetPeer() (value InputPeerClass) + GetTopMsgID() (value int, ok bool) GetOffsetID() (value int) GetAddOffset() (value int) GetLimit() (value int) @@ -121,6 +134,10 @@ func (g *MessagesGetUnreadMentionsRequest) FillFrom(from interface { GetMinID() (value int) }) { g.Peer = from.GetPeer() + if val, ok := from.GetTopMsgID(); ok { + g.TopMsgID = val + } + g.OffsetID = from.GetOffsetID() g.AddOffset = from.GetAddOffset() g.Limit = from.GetLimit() @@ -155,6 +172,11 @@ func (g *MessagesGetUnreadMentionsRequest) TypeInfo() tdp.Type { Name: "Peer", SchemaName: "peer", }, + { + Name: "TopMsgID", + SchemaName: "top_msg_id", + Null: !g.Flags.Has(0), + }, { Name: "OffsetID", SchemaName: "offset_id", @@ -179,10 +201,17 @@ func (g *MessagesGetUnreadMentionsRequest) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (g *MessagesGetUnreadMentionsRequest) SetFlags() { + if !(g.TopMsgID == 0) { + g.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (g *MessagesGetUnreadMentionsRequest) Encode(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't encode messages.getUnreadMentions#46578472 as nil") + return fmt.Errorf("can't encode messages.getUnreadMentions#f107e790 as nil") } b.PutID(MessagesGetUnreadMentionsRequestTypeID) return g.EncodeBare(b) @@ -191,13 +220,20 @@ func (g *MessagesGetUnreadMentionsRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (g *MessagesGetUnreadMentionsRequest) EncodeBare(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't encode messages.getUnreadMentions#46578472 as nil") + return fmt.Errorf("can't encode messages.getUnreadMentions#f107e790 as nil") + } + g.SetFlags() + if err := g.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.getUnreadMentions#f107e790: field flags: %w", err) } if g.Peer == nil { - return fmt.Errorf("unable to encode messages.getUnreadMentions#46578472: field peer is nil") + return fmt.Errorf("unable to encode messages.getUnreadMentions#f107e790: field peer is nil") } if err := g.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.getUnreadMentions#46578472: field peer: %w", err) + return fmt.Errorf("unable to encode messages.getUnreadMentions#f107e790: field peer: %w", err) + } + if g.Flags.Has(0) { + b.PutInt(g.TopMsgID) } b.PutInt(g.OffsetID) b.PutInt(g.AddOffset) @@ -210,10 +246,10 @@ func (g *MessagesGetUnreadMentionsRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (g *MessagesGetUnreadMentionsRequest) Decode(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't decode messages.getUnreadMentions#46578472 to nil") + return fmt.Errorf("can't decode messages.getUnreadMentions#f107e790 to nil") } if err := b.ConsumeID(MessagesGetUnreadMentionsRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.getUnreadMentions#46578472: %w", err) + return fmt.Errorf("unable to decode messages.getUnreadMentions#f107e790: %w", err) } return g.DecodeBare(b) } @@ -221,47 +257,59 @@ func (g *MessagesGetUnreadMentionsRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (g *MessagesGetUnreadMentionsRequest) DecodeBare(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't decode messages.getUnreadMentions#46578472 to nil") + return fmt.Errorf("can't decode messages.getUnreadMentions#f107e790 to nil") + } + { + if err := g.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.getUnreadMentions#f107e790: field flags: %w", err) + } } { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.getUnreadMentions#46578472: field peer: %w", err) + return fmt.Errorf("unable to decode messages.getUnreadMentions#f107e790: field peer: %w", err) } g.Peer = value } + if g.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.getUnreadMentions#f107e790: field top_msg_id: %w", err) + } + g.TopMsgID = value + } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.getUnreadMentions#46578472: field offset_id: %w", err) + return fmt.Errorf("unable to decode messages.getUnreadMentions#f107e790: field offset_id: %w", err) } g.OffsetID = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.getUnreadMentions#46578472: field add_offset: %w", err) + return fmt.Errorf("unable to decode messages.getUnreadMentions#f107e790: field add_offset: %w", err) } g.AddOffset = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.getUnreadMentions#46578472: field limit: %w", err) + return fmt.Errorf("unable to decode messages.getUnreadMentions#f107e790: field limit: %w", err) } g.Limit = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.getUnreadMentions#46578472: field max_id: %w", err) + return fmt.Errorf("unable to decode messages.getUnreadMentions#f107e790: field max_id: %w", err) } g.MaxID = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.getUnreadMentions#46578472: field min_id: %w", err) + return fmt.Errorf("unable to decode messages.getUnreadMentions#f107e790: field min_id: %w", err) } g.MinID = value } @@ -276,6 +324,24 @@ func (g *MessagesGetUnreadMentionsRequest) GetPeer() (value InputPeerClass) { return g.Peer } +// SetTopMsgID sets value of TopMsgID conditional field. +func (g *MessagesGetUnreadMentionsRequest) SetTopMsgID(value int) { + g.Flags.Set(0) + g.TopMsgID = value +} + +// GetTopMsgID returns value of TopMsgID conditional field and +// boolean which is true if field was set. +func (g *MessagesGetUnreadMentionsRequest) GetTopMsgID() (value int, ok bool) { + if g == nil { + return + } + if !g.Flags.Has(0) { + return value, false + } + return g.TopMsgID, true +} + // GetOffsetID returns value of OffsetID field. func (g *MessagesGetUnreadMentionsRequest) GetOffsetID() (value int) { if g == nil { @@ -316,7 +382,7 @@ func (g *MessagesGetUnreadMentionsRequest) GetMinID() (value int) { return g.MinID } -// MessagesGetUnreadMentions invokes method messages.getUnreadMentions#46578472 returning error if any. +// MessagesGetUnreadMentions invokes method messages.getUnreadMentions#f107e790 returning error if any. // Get unread messages where we were mentioned // // Possible errors: diff --git a/tg/tl_messages_get_unread_reactions_gen.go b/tg/tl_messages_get_unread_reactions_gen.go index b02d40e733..1518ff7c0e 100644 --- a/tg/tl_messages_get_unread_reactions_gen.go +++ b/tg/tl_messages_get_unread_reactions_gen.go @@ -31,13 +31,19 @@ var ( _ = tdjson.Encoder{} ) -// MessagesGetUnreadReactionsRequest represents TL type `messages.getUnreadReactions#e85bae1a`. +// MessagesGetUnreadReactionsRequest represents TL type `messages.getUnreadReactions#3223495b`. // Get unread reactions to messages you sent // // See https://core.telegram.org/method/messages.getUnreadReactions for reference. type MessagesGetUnreadReactionsRequest struct { + // Flags field of MessagesGetUnreadReactionsRequest. + Flags bin.Fields // Peer Peer InputPeerClass + // TopMsgID field of MessagesGetUnreadReactionsRequest. + // + // Use SetTopMsgID and GetTopMsgID helpers. + TopMsgID int // Offsets for pagination, for more info click here¹ // // Links: @@ -60,7 +66,7 @@ type MessagesGetUnreadReactionsRequest struct { } // MessagesGetUnreadReactionsRequestTypeID is TL type id of MessagesGetUnreadReactionsRequest. -const MessagesGetUnreadReactionsRequestTypeID = 0xe85bae1a +const MessagesGetUnreadReactionsRequestTypeID = 0x3223495b // Ensuring interfaces in compile-time for MessagesGetUnreadReactionsRequest. var ( @@ -74,9 +80,15 @@ func (g *MessagesGetUnreadReactionsRequest) Zero() bool { if g == nil { return true } + if !(g.Flags.Zero()) { + return false + } if !(g.Peer == nil) { return false } + if !(g.TopMsgID == 0) { + return false + } if !(g.OffsetID == 0) { return false } @@ -108,6 +120,7 @@ func (g *MessagesGetUnreadReactionsRequest) String() string { // FillFrom fills MessagesGetUnreadReactionsRequest from given interface. func (g *MessagesGetUnreadReactionsRequest) FillFrom(from interface { GetPeer() (value InputPeerClass) + GetTopMsgID() (value int, ok bool) GetOffsetID() (value int) GetAddOffset() (value int) GetLimit() (value int) @@ -115,6 +128,10 @@ func (g *MessagesGetUnreadReactionsRequest) FillFrom(from interface { GetMinID() (value int) }) { g.Peer = from.GetPeer() + if val, ok := from.GetTopMsgID(); ok { + g.TopMsgID = val + } + g.OffsetID = from.GetOffsetID() g.AddOffset = from.GetAddOffset() g.Limit = from.GetLimit() @@ -149,6 +166,11 @@ func (g *MessagesGetUnreadReactionsRequest) TypeInfo() tdp.Type { Name: "Peer", SchemaName: "peer", }, + { + Name: "TopMsgID", + SchemaName: "top_msg_id", + Null: !g.Flags.Has(0), + }, { Name: "OffsetID", SchemaName: "offset_id", @@ -173,10 +195,17 @@ func (g *MessagesGetUnreadReactionsRequest) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (g *MessagesGetUnreadReactionsRequest) SetFlags() { + if !(g.TopMsgID == 0) { + g.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (g *MessagesGetUnreadReactionsRequest) Encode(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't encode messages.getUnreadReactions#e85bae1a as nil") + return fmt.Errorf("can't encode messages.getUnreadReactions#3223495b as nil") } b.PutID(MessagesGetUnreadReactionsRequestTypeID) return g.EncodeBare(b) @@ -185,13 +214,20 @@ func (g *MessagesGetUnreadReactionsRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (g *MessagesGetUnreadReactionsRequest) EncodeBare(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't encode messages.getUnreadReactions#e85bae1a as nil") + return fmt.Errorf("can't encode messages.getUnreadReactions#3223495b as nil") + } + g.SetFlags() + if err := g.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.getUnreadReactions#3223495b: field flags: %w", err) } if g.Peer == nil { - return fmt.Errorf("unable to encode messages.getUnreadReactions#e85bae1a: field peer is nil") + return fmt.Errorf("unable to encode messages.getUnreadReactions#3223495b: field peer is nil") } if err := g.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.getUnreadReactions#e85bae1a: field peer: %w", err) + return fmt.Errorf("unable to encode messages.getUnreadReactions#3223495b: field peer: %w", err) + } + if g.Flags.Has(0) { + b.PutInt(g.TopMsgID) } b.PutInt(g.OffsetID) b.PutInt(g.AddOffset) @@ -204,10 +240,10 @@ func (g *MessagesGetUnreadReactionsRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (g *MessagesGetUnreadReactionsRequest) Decode(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't decode messages.getUnreadReactions#e85bae1a to nil") + return fmt.Errorf("can't decode messages.getUnreadReactions#3223495b to nil") } if err := b.ConsumeID(MessagesGetUnreadReactionsRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.getUnreadReactions#e85bae1a: %w", err) + return fmt.Errorf("unable to decode messages.getUnreadReactions#3223495b: %w", err) } return g.DecodeBare(b) } @@ -215,47 +251,59 @@ func (g *MessagesGetUnreadReactionsRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (g *MessagesGetUnreadReactionsRequest) DecodeBare(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't decode messages.getUnreadReactions#e85bae1a to nil") + return fmt.Errorf("can't decode messages.getUnreadReactions#3223495b to nil") + } + { + if err := g.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.getUnreadReactions#3223495b: field flags: %w", err) + } } { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.getUnreadReactions#e85bae1a: field peer: %w", err) + return fmt.Errorf("unable to decode messages.getUnreadReactions#3223495b: field peer: %w", err) } g.Peer = value } + if g.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.getUnreadReactions#3223495b: field top_msg_id: %w", err) + } + g.TopMsgID = value + } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.getUnreadReactions#e85bae1a: field offset_id: %w", err) + return fmt.Errorf("unable to decode messages.getUnreadReactions#3223495b: field offset_id: %w", err) } g.OffsetID = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.getUnreadReactions#e85bae1a: field add_offset: %w", err) + return fmt.Errorf("unable to decode messages.getUnreadReactions#3223495b: field add_offset: %w", err) } g.AddOffset = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.getUnreadReactions#e85bae1a: field limit: %w", err) + return fmt.Errorf("unable to decode messages.getUnreadReactions#3223495b: field limit: %w", err) } g.Limit = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.getUnreadReactions#e85bae1a: field max_id: %w", err) + return fmt.Errorf("unable to decode messages.getUnreadReactions#3223495b: field max_id: %w", err) } g.MaxID = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.getUnreadReactions#e85bae1a: field min_id: %w", err) + return fmt.Errorf("unable to decode messages.getUnreadReactions#3223495b: field min_id: %w", err) } g.MinID = value } @@ -270,6 +318,24 @@ func (g *MessagesGetUnreadReactionsRequest) GetPeer() (value InputPeerClass) { return g.Peer } +// SetTopMsgID sets value of TopMsgID conditional field. +func (g *MessagesGetUnreadReactionsRequest) SetTopMsgID(value int) { + g.Flags.Set(0) + g.TopMsgID = value +} + +// GetTopMsgID returns value of TopMsgID conditional field and +// boolean which is true if field was set. +func (g *MessagesGetUnreadReactionsRequest) GetTopMsgID() (value int, ok bool) { + if g == nil { + return + } + if !g.Flags.Has(0) { + return value, false + } + return g.TopMsgID, true +} + // GetOffsetID returns value of OffsetID field. func (g *MessagesGetUnreadReactionsRequest) GetOffsetID() (value int) { if g == nil { @@ -310,7 +376,7 @@ func (g *MessagesGetUnreadReactionsRequest) GetMinID() (value int) { return g.MinID } -// MessagesGetUnreadReactions invokes method messages.getUnreadReactions#e85bae1a returning error if any. +// MessagesGetUnreadReactions invokes method messages.getUnreadReactions#3223495b returning error if any. // Get unread reactions to messages you sent // // See https://core.telegram.org/method/messages.getUnreadReactions for reference. diff --git a/tg/tl_messages_prolong_web_view_gen.go b/tg/tl_messages_prolong_web_view_gen.go index 2362e5ea33..d2c4e89b03 100644 --- a/tg/tl_messages_prolong_web_view_gen.go +++ b/tg/tl_messages_prolong_web_view_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesProlongWebViewRequest represents TL type `messages.prolongWebView#ea5fbcce`. +// MessagesProlongWebViewRequest represents TL type `messages.prolongWebView#7ff34309`. // Indicate to the server (from the user side) that the user is still using a web app. // // See https://core.telegram.org/method/messages.prolongWebView for reference. @@ -68,6 +68,10 @@ type MessagesProlongWebViewRequest struct { // // Use SetReplyToMsgID and GetReplyToMsgID helpers. ReplyToMsgID int + // TopMsgID field of MessagesProlongWebViewRequest. + // + // Use SetTopMsgID and GetTopMsgID helpers. + TopMsgID int // Open the web app as the specified peer // // Use SetSendAs and GetSendAs helpers. @@ -75,7 +79,7 @@ type MessagesProlongWebViewRequest struct { } // MessagesProlongWebViewRequestTypeID is TL type id of MessagesProlongWebViewRequest. -const MessagesProlongWebViewRequestTypeID = 0xea5fbcce +const MessagesProlongWebViewRequestTypeID = 0x7ff34309 // Ensuring interfaces in compile-time for MessagesProlongWebViewRequest. var ( @@ -107,6 +111,9 @@ func (p *MessagesProlongWebViewRequest) Zero() bool { if !(p.ReplyToMsgID == 0) { return false } + if !(p.TopMsgID == 0) { + return false + } if !(p.SendAs == nil) { return false } @@ -130,6 +137,7 @@ func (p *MessagesProlongWebViewRequest) FillFrom(from interface { GetBot() (value InputUserClass) GetQueryID() (value int64) GetReplyToMsgID() (value int, ok bool) + GetTopMsgID() (value int, ok bool) GetSendAs() (value InputPeerClass, ok bool) }) { p.Silent = from.GetSilent() @@ -140,6 +148,10 @@ func (p *MessagesProlongWebViewRequest) FillFrom(from interface { p.ReplyToMsgID = val } + if val, ok := from.GetTopMsgID(); ok { + p.TopMsgID = val + } + if val, ok := from.GetSendAs(); ok { p.SendAs = val } @@ -191,6 +203,11 @@ func (p *MessagesProlongWebViewRequest) TypeInfo() tdp.Type { SchemaName: "reply_to_msg_id", Null: !p.Flags.Has(0), }, + { + Name: "TopMsgID", + SchemaName: "top_msg_id", + Null: !p.Flags.Has(9), + }, { Name: "SendAs", SchemaName: "send_as", @@ -208,6 +225,9 @@ func (p *MessagesProlongWebViewRequest) SetFlags() { if !(p.ReplyToMsgID == 0) { p.Flags.Set(0) } + if !(p.TopMsgID == 0) { + p.Flags.Set(9) + } if !(p.SendAs == nil) { p.Flags.Set(13) } @@ -216,7 +236,7 @@ func (p *MessagesProlongWebViewRequest) SetFlags() { // Encode implements bin.Encoder. func (p *MessagesProlongWebViewRequest) Encode(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't encode messages.prolongWebView#ea5fbcce as nil") + return fmt.Errorf("can't encode messages.prolongWebView#7ff34309 as nil") } b.PutID(MessagesProlongWebViewRequestTypeID) return p.EncodeBare(b) @@ -225,34 +245,37 @@ func (p *MessagesProlongWebViewRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (p *MessagesProlongWebViewRequest) EncodeBare(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't encode messages.prolongWebView#ea5fbcce as nil") + return fmt.Errorf("can't encode messages.prolongWebView#7ff34309 as nil") } p.SetFlags() if err := p.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.prolongWebView#ea5fbcce: field flags: %w", err) + return fmt.Errorf("unable to encode messages.prolongWebView#7ff34309: field flags: %w", err) } if p.Peer == nil { - return fmt.Errorf("unable to encode messages.prolongWebView#ea5fbcce: field peer is nil") + return fmt.Errorf("unable to encode messages.prolongWebView#7ff34309: field peer is nil") } if err := p.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.prolongWebView#ea5fbcce: field peer: %w", err) + return fmt.Errorf("unable to encode messages.prolongWebView#7ff34309: field peer: %w", err) } if p.Bot == nil { - return fmt.Errorf("unable to encode messages.prolongWebView#ea5fbcce: field bot is nil") + return fmt.Errorf("unable to encode messages.prolongWebView#7ff34309: field bot is nil") } if err := p.Bot.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.prolongWebView#ea5fbcce: field bot: %w", err) + return fmt.Errorf("unable to encode messages.prolongWebView#7ff34309: field bot: %w", err) } b.PutLong(p.QueryID) if p.Flags.Has(0) { b.PutInt(p.ReplyToMsgID) } + if p.Flags.Has(9) { + b.PutInt(p.TopMsgID) + } if p.Flags.Has(13) { if p.SendAs == nil { - return fmt.Errorf("unable to encode messages.prolongWebView#ea5fbcce: field send_as is nil") + return fmt.Errorf("unable to encode messages.prolongWebView#7ff34309: field send_as is nil") } if err := p.SendAs.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.prolongWebView#ea5fbcce: field send_as: %w", err) + return fmt.Errorf("unable to encode messages.prolongWebView#7ff34309: field send_as: %w", err) } } return nil @@ -261,10 +284,10 @@ func (p *MessagesProlongWebViewRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (p *MessagesProlongWebViewRequest) Decode(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't decode messages.prolongWebView#ea5fbcce to nil") + return fmt.Errorf("can't decode messages.prolongWebView#7ff34309 to nil") } if err := b.ConsumeID(MessagesProlongWebViewRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.prolongWebView#ea5fbcce: %w", err) + return fmt.Errorf("unable to decode messages.prolongWebView#7ff34309: %w", err) } return p.DecodeBare(b) } @@ -272,46 +295,53 @@ func (p *MessagesProlongWebViewRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (p *MessagesProlongWebViewRequest) DecodeBare(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't decode messages.prolongWebView#ea5fbcce to nil") + return fmt.Errorf("can't decode messages.prolongWebView#7ff34309 to nil") } { if err := p.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.prolongWebView#ea5fbcce: field flags: %w", err) + return fmt.Errorf("unable to decode messages.prolongWebView#7ff34309: field flags: %w", err) } } p.Silent = p.Flags.Has(5) { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.prolongWebView#ea5fbcce: field peer: %w", err) + return fmt.Errorf("unable to decode messages.prolongWebView#7ff34309: field peer: %w", err) } p.Peer = value } { value, err := DecodeInputUser(b) if err != nil { - return fmt.Errorf("unable to decode messages.prolongWebView#ea5fbcce: field bot: %w", err) + return fmt.Errorf("unable to decode messages.prolongWebView#7ff34309: field bot: %w", err) } p.Bot = value } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode messages.prolongWebView#ea5fbcce: field query_id: %w", err) + return fmt.Errorf("unable to decode messages.prolongWebView#7ff34309: field query_id: %w", err) } p.QueryID = value } if p.Flags.Has(0) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.prolongWebView#ea5fbcce: field reply_to_msg_id: %w", err) + return fmt.Errorf("unable to decode messages.prolongWebView#7ff34309: field reply_to_msg_id: %w", err) } p.ReplyToMsgID = value } + if p.Flags.Has(9) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.prolongWebView#7ff34309: field top_msg_id: %w", err) + } + p.TopMsgID = value + } if p.Flags.Has(13) { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.prolongWebView#ea5fbcce: field send_as: %w", err) + return fmt.Errorf("unable to decode messages.prolongWebView#7ff34309: field send_as: %w", err) } p.SendAs = value } @@ -379,6 +409,24 @@ func (p *MessagesProlongWebViewRequest) GetReplyToMsgID() (value int, ok bool) { return p.ReplyToMsgID, true } +// SetTopMsgID sets value of TopMsgID conditional field. +func (p *MessagesProlongWebViewRequest) SetTopMsgID(value int) { + p.Flags.Set(9) + p.TopMsgID = value +} + +// GetTopMsgID returns value of TopMsgID conditional field and +// boolean which is true if field was set. +func (p *MessagesProlongWebViewRequest) GetTopMsgID() (value int, ok bool) { + if p == nil { + return + } + if !p.Flags.Has(9) { + return value, false + } + return p.TopMsgID, true +} + // SetSendAs sets value of SendAs conditional field. func (p *MessagesProlongWebViewRequest) SetSendAs(value InputPeerClass) { p.Flags.Set(13) @@ -397,7 +445,7 @@ func (p *MessagesProlongWebViewRequest) GetSendAs() (value InputPeerClass, ok bo return p.SendAs, true } -// MessagesProlongWebView invokes method messages.prolongWebView#ea5fbcce returning error if any. +// MessagesProlongWebView invokes method messages.prolongWebView#7ff34309 returning error if any. // Indicate to the server (from the user side) that the user is still using a web app. // // See https://core.telegram.org/method/messages.prolongWebView for reference. diff --git a/tg/tl_messages_read_mentions_gen.go b/tg/tl_messages_read_mentions_gen.go index bd04ba5a02..95c46451b1 100644 --- a/tg/tl_messages_read_mentions_gen.go +++ b/tg/tl_messages_read_mentions_gen.go @@ -31,17 +31,23 @@ var ( _ = tdjson.Encoder{} ) -// MessagesReadMentionsRequest represents TL type `messages.readMentions#f0189d3`. +// MessagesReadMentionsRequest represents TL type `messages.readMentions#36e5bf4d`. // Mark mentions as read // // See https://core.telegram.org/method/messages.readMentions for reference. type MessagesReadMentionsRequest struct { + // Flags field of MessagesReadMentionsRequest. + Flags bin.Fields // Dialog Peer InputPeerClass + // TopMsgID field of MessagesReadMentionsRequest. + // + // Use SetTopMsgID and GetTopMsgID helpers. + TopMsgID int } // MessagesReadMentionsRequestTypeID is TL type id of MessagesReadMentionsRequest. -const MessagesReadMentionsRequestTypeID = 0xf0189d3 +const MessagesReadMentionsRequestTypeID = 0x36e5bf4d // Ensuring interfaces in compile-time for MessagesReadMentionsRequest. var ( @@ -55,9 +61,15 @@ func (r *MessagesReadMentionsRequest) Zero() bool { if r == nil { return true } + if !(r.Flags.Zero()) { + return false + } if !(r.Peer == nil) { return false } + if !(r.TopMsgID == 0) { + return false + } return true } @@ -74,8 +86,13 @@ func (r *MessagesReadMentionsRequest) String() string { // FillFrom fills MessagesReadMentionsRequest from given interface. func (r *MessagesReadMentionsRequest) FillFrom(from interface { GetPeer() (value InputPeerClass) + GetTopMsgID() (value int, ok bool) }) { r.Peer = from.GetPeer() + if val, ok := from.GetTopMsgID(); ok { + r.TopMsgID = val + } + } // TypeID returns type id in TL schema. @@ -105,14 +122,26 @@ func (r *MessagesReadMentionsRequest) TypeInfo() tdp.Type { Name: "Peer", SchemaName: "peer", }, + { + Name: "TopMsgID", + SchemaName: "top_msg_id", + Null: !r.Flags.Has(0), + }, } return typ } +// SetFlags sets flags for non-zero fields. +func (r *MessagesReadMentionsRequest) SetFlags() { + if !(r.TopMsgID == 0) { + r.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (r *MessagesReadMentionsRequest) Encode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode messages.readMentions#f0189d3 as nil") + return fmt.Errorf("can't encode messages.readMentions#36e5bf4d as nil") } b.PutID(MessagesReadMentionsRequestTypeID) return r.EncodeBare(b) @@ -121,13 +150,20 @@ func (r *MessagesReadMentionsRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (r *MessagesReadMentionsRequest) EncodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode messages.readMentions#f0189d3 as nil") + return fmt.Errorf("can't encode messages.readMentions#36e5bf4d as nil") + } + r.SetFlags() + if err := r.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.readMentions#36e5bf4d: field flags: %w", err) } if r.Peer == nil { - return fmt.Errorf("unable to encode messages.readMentions#f0189d3: field peer is nil") + return fmt.Errorf("unable to encode messages.readMentions#36e5bf4d: field peer is nil") } if err := r.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.readMentions#f0189d3: field peer: %w", err) + return fmt.Errorf("unable to encode messages.readMentions#36e5bf4d: field peer: %w", err) + } + if r.Flags.Has(0) { + b.PutInt(r.TopMsgID) } return nil } @@ -135,10 +171,10 @@ func (r *MessagesReadMentionsRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (r *MessagesReadMentionsRequest) Decode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode messages.readMentions#f0189d3 to nil") + return fmt.Errorf("can't decode messages.readMentions#36e5bf4d to nil") } if err := b.ConsumeID(MessagesReadMentionsRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.readMentions#f0189d3: %w", err) + return fmt.Errorf("unable to decode messages.readMentions#36e5bf4d: %w", err) } return r.DecodeBare(b) } @@ -146,15 +182,27 @@ func (r *MessagesReadMentionsRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (r *MessagesReadMentionsRequest) DecodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode messages.readMentions#f0189d3 to nil") + return fmt.Errorf("can't decode messages.readMentions#36e5bf4d to nil") + } + { + if err := r.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.readMentions#36e5bf4d: field flags: %w", err) + } } { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.readMentions#f0189d3: field peer: %w", err) + return fmt.Errorf("unable to decode messages.readMentions#36e5bf4d: field peer: %w", err) } r.Peer = value } + if r.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.readMentions#36e5bf4d: field top_msg_id: %w", err) + } + r.TopMsgID = value + } return nil } @@ -166,7 +214,25 @@ func (r *MessagesReadMentionsRequest) GetPeer() (value InputPeerClass) { return r.Peer } -// MessagesReadMentions invokes method messages.readMentions#f0189d3 returning error if any. +// SetTopMsgID sets value of TopMsgID conditional field. +func (r *MessagesReadMentionsRequest) SetTopMsgID(value int) { + r.Flags.Set(0) + r.TopMsgID = value +} + +// GetTopMsgID returns value of TopMsgID conditional field and +// boolean which is true if field was set. +func (r *MessagesReadMentionsRequest) GetTopMsgID() (value int, ok bool) { + if r == nil { + return + } + if !r.Flags.Has(0) { + return value, false + } + return r.TopMsgID, true +} + +// MessagesReadMentions invokes method messages.readMentions#36e5bf4d returning error if any. // Mark mentions as read // // Possible errors: @@ -177,12 +243,9 @@ func (r *MessagesReadMentionsRequest) GetPeer() (value InputPeerClass) { // 400 PEER_ID_INVALID: The provided peer id is invalid. // // See https://core.telegram.org/method/messages.readMentions for reference. -func (c *Client) MessagesReadMentions(ctx context.Context, peer InputPeerClass) (*MessagesAffectedHistory, error) { +func (c *Client) MessagesReadMentions(ctx context.Context, request *MessagesReadMentionsRequest) (*MessagesAffectedHistory, error) { var result MessagesAffectedHistory - request := &MessagesReadMentionsRequest{ - Peer: peer, - } if err := c.rpc.Invoke(ctx, request, &result); err != nil { return nil, err } diff --git a/tg/tl_messages_read_reactions_gen.go b/tg/tl_messages_read_reactions_gen.go index b66e406158..e0adb2ee66 100644 --- a/tg/tl_messages_read_reactions_gen.go +++ b/tg/tl_messages_read_reactions_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesReadReactionsRequest represents TL type `messages.readReactions#82e251d7`. +// MessagesReadReactionsRequest represents TL type `messages.readReactions#54aa7f8e`. // Mark message reactions »¹ as read // // Links: @@ -39,12 +39,18 @@ var ( // // See https://core.telegram.org/method/messages.readReactions for reference. type MessagesReadReactionsRequest struct { + // Flags field of MessagesReadReactionsRequest. + Flags bin.Fields // Peer Peer InputPeerClass + // TopMsgID field of MessagesReadReactionsRequest. + // + // Use SetTopMsgID and GetTopMsgID helpers. + TopMsgID int } // MessagesReadReactionsRequestTypeID is TL type id of MessagesReadReactionsRequest. -const MessagesReadReactionsRequestTypeID = 0x82e251d7 +const MessagesReadReactionsRequestTypeID = 0x54aa7f8e // Ensuring interfaces in compile-time for MessagesReadReactionsRequest. var ( @@ -58,9 +64,15 @@ func (r *MessagesReadReactionsRequest) Zero() bool { if r == nil { return true } + if !(r.Flags.Zero()) { + return false + } if !(r.Peer == nil) { return false } + if !(r.TopMsgID == 0) { + return false + } return true } @@ -77,8 +89,13 @@ func (r *MessagesReadReactionsRequest) String() string { // FillFrom fills MessagesReadReactionsRequest from given interface. func (r *MessagesReadReactionsRequest) FillFrom(from interface { GetPeer() (value InputPeerClass) + GetTopMsgID() (value int, ok bool) }) { r.Peer = from.GetPeer() + if val, ok := from.GetTopMsgID(); ok { + r.TopMsgID = val + } + } // TypeID returns type id in TL schema. @@ -108,14 +125,26 @@ func (r *MessagesReadReactionsRequest) TypeInfo() tdp.Type { Name: "Peer", SchemaName: "peer", }, + { + Name: "TopMsgID", + SchemaName: "top_msg_id", + Null: !r.Flags.Has(0), + }, } return typ } +// SetFlags sets flags for non-zero fields. +func (r *MessagesReadReactionsRequest) SetFlags() { + if !(r.TopMsgID == 0) { + r.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (r *MessagesReadReactionsRequest) Encode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode messages.readReactions#82e251d7 as nil") + return fmt.Errorf("can't encode messages.readReactions#54aa7f8e as nil") } b.PutID(MessagesReadReactionsRequestTypeID) return r.EncodeBare(b) @@ -124,13 +153,20 @@ func (r *MessagesReadReactionsRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (r *MessagesReadReactionsRequest) EncodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode messages.readReactions#82e251d7 as nil") + return fmt.Errorf("can't encode messages.readReactions#54aa7f8e as nil") + } + r.SetFlags() + if err := r.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.readReactions#54aa7f8e: field flags: %w", err) } if r.Peer == nil { - return fmt.Errorf("unable to encode messages.readReactions#82e251d7: field peer is nil") + return fmt.Errorf("unable to encode messages.readReactions#54aa7f8e: field peer is nil") } if err := r.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.readReactions#82e251d7: field peer: %w", err) + return fmt.Errorf("unable to encode messages.readReactions#54aa7f8e: field peer: %w", err) + } + if r.Flags.Has(0) { + b.PutInt(r.TopMsgID) } return nil } @@ -138,10 +174,10 @@ func (r *MessagesReadReactionsRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (r *MessagesReadReactionsRequest) Decode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode messages.readReactions#82e251d7 to nil") + return fmt.Errorf("can't decode messages.readReactions#54aa7f8e to nil") } if err := b.ConsumeID(MessagesReadReactionsRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.readReactions#82e251d7: %w", err) + return fmt.Errorf("unable to decode messages.readReactions#54aa7f8e: %w", err) } return r.DecodeBare(b) } @@ -149,15 +185,27 @@ func (r *MessagesReadReactionsRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (r *MessagesReadReactionsRequest) DecodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode messages.readReactions#82e251d7 to nil") + return fmt.Errorf("can't decode messages.readReactions#54aa7f8e to nil") + } + { + if err := r.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.readReactions#54aa7f8e: field flags: %w", err) + } } { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.readReactions#82e251d7: field peer: %w", err) + return fmt.Errorf("unable to decode messages.readReactions#54aa7f8e: field peer: %w", err) } r.Peer = value } + if r.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.readReactions#54aa7f8e: field top_msg_id: %w", err) + } + r.TopMsgID = value + } return nil } @@ -169,7 +217,25 @@ func (r *MessagesReadReactionsRequest) GetPeer() (value InputPeerClass) { return r.Peer } -// MessagesReadReactions invokes method messages.readReactions#82e251d7 returning error if any. +// SetTopMsgID sets value of TopMsgID conditional field. +func (r *MessagesReadReactionsRequest) SetTopMsgID(value int) { + r.Flags.Set(0) + r.TopMsgID = value +} + +// GetTopMsgID returns value of TopMsgID conditional field and +// boolean which is true if field was set. +func (r *MessagesReadReactionsRequest) GetTopMsgID() (value int, ok bool) { + if r == nil { + return + } + if !r.Flags.Has(0) { + return value, false + } + return r.TopMsgID, true +} + +// MessagesReadReactions invokes method messages.readReactions#54aa7f8e returning error if any. // Mark message reactions »¹ as read // // Links: @@ -180,12 +246,9 @@ func (r *MessagesReadReactionsRequest) GetPeer() (value InputPeerClass) { // 400 PEER_ID_INVALID: The provided peer id is invalid. // // See https://core.telegram.org/method/messages.readReactions for reference. -func (c *Client) MessagesReadReactions(ctx context.Context, peer InputPeerClass) (*MessagesAffectedHistory, error) { +func (c *Client) MessagesReadReactions(ctx context.Context, request *MessagesReadReactionsRequest) (*MessagesAffectedHistory, error) { var result MessagesAffectedHistory - request := &MessagesReadReactionsRequest{ - Peer: peer, - } if err := c.rpc.Invoke(ctx, request, &result); err != nil { return nil, err } diff --git a/tg/tl_messages_request_web_view_gen.go b/tg/tl_messages_request_web_view_gen.go index db129bf2e9..f02235880d 100644 --- a/tg/tl_messages_request_web_view_gen.go +++ b/tg/tl_messages_request_web_view_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesRequestWebViewRequest represents TL type `messages.requestWebView#fc87a53c`. +// MessagesRequestWebViewRequest represents TL type `messages.requestWebView#178b480b`. // Open a bot web app¹, sending over user information after user confirmation. // After calling this method, until the user closes the webview, messages // prolongWebView¹ must be called every 60 seconds. @@ -99,6 +99,10 @@ type MessagesRequestWebViewRequest struct { // // Use SetReplyToMsgID and GetReplyToMsgID helpers. ReplyToMsgID int + // TopMsgID field of MessagesRequestWebViewRequest. + // + // Use SetTopMsgID and GetTopMsgID helpers. + TopMsgID int // Open the web app as the specified peer, sending the resulting the message as the // specified peer. // @@ -107,7 +111,7 @@ type MessagesRequestWebViewRequest struct { } // MessagesRequestWebViewRequestTypeID is TL type id of MessagesRequestWebViewRequest. -const MessagesRequestWebViewRequestTypeID = 0xfc87a53c +const MessagesRequestWebViewRequestTypeID = 0x178b480b // Ensuring interfaces in compile-time for MessagesRequestWebViewRequest. var ( @@ -151,6 +155,9 @@ func (r *MessagesRequestWebViewRequest) Zero() bool { if !(r.ReplyToMsgID == 0) { return false } + if !(r.TopMsgID == 0) { + return false + } if !(r.SendAs == nil) { return false } @@ -178,6 +185,7 @@ func (r *MessagesRequestWebViewRequest) FillFrom(from interface { GetThemeParams() (value DataJSON, ok bool) GetPlatform() (value string) GetReplyToMsgID() (value int, ok bool) + GetTopMsgID() (value int, ok bool) GetSendAs() (value InputPeerClass, ok bool) }) { r.FromBotMenu = from.GetFromBotMenu() @@ -201,6 +209,10 @@ func (r *MessagesRequestWebViewRequest) FillFrom(from interface { r.ReplyToMsgID = val } + if val, ok := from.GetTopMsgID(); ok { + r.TopMsgID = val + } + if val, ok := from.GetSendAs(); ok { r.SendAs = val } @@ -272,6 +284,11 @@ func (r *MessagesRequestWebViewRequest) TypeInfo() tdp.Type { SchemaName: "reply_to_msg_id", Null: !r.Flags.Has(0), }, + { + Name: "TopMsgID", + SchemaName: "top_msg_id", + Null: !r.Flags.Has(9), + }, { Name: "SendAs", SchemaName: "send_as", @@ -301,6 +318,9 @@ func (r *MessagesRequestWebViewRequest) SetFlags() { if !(r.ReplyToMsgID == 0) { r.Flags.Set(0) } + if !(r.TopMsgID == 0) { + r.Flags.Set(9) + } if !(r.SendAs == nil) { r.Flags.Set(13) } @@ -309,7 +329,7 @@ func (r *MessagesRequestWebViewRequest) SetFlags() { // Encode implements bin.Encoder. func (r *MessagesRequestWebViewRequest) Encode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode messages.requestWebView#fc87a53c as nil") + return fmt.Errorf("can't encode messages.requestWebView#178b480b as nil") } b.PutID(MessagesRequestWebViewRequestTypeID) return r.EncodeBare(b) @@ -318,23 +338,23 @@ func (r *MessagesRequestWebViewRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (r *MessagesRequestWebViewRequest) EncodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode messages.requestWebView#fc87a53c as nil") + return fmt.Errorf("can't encode messages.requestWebView#178b480b as nil") } r.SetFlags() if err := r.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.requestWebView#fc87a53c: field flags: %w", err) + return fmt.Errorf("unable to encode messages.requestWebView#178b480b: field flags: %w", err) } if r.Peer == nil { - return fmt.Errorf("unable to encode messages.requestWebView#fc87a53c: field peer is nil") + return fmt.Errorf("unable to encode messages.requestWebView#178b480b: field peer is nil") } if err := r.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.requestWebView#fc87a53c: field peer: %w", err) + return fmt.Errorf("unable to encode messages.requestWebView#178b480b: field peer: %w", err) } if r.Bot == nil { - return fmt.Errorf("unable to encode messages.requestWebView#fc87a53c: field bot is nil") + return fmt.Errorf("unable to encode messages.requestWebView#178b480b: field bot is nil") } if err := r.Bot.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.requestWebView#fc87a53c: field bot: %w", err) + return fmt.Errorf("unable to encode messages.requestWebView#178b480b: field bot: %w", err) } if r.Flags.Has(1) { b.PutString(r.URL) @@ -344,19 +364,22 @@ func (r *MessagesRequestWebViewRequest) EncodeBare(b *bin.Buffer) error { } if r.Flags.Has(2) { if err := r.ThemeParams.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.requestWebView#fc87a53c: field theme_params: %w", err) + return fmt.Errorf("unable to encode messages.requestWebView#178b480b: field theme_params: %w", err) } } b.PutString(r.Platform) if r.Flags.Has(0) { b.PutInt(r.ReplyToMsgID) } + if r.Flags.Has(9) { + b.PutInt(r.TopMsgID) + } if r.Flags.Has(13) { if r.SendAs == nil { - return fmt.Errorf("unable to encode messages.requestWebView#fc87a53c: field send_as is nil") + return fmt.Errorf("unable to encode messages.requestWebView#178b480b: field send_as is nil") } if err := r.SendAs.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.requestWebView#fc87a53c: field send_as: %w", err) + return fmt.Errorf("unable to encode messages.requestWebView#178b480b: field send_as: %w", err) } } return nil @@ -365,10 +388,10 @@ func (r *MessagesRequestWebViewRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (r *MessagesRequestWebViewRequest) Decode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode messages.requestWebView#fc87a53c to nil") + return fmt.Errorf("can't decode messages.requestWebView#178b480b to nil") } if err := b.ConsumeID(MessagesRequestWebViewRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.requestWebView#fc87a53c: %w", err) + return fmt.Errorf("unable to decode messages.requestWebView#178b480b: %w", err) } return r.DecodeBare(b) } @@ -376,11 +399,11 @@ func (r *MessagesRequestWebViewRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (r *MessagesRequestWebViewRequest) DecodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode messages.requestWebView#fc87a53c to nil") + return fmt.Errorf("can't decode messages.requestWebView#178b480b to nil") } { if err := r.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.requestWebView#fc87a53c: field flags: %w", err) + return fmt.Errorf("unable to decode messages.requestWebView#178b480b: field flags: %w", err) } } r.FromBotMenu = r.Flags.Has(4) @@ -388,54 +411,61 @@ func (r *MessagesRequestWebViewRequest) DecodeBare(b *bin.Buffer) error { { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.requestWebView#fc87a53c: field peer: %w", err) + return fmt.Errorf("unable to decode messages.requestWebView#178b480b: field peer: %w", err) } r.Peer = value } { value, err := DecodeInputUser(b) if err != nil { - return fmt.Errorf("unable to decode messages.requestWebView#fc87a53c: field bot: %w", err) + return fmt.Errorf("unable to decode messages.requestWebView#178b480b: field bot: %w", err) } r.Bot = value } if r.Flags.Has(1) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messages.requestWebView#fc87a53c: field url: %w", err) + return fmt.Errorf("unable to decode messages.requestWebView#178b480b: field url: %w", err) } r.URL = value } if r.Flags.Has(3) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messages.requestWebView#fc87a53c: field start_param: %w", err) + return fmt.Errorf("unable to decode messages.requestWebView#178b480b: field start_param: %w", err) } r.StartParam = value } if r.Flags.Has(2) { if err := r.ThemeParams.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.requestWebView#fc87a53c: field theme_params: %w", err) + return fmt.Errorf("unable to decode messages.requestWebView#178b480b: field theme_params: %w", err) } } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messages.requestWebView#fc87a53c: field platform: %w", err) + return fmt.Errorf("unable to decode messages.requestWebView#178b480b: field platform: %w", err) } r.Platform = value } if r.Flags.Has(0) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.requestWebView#fc87a53c: field reply_to_msg_id: %w", err) + return fmt.Errorf("unable to decode messages.requestWebView#178b480b: field reply_to_msg_id: %w", err) } r.ReplyToMsgID = value } + if r.Flags.Has(9) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.requestWebView#178b480b: field top_msg_id: %w", err) + } + r.TopMsgID = value + } if r.Flags.Has(13) { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.requestWebView#fc87a53c: field send_as: %w", err) + return fmt.Errorf("unable to decode messages.requestWebView#178b480b: field send_as: %w", err) } r.SendAs = value } @@ -576,6 +606,24 @@ func (r *MessagesRequestWebViewRequest) GetReplyToMsgID() (value int, ok bool) { return r.ReplyToMsgID, true } +// SetTopMsgID sets value of TopMsgID conditional field. +func (r *MessagesRequestWebViewRequest) SetTopMsgID(value int) { + r.Flags.Set(9) + r.TopMsgID = value +} + +// GetTopMsgID returns value of TopMsgID conditional field and +// boolean which is true if field was set. +func (r *MessagesRequestWebViewRequest) GetTopMsgID() (value int, ok bool) { + if r == nil { + return + } + if !r.Flags.Has(9) { + return value, false + } + return r.TopMsgID, true +} + // SetSendAs sets value of SendAs conditional field. func (r *MessagesRequestWebViewRequest) SetSendAs(value InputPeerClass) { r.Flags.Set(13) @@ -594,7 +642,7 @@ func (r *MessagesRequestWebViewRequest) GetSendAs() (value InputPeerClass, ok bo return r.SendAs, true } -// MessagesRequestWebView invokes method messages.requestWebView#fc87a53c returning error if any. +// MessagesRequestWebView invokes method messages.requestWebView#178b480b returning error if any. // Open a bot web app¹, sending over user information after user confirmation. // After calling this method, until the user closes the webview, messages // prolongWebView¹ must be called every 60 seconds. diff --git a/tg/tl_messages_save_draft_gen.go b/tg/tl_messages_save_draft_gen.go index 7eea07c569..e4459d5279 100644 --- a/tg/tl_messages_save_draft_gen.go +++ b/tg/tl_messages_save_draft_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesSaveDraftRequest represents TL type `messages.saveDraft#bc39e14b`. +// MessagesSaveDraftRequest represents TL type `messages.saveDraft#b4331e3f`. // Save a message draft¹ associated to a chat. // // Links: @@ -50,6 +50,10 @@ type MessagesSaveDraftRequest struct { // // Use SetReplyToMsgID and GetReplyToMsgID helpers. ReplyToMsgID int + // TopMsgID field of MessagesSaveDraftRequest. + // + // Use SetTopMsgID and GetTopMsgID helpers. + TopMsgID int // Destination of the message that should be sent Peer InputPeerClass // The draft @@ -64,7 +68,7 @@ type MessagesSaveDraftRequest struct { } // MessagesSaveDraftRequestTypeID is TL type id of MessagesSaveDraftRequest. -const MessagesSaveDraftRequestTypeID = 0xbc39e14b +const MessagesSaveDraftRequestTypeID = 0xb4331e3f // Ensuring interfaces in compile-time for MessagesSaveDraftRequest. var ( @@ -87,6 +91,9 @@ func (s *MessagesSaveDraftRequest) Zero() bool { if !(s.ReplyToMsgID == 0) { return false } + if !(s.TopMsgID == 0) { + return false + } if !(s.Peer == nil) { return false } @@ -113,6 +120,7 @@ func (s *MessagesSaveDraftRequest) String() string { func (s *MessagesSaveDraftRequest) FillFrom(from interface { GetNoWebpage() (value bool) GetReplyToMsgID() (value int, ok bool) + GetTopMsgID() (value int, ok bool) GetPeer() (value InputPeerClass) GetMessage() (value string) GetEntities() (value []MessageEntityClass, ok bool) @@ -122,6 +130,10 @@ func (s *MessagesSaveDraftRequest) FillFrom(from interface { s.ReplyToMsgID = val } + if val, ok := from.GetTopMsgID(); ok { + s.TopMsgID = val + } + s.Peer = from.GetPeer() s.Message = from.GetMessage() if val, ok := from.GetEntities(); ok { @@ -163,6 +175,11 @@ func (s *MessagesSaveDraftRequest) TypeInfo() tdp.Type { SchemaName: "reply_to_msg_id", Null: !s.Flags.Has(0), }, + { + Name: "TopMsgID", + SchemaName: "top_msg_id", + Null: !s.Flags.Has(2), + }, { Name: "Peer", SchemaName: "peer", @@ -188,6 +205,9 @@ func (s *MessagesSaveDraftRequest) SetFlags() { if !(s.ReplyToMsgID == 0) { s.Flags.Set(0) } + if !(s.TopMsgID == 0) { + s.Flags.Set(2) + } if !(s.Entities == nil) { s.Flags.Set(3) } @@ -196,7 +216,7 @@ func (s *MessagesSaveDraftRequest) SetFlags() { // Encode implements bin.Encoder. func (s *MessagesSaveDraftRequest) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.saveDraft#bc39e14b as nil") + return fmt.Errorf("can't encode messages.saveDraft#b4331e3f as nil") } b.PutID(MessagesSaveDraftRequestTypeID) return s.EncodeBare(b) @@ -205,30 +225,33 @@ func (s *MessagesSaveDraftRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *MessagesSaveDraftRequest) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.saveDraft#bc39e14b as nil") + return fmt.Errorf("can't encode messages.saveDraft#b4331e3f as nil") } s.SetFlags() if err := s.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.saveDraft#bc39e14b: field flags: %w", err) + return fmt.Errorf("unable to encode messages.saveDraft#b4331e3f: field flags: %w", err) } if s.Flags.Has(0) { b.PutInt(s.ReplyToMsgID) } + if s.Flags.Has(2) { + b.PutInt(s.TopMsgID) + } if s.Peer == nil { - return fmt.Errorf("unable to encode messages.saveDraft#bc39e14b: field peer is nil") + return fmt.Errorf("unable to encode messages.saveDraft#b4331e3f: field peer is nil") } if err := s.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.saveDraft#bc39e14b: field peer: %w", err) + return fmt.Errorf("unable to encode messages.saveDraft#b4331e3f: field peer: %w", err) } b.PutString(s.Message) if s.Flags.Has(3) { b.PutVectorHeader(len(s.Entities)) for idx, v := range s.Entities { if v == nil { - return fmt.Errorf("unable to encode messages.saveDraft#bc39e14b: field entities element with index %d is nil", idx) + return fmt.Errorf("unable to encode messages.saveDraft#b4331e3f: field entities element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.saveDraft#bc39e14b: field entities element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode messages.saveDraft#b4331e3f: field entities element with index %d: %w", idx, err) } } } @@ -238,10 +261,10 @@ func (s *MessagesSaveDraftRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *MessagesSaveDraftRequest) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.saveDraft#bc39e14b to nil") + return fmt.Errorf("can't decode messages.saveDraft#b4331e3f to nil") } if err := b.ConsumeID(MessagesSaveDraftRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.saveDraft#bc39e14b: %w", err) + return fmt.Errorf("unable to decode messages.saveDraft#b4331e3f: %w", err) } return s.DecodeBare(b) } @@ -249,39 +272,46 @@ func (s *MessagesSaveDraftRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *MessagesSaveDraftRequest) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.saveDraft#bc39e14b to nil") + return fmt.Errorf("can't decode messages.saveDraft#b4331e3f to nil") } { if err := s.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.saveDraft#bc39e14b: field flags: %w", err) + return fmt.Errorf("unable to decode messages.saveDraft#b4331e3f: field flags: %w", err) } } s.NoWebpage = s.Flags.Has(1) if s.Flags.Has(0) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.saveDraft#bc39e14b: field reply_to_msg_id: %w", err) + return fmt.Errorf("unable to decode messages.saveDraft#b4331e3f: field reply_to_msg_id: %w", err) } s.ReplyToMsgID = value } + if s.Flags.Has(2) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.saveDraft#b4331e3f: field top_msg_id: %w", err) + } + s.TopMsgID = value + } { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.saveDraft#bc39e14b: field peer: %w", err) + return fmt.Errorf("unable to decode messages.saveDraft#b4331e3f: field peer: %w", err) } s.Peer = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messages.saveDraft#bc39e14b: field message: %w", err) + return fmt.Errorf("unable to decode messages.saveDraft#b4331e3f: field message: %w", err) } s.Message = value } if s.Flags.Has(3) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode messages.saveDraft#bc39e14b: field entities: %w", err) + return fmt.Errorf("unable to decode messages.saveDraft#b4331e3f: field entities: %w", err) } if headerLen > 0 { @@ -290,7 +320,7 @@ func (s *MessagesSaveDraftRequest) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeMessageEntity(b) if err != nil { - return fmt.Errorf("unable to decode messages.saveDraft#bc39e14b: field entities: %w", err) + return fmt.Errorf("unable to decode messages.saveDraft#b4331e3f: field entities: %w", err) } s.Entities = append(s.Entities, value) } @@ -335,6 +365,24 @@ func (s *MessagesSaveDraftRequest) GetReplyToMsgID() (value int, ok bool) { return s.ReplyToMsgID, true } +// SetTopMsgID sets value of TopMsgID conditional field. +func (s *MessagesSaveDraftRequest) SetTopMsgID(value int) { + s.Flags.Set(2) + s.TopMsgID = value +} + +// GetTopMsgID returns value of TopMsgID conditional field and +// boolean which is true if field was set. +func (s *MessagesSaveDraftRequest) GetTopMsgID() (value int, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(2) { + return value, false + } + return s.TopMsgID, true +} + // GetPeer returns value of Peer field. func (s *MessagesSaveDraftRequest) GetPeer() (value InputPeerClass) { if s == nil { @@ -377,7 +425,7 @@ func (s *MessagesSaveDraftRequest) MapEntities() (value MessageEntityClassArray, return MessageEntityClassArray(s.Entities), true } -// MessagesSaveDraft invokes method messages.saveDraft#bc39e14b returning error if any. +// MessagesSaveDraft invokes method messages.saveDraft#b4331e3f returning error if any. // Save a message draft¹ associated to a chat. // // Links: diff --git a/tg/tl_messages_send_inline_bot_result_gen.go b/tg/tl_messages_send_inline_bot_result_gen.go index 79030bc179..3c4a8cd7f9 100644 --- a/tg/tl_messages_send_inline_bot_result_gen.go +++ b/tg/tl_messages_send_inline_bot_result_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesSendInlineBotResultRequest represents TL type `messages.sendInlineBotResult#7aa11297`. +// MessagesSendInlineBotResultRequest represents TL type `messages.sendInlineBotResult#d3fbdccb`. // Send a result obtained using messages.getInlineBotResults¹. // // Links: @@ -66,6 +66,10 @@ type MessagesSendInlineBotResultRequest struct { // // Use SetReplyToMsgID and GetReplyToMsgID helpers. ReplyToMsgID int + // TopMsgID field of MessagesSendInlineBotResultRequest. + // + // Use SetTopMsgID and GetTopMsgID helpers. + TopMsgID int // Random ID to avoid resending the same query RandomID int64 // Query ID from messages.getInlineBotResults¹ @@ -89,7 +93,7 @@ type MessagesSendInlineBotResultRequest struct { } // MessagesSendInlineBotResultRequestTypeID is TL type id of MessagesSendInlineBotResultRequest. -const MessagesSendInlineBotResultRequestTypeID = 0x7aa11297 +const MessagesSendInlineBotResultRequestTypeID = 0xd3fbdccb // Ensuring interfaces in compile-time for MessagesSendInlineBotResultRequest. var ( @@ -124,6 +128,9 @@ func (s *MessagesSendInlineBotResultRequest) Zero() bool { if !(s.ReplyToMsgID == 0) { return false } + if !(s.TopMsgID == 0) { + return false + } if !(s.RandomID == 0) { return false } @@ -160,6 +167,7 @@ func (s *MessagesSendInlineBotResultRequest) FillFrom(from interface { GetHideVia() (value bool) GetPeer() (value InputPeerClass) GetReplyToMsgID() (value int, ok bool) + GetTopMsgID() (value int, ok bool) GetRandomID() (value int64) GetQueryID() (value int64) GetID() (value string) @@ -175,6 +183,10 @@ func (s *MessagesSendInlineBotResultRequest) FillFrom(from interface { s.ReplyToMsgID = val } + if val, ok := from.GetTopMsgID(); ok { + s.TopMsgID = val + } + s.RandomID = from.GetRandomID() s.QueryID = from.GetQueryID() s.ID = from.GetID() @@ -240,6 +252,11 @@ func (s *MessagesSendInlineBotResultRequest) TypeInfo() tdp.Type { SchemaName: "reply_to_msg_id", Null: !s.Flags.Has(0), }, + { + Name: "TopMsgID", + SchemaName: "top_msg_id", + Null: !s.Flags.Has(9), + }, { Name: "RandomID", SchemaName: "random_id", @@ -283,6 +300,9 @@ func (s *MessagesSendInlineBotResultRequest) SetFlags() { if !(s.ReplyToMsgID == 0) { s.Flags.Set(0) } + if !(s.TopMsgID == 0) { + s.Flags.Set(9) + } if !(s.ScheduleDate == 0) { s.Flags.Set(10) } @@ -294,7 +314,7 @@ func (s *MessagesSendInlineBotResultRequest) SetFlags() { // Encode implements bin.Encoder. func (s *MessagesSendInlineBotResultRequest) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.sendInlineBotResult#7aa11297 as nil") + return fmt.Errorf("can't encode messages.sendInlineBotResult#d3fbdccb as nil") } b.PutID(MessagesSendInlineBotResultRequestTypeID) return s.EncodeBare(b) @@ -303,21 +323,24 @@ func (s *MessagesSendInlineBotResultRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *MessagesSendInlineBotResultRequest) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.sendInlineBotResult#7aa11297 as nil") + return fmt.Errorf("can't encode messages.sendInlineBotResult#d3fbdccb as nil") } s.SetFlags() if err := s.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendInlineBotResult#7aa11297: field flags: %w", err) + return fmt.Errorf("unable to encode messages.sendInlineBotResult#d3fbdccb: field flags: %w", err) } if s.Peer == nil { - return fmt.Errorf("unable to encode messages.sendInlineBotResult#7aa11297: field peer is nil") + return fmt.Errorf("unable to encode messages.sendInlineBotResult#d3fbdccb: field peer is nil") } if err := s.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendInlineBotResult#7aa11297: field peer: %w", err) + return fmt.Errorf("unable to encode messages.sendInlineBotResult#d3fbdccb: field peer: %w", err) } if s.Flags.Has(0) { b.PutInt(s.ReplyToMsgID) } + if s.Flags.Has(9) { + b.PutInt(s.TopMsgID) + } b.PutLong(s.RandomID) b.PutLong(s.QueryID) b.PutString(s.ID) @@ -326,10 +349,10 @@ func (s *MessagesSendInlineBotResultRequest) EncodeBare(b *bin.Buffer) error { } if s.Flags.Has(13) { if s.SendAs == nil { - return fmt.Errorf("unable to encode messages.sendInlineBotResult#7aa11297: field send_as is nil") + return fmt.Errorf("unable to encode messages.sendInlineBotResult#d3fbdccb: field send_as is nil") } if err := s.SendAs.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendInlineBotResult#7aa11297: field send_as: %w", err) + return fmt.Errorf("unable to encode messages.sendInlineBotResult#d3fbdccb: field send_as: %w", err) } } return nil @@ -338,10 +361,10 @@ func (s *MessagesSendInlineBotResultRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *MessagesSendInlineBotResultRequest) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.sendInlineBotResult#7aa11297 to nil") + return fmt.Errorf("can't decode messages.sendInlineBotResult#d3fbdccb to nil") } if err := b.ConsumeID(MessagesSendInlineBotResultRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.sendInlineBotResult#7aa11297: %w", err) + return fmt.Errorf("unable to decode messages.sendInlineBotResult#d3fbdccb: %w", err) } return s.DecodeBare(b) } @@ -349,11 +372,11 @@ func (s *MessagesSendInlineBotResultRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *MessagesSendInlineBotResultRequest) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.sendInlineBotResult#7aa11297 to nil") + return fmt.Errorf("can't decode messages.sendInlineBotResult#d3fbdccb to nil") } { if err := s.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.sendInlineBotResult#7aa11297: field flags: %w", err) + return fmt.Errorf("unable to decode messages.sendInlineBotResult#d3fbdccb: field flags: %w", err) } } s.Silent = s.Flags.Has(5) @@ -363,49 +386,56 @@ func (s *MessagesSendInlineBotResultRequest) DecodeBare(b *bin.Buffer) error { { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendInlineBotResult#7aa11297: field peer: %w", err) + return fmt.Errorf("unable to decode messages.sendInlineBotResult#d3fbdccb: field peer: %w", err) } s.Peer = value } if s.Flags.Has(0) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.sendInlineBotResult#7aa11297: field reply_to_msg_id: %w", err) + return fmt.Errorf("unable to decode messages.sendInlineBotResult#d3fbdccb: field reply_to_msg_id: %w", err) } s.ReplyToMsgID = value } + if s.Flags.Has(9) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.sendInlineBotResult#d3fbdccb: field top_msg_id: %w", err) + } + s.TopMsgID = value + } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode messages.sendInlineBotResult#7aa11297: field random_id: %w", err) + return fmt.Errorf("unable to decode messages.sendInlineBotResult#d3fbdccb: field random_id: %w", err) } s.RandomID = value } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode messages.sendInlineBotResult#7aa11297: field query_id: %w", err) + return fmt.Errorf("unable to decode messages.sendInlineBotResult#d3fbdccb: field query_id: %w", err) } s.QueryID = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messages.sendInlineBotResult#7aa11297: field id: %w", err) + return fmt.Errorf("unable to decode messages.sendInlineBotResult#d3fbdccb: field id: %w", err) } s.ID = value } if s.Flags.Has(10) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.sendInlineBotResult#7aa11297: field schedule_date: %w", err) + return fmt.Errorf("unable to decode messages.sendInlineBotResult#d3fbdccb: field schedule_date: %w", err) } s.ScheduleDate = value } if s.Flags.Has(13) { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendInlineBotResult#7aa11297: field send_as: %w", err) + return fmt.Errorf("unable to decode messages.sendInlineBotResult#d3fbdccb: field send_as: %w", err) } s.SendAs = value } @@ -514,6 +544,24 @@ func (s *MessagesSendInlineBotResultRequest) GetReplyToMsgID() (value int, ok bo return s.ReplyToMsgID, true } +// SetTopMsgID sets value of TopMsgID conditional field. +func (s *MessagesSendInlineBotResultRequest) SetTopMsgID(value int) { + s.Flags.Set(9) + s.TopMsgID = value +} + +// GetTopMsgID returns value of TopMsgID conditional field and +// boolean which is true if field was set. +func (s *MessagesSendInlineBotResultRequest) GetTopMsgID() (value int, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(9) { + return value, false + } + return s.TopMsgID, true +} + // GetRandomID returns value of RandomID field. func (s *MessagesSendInlineBotResultRequest) GetRandomID() (value int64) { if s == nil { @@ -574,7 +622,7 @@ func (s *MessagesSendInlineBotResultRequest) GetSendAs() (value InputPeerClass, return s.SendAs, true } -// MessagesSendInlineBotResult invokes method messages.sendInlineBotResult#7aa11297 returning error if any. +// MessagesSendInlineBotResult invokes method messages.sendInlineBotResult#d3fbdccb returning error if any. // Send a result obtained using messages.getInlineBotResults¹. // // Links: diff --git a/tg/tl_messages_send_media_gen.go b/tg/tl_messages_send_media_gen.go index 9951853b92..e32c1bd12e 100644 --- a/tg/tl_messages_send_media_gen.go +++ b/tg/tl_messages_send_media_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesSendMediaRequest represents TL type `messages.sendMedia#e25ff8e0`. +// MessagesSendMediaRequest represents TL type `messages.sendMedia#7547c966`. // Send a media // // See https://core.telegram.org/method/messages.sendMedia for reference. @@ -61,6 +61,10 @@ type MessagesSendMediaRequest struct { // // Use SetReplyToMsgID and GetReplyToMsgID helpers. ReplyToMsgID int + // TopMsgID field of MessagesSendMediaRequest. + // + // Use SetTopMsgID and GetTopMsgID helpers. + TopMsgID int // Attached media Media InputMediaClass // Caption @@ -92,7 +96,7 @@ type MessagesSendMediaRequest struct { } // MessagesSendMediaRequestTypeID is TL type id of MessagesSendMediaRequest. -const MessagesSendMediaRequestTypeID = 0xe25ff8e0 +const MessagesSendMediaRequestTypeID = 0x7547c966 // Ensuring interfaces in compile-time for MessagesSendMediaRequest. var ( @@ -130,6 +134,9 @@ func (s *MessagesSendMediaRequest) Zero() bool { if !(s.ReplyToMsgID == 0) { return false } + if !(s.TopMsgID == 0) { + return false + } if !(s.Media == nil) { return false } @@ -173,6 +180,7 @@ func (s *MessagesSendMediaRequest) FillFrom(from interface { GetUpdateStickersetsOrder() (value bool) GetPeer() (value InputPeerClass) GetReplyToMsgID() (value int, ok bool) + GetTopMsgID() (value int, ok bool) GetMedia() (value InputMediaClass) GetMessage() (value string) GetRandomID() (value int64) @@ -191,6 +199,10 @@ func (s *MessagesSendMediaRequest) FillFrom(from interface { s.ReplyToMsgID = val } + if val, ok := from.GetTopMsgID(); ok { + s.TopMsgID = val + } + s.Media = from.GetMedia() s.Message = from.GetMessage() s.RandomID = from.GetRandomID() @@ -269,6 +281,11 @@ func (s *MessagesSendMediaRequest) TypeInfo() tdp.Type { SchemaName: "reply_to_msg_id", Null: !s.Flags.Has(0), }, + { + Name: "TopMsgID", + SchemaName: "top_msg_id", + Null: !s.Flags.Has(9), + }, { Name: "Media", SchemaName: "media", @@ -325,6 +342,9 @@ func (s *MessagesSendMediaRequest) SetFlags() { if !(s.ReplyToMsgID == 0) { s.Flags.Set(0) } + if !(s.TopMsgID == 0) { + s.Flags.Set(9) + } if !(s.ReplyMarkup == nil) { s.Flags.Set(2) } @@ -342,7 +362,7 @@ func (s *MessagesSendMediaRequest) SetFlags() { // Encode implements bin.Encoder. func (s *MessagesSendMediaRequest) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.sendMedia#e25ff8e0 as nil") + return fmt.Errorf("can't encode messages.sendMedia#7547c966 as nil") } b.PutID(MessagesSendMediaRequestTypeID) return s.EncodeBare(b) @@ -351,45 +371,48 @@ func (s *MessagesSendMediaRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *MessagesSendMediaRequest) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.sendMedia#e25ff8e0 as nil") + return fmt.Errorf("can't encode messages.sendMedia#7547c966 as nil") } s.SetFlags() if err := s.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMedia#e25ff8e0: field flags: %w", err) + return fmt.Errorf("unable to encode messages.sendMedia#7547c966: field flags: %w", err) } if s.Peer == nil { - return fmt.Errorf("unable to encode messages.sendMedia#e25ff8e0: field peer is nil") + return fmt.Errorf("unable to encode messages.sendMedia#7547c966: field peer is nil") } if err := s.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMedia#e25ff8e0: field peer: %w", err) + return fmt.Errorf("unable to encode messages.sendMedia#7547c966: field peer: %w", err) } if s.Flags.Has(0) { b.PutInt(s.ReplyToMsgID) } + if s.Flags.Has(9) { + b.PutInt(s.TopMsgID) + } if s.Media == nil { - return fmt.Errorf("unable to encode messages.sendMedia#e25ff8e0: field media is nil") + return fmt.Errorf("unable to encode messages.sendMedia#7547c966: field media is nil") } if err := s.Media.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMedia#e25ff8e0: field media: %w", err) + return fmt.Errorf("unable to encode messages.sendMedia#7547c966: field media: %w", err) } b.PutString(s.Message) b.PutLong(s.RandomID) if s.Flags.Has(2) { if s.ReplyMarkup == nil { - return fmt.Errorf("unable to encode messages.sendMedia#e25ff8e0: field reply_markup is nil") + return fmt.Errorf("unable to encode messages.sendMedia#7547c966: field reply_markup is nil") } if err := s.ReplyMarkup.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMedia#e25ff8e0: field reply_markup: %w", err) + return fmt.Errorf("unable to encode messages.sendMedia#7547c966: field reply_markup: %w", err) } } if s.Flags.Has(3) { b.PutVectorHeader(len(s.Entities)) for idx, v := range s.Entities { if v == nil { - return fmt.Errorf("unable to encode messages.sendMedia#e25ff8e0: field entities element with index %d is nil", idx) + return fmt.Errorf("unable to encode messages.sendMedia#7547c966: field entities element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMedia#e25ff8e0: field entities element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode messages.sendMedia#7547c966: field entities element with index %d: %w", idx, err) } } } @@ -398,10 +421,10 @@ func (s *MessagesSendMediaRequest) EncodeBare(b *bin.Buffer) error { } if s.Flags.Has(13) { if s.SendAs == nil { - return fmt.Errorf("unable to encode messages.sendMedia#e25ff8e0: field send_as is nil") + return fmt.Errorf("unable to encode messages.sendMedia#7547c966: field send_as is nil") } if err := s.SendAs.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMedia#e25ff8e0: field send_as: %w", err) + return fmt.Errorf("unable to encode messages.sendMedia#7547c966: field send_as: %w", err) } } return nil @@ -410,10 +433,10 @@ func (s *MessagesSendMediaRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *MessagesSendMediaRequest) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.sendMedia#e25ff8e0 to nil") + return fmt.Errorf("can't decode messages.sendMedia#7547c966 to nil") } if err := b.ConsumeID(MessagesSendMediaRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#e25ff8e0: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7547c966: %w", err) } return s.DecodeBare(b) } @@ -421,11 +444,11 @@ func (s *MessagesSendMediaRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *MessagesSendMediaRequest) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.sendMedia#e25ff8e0 to nil") + return fmt.Errorf("can't decode messages.sendMedia#7547c966 to nil") } { if err := s.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#e25ff8e0: field flags: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7547c966: field flags: %w", err) } } s.Silent = s.Flags.Has(5) @@ -436,49 +459,56 @@ func (s *MessagesSendMediaRequest) DecodeBare(b *bin.Buffer) error { { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#e25ff8e0: field peer: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7547c966: field peer: %w", err) } s.Peer = value } if s.Flags.Has(0) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#e25ff8e0: field reply_to_msg_id: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7547c966: field reply_to_msg_id: %w", err) } s.ReplyToMsgID = value } + if s.Flags.Has(9) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.sendMedia#7547c966: field top_msg_id: %w", err) + } + s.TopMsgID = value + } { value, err := DecodeInputMedia(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#e25ff8e0: field media: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7547c966: field media: %w", err) } s.Media = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#e25ff8e0: field message: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7547c966: field message: %w", err) } s.Message = value } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#e25ff8e0: field random_id: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7547c966: field random_id: %w", err) } s.RandomID = value } if s.Flags.Has(2) { value, err := DecodeReplyMarkup(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#e25ff8e0: field reply_markup: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7547c966: field reply_markup: %w", err) } s.ReplyMarkup = value } if s.Flags.Has(3) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#e25ff8e0: field entities: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7547c966: field entities: %w", err) } if headerLen > 0 { @@ -487,7 +517,7 @@ func (s *MessagesSendMediaRequest) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeMessageEntity(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#e25ff8e0: field entities: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7547c966: field entities: %w", err) } s.Entities = append(s.Entities, value) } @@ -495,14 +525,14 @@ func (s *MessagesSendMediaRequest) DecodeBare(b *bin.Buffer) error { if s.Flags.Has(10) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#e25ff8e0: field schedule_date: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7547c966: field schedule_date: %w", err) } s.ScheduleDate = value } if s.Flags.Has(13) { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMedia#e25ff8e0: field send_as: %w", err) + return fmt.Errorf("unable to decode messages.sendMedia#7547c966: field send_as: %w", err) } s.SendAs = value } @@ -630,6 +660,24 @@ func (s *MessagesSendMediaRequest) GetReplyToMsgID() (value int, ok bool) { return s.ReplyToMsgID, true } +// SetTopMsgID sets value of TopMsgID conditional field. +func (s *MessagesSendMediaRequest) SetTopMsgID(value int) { + s.Flags.Set(9) + s.TopMsgID = value +} + +// GetTopMsgID returns value of TopMsgID conditional field and +// boolean which is true if field was set. +func (s *MessagesSendMediaRequest) GetTopMsgID() (value int, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(9) { + return value, false + } + return s.TopMsgID, true +} + // GetMedia returns value of Media field. func (s *MessagesSendMediaRequest) GetMedia() (value InputMediaClass) { if s == nil { @@ -734,7 +782,7 @@ func (s *MessagesSendMediaRequest) MapEntities() (value MessageEntityClassArray, return MessageEntityClassArray(s.Entities), true } -// MessagesSendMedia invokes method messages.sendMedia#e25ff8e0 returning error if any. +// MessagesSendMedia invokes method messages.sendMedia#7547c966 returning error if any. // Send a media // // Possible errors: diff --git a/tg/tl_messages_send_message_gen.go b/tg/tl_messages_send_message_gen.go index aa9401c37d..51db4b2451 100644 --- a/tg/tl_messages_send_message_gen.go +++ b/tg/tl_messages_send_message_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesSendMessageRequest represents TL type `messages.sendMessage#d9d75a4`. +// MessagesSendMessageRequest represents TL type `messages.sendMessage#1cc20387`. // Sends a message to a chat // // See https://core.telegram.org/method/messages.sendMessage for reference. @@ -63,6 +63,10 @@ type MessagesSendMessageRequest struct { // // Use SetReplyToMsgID and GetReplyToMsgID helpers. ReplyToMsgID int + // TopMsgID field of MessagesSendMessageRequest. + // + // Use SetTopMsgID and GetTopMsgID helpers. + TopMsgID int // The message Message string // Unique client message ID required to prevent message resending @@ -92,7 +96,7 @@ type MessagesSendMessageRequest struct { } // MessagesSendMessageRequestTypeID is TL type id of MessagesSendMessageRequest. -const MessagesSendMessageRequestTypeID = 0xd9d75a4 +const MessagesSendMessageRequestTypeID = 0x1cc20387 // Ensuring interfaces in compile-time for MessagesSendMessageRequest. var ( @@ -133,6 +137,9 @@ func (s *MessagesSendMessageRequest) Zero() bool { if !(s.ReplyToMsgID == 0) { return false } + if !(s.TopMsgID == 0) { + return false + } if !(s.Message == "") { return false } @@ -174,6 +181,7 @@ func (s *MessagesSendMessageRequest) FillFrom(from interface { GetUpdateStickersetsOrder() (value bool) GetPeer() (value InputPeerClass) GetReplyToMsgID() (value int, ok bool) + GetTopMsgID() (value int, ok bool) GetMessage() (value string) GetRandomID() (value int64) GetReplyMarkup() (value ReplyMarkupClass, ok bool) @@ -192,6 +200,10 @@ func (s *MessagesSendMessageRequest) FillFrom(from interface { s.ReplyToMsgID = val } + if val, ok := from.GetTopMsgID(); ok { + s.TopMsgID = val + } + s.Message = from.GetMessage() s.RandomID = from.GetRandomID() if val, ok := from.GetReplyMarkup(); ok { @@ -274,6 +286,11 @@ func (s *MessagesSendMessageRequest) TypeInfo() tdp.Type { SchemaName: "reply_to_msg_id", Null: !s.Flags.Has(0), }, + { + Name: "TopMsgID", + SchemaName: "top_msg_id", + Null: !s.Flags.Has(9), + }, { Name: "Message", SchemaName: "message", @@ -329,6 +346,9 @@ func (s *MessagesSendMessageRequest) SetFlags() { if !(s.ReplyToMsgID == 0) { s.Flags.Set(0) } + if !(s.TopMsgID == 0) { + s.Flags.Set(9) + } if !(s.ReplyMarkup == nil) { s.Flags.Set(2) } @@ -346,7 +366,7 @@ func (s *MessagesSendMessageRequest) SetFlags() { // Encode implements bin.Encoder. func (s *MessagesSendMessageRequest) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.sendMessage#d9d75a4 as nil") + return fmt.Errorf("can't encode messages.sendMessage#1cc20387 as nil") } b.PutID(MessagesSendMessageRequestTypeID) return s.EncodeBare(b) @@ -355,39 +375,42 @@ func (s *MessagesSendMessageRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *MessagesSendMessageRequest) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.sendMessage#d9d75a4 as nil") + return fmt.Errorf("can't encode messages.sendMessage#1cc20387 as nil") } s.SetFlags() if err := s.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMessage#d9d75a4: field flags: %w", err) + return fmt.Errorf("unable to encode messages.sendMessage#1cc20387: field flags: %w", err) } if s.Peer == nil { - return fmt.Errorf("unable to encode messages.sendMessage#d9d75a4: field peer is nil") + return fmt.Errorf("unable to encode messages.sendMessage#1cc20387: field peer is nil") } if err := s.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMessage#d9d75a4: field peer: %w", err) + return fmt.Errorf("unable to encode messages.sendMessage#1cc20387: field peer: %w", err) } if s.Flags.Has(0) { b.PutInt(s.ReplyToMsgID) } + if s.Flags.Has(9) { + b.PutInt(s.TopMsgID) + } b.PutString(s.Message) b.PutLong(s.RandomID) if s.Flags.Has(2) { if s.ReplyMarkup == nil { - return fmt.Errorf("unable to encode messages.sendMessage#d9d75a4: field reply_markup is nil") + return fmt.Errorf("unable to encode messages.sendMessage#1cc20387: field reply_markup is nil") } if err := s.ReplyMarkup.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMessage#d9d75a4: field reply_markup: %w", err) + return fmt.Errorf("unable to encode messages.sendMessage#1cc20387: field reply_markup: %w", err) } } if s.Flags.Has(3) { b.PutVectorHeader(len(s.Entities)) for idx, v := range s.Entities { if v == nil { - return fmt.Errorf("unable to encode messages.sendMessage#d9d75a4: field entities element with index %d is nil", idx) + return fmt.Errorf("unable to encode messages.sendMessage#1cc20387: field entities element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMessage#d9d75a4: field entities element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode messages.sendMessage#1cc20387: field entities element with index %d: %w", idx, err) } } } @@ -396,10 +419,10 @@ func (s *MessagesSendMessageRequest) EncodeBare(b *bin.Buffer) error { } if s.Flags.Has(13) { if s.SendAs == nil { - return fmt.Errorf("unable to encode messages.sendMessage#d9d75a4: field send_as is nil") + return fmt.Errorf("unable to encode messages.sendMessage#1cc20387: field send_as is nil") } if err := s.SendAs.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMessage#d9d75a4: field send_as: %w", err) + return fmt.Errorf("unable to encode messages.sendMessage#1cc20387: field send_as: %w", err) } } return nil @@ -408,10 +431,10 @@ func (s *MessagesSendMessageRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *MessagesSendMessageRequest) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.sendMessage#d9d75a4 to nil") + return fmt.Errorf("can't decode messages.sendMessage#1cc20387 to nil") } if err := b.ConsumeID(MessagesSendMessageRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.sendMessage#d9d75a4: %w", err) + return fmt.Errorf("unable to decode messages.sendMessage#1cc20387: %w", err) } return s.DecodeBare(b) } @@ -419,11 +442,11 @@ func (s *MessagesSendMessageRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *MessagesSendMessageRequest) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.sendMessage#d9d75a4 to nil") + return fmt.Errorf("can't decode messages.sendMessage#1cc20387 to nil") } { if err := s.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.sendMessage#d9d75a4: field flags: %w", err) + return fmt.Errorf("unable to decode messages.sendMessage#1cc20387: field flags: %w", err) } } s.NoWebpage = s.Flags.Has(1) @@ -435,42 +458,49 @@ func (s *MessagesSendMessageRequest) DecodeBare(b *bin.Buffer) error { { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMessage#d9d75a4: field peer: %w", err) + return fmt.Errorf("unable to decode messages.sendMessage#1cc20387: field peer: %w", err) } s.Peer = value } if s.Flags.Has(0) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.sendMessage#d9d75a4: field reply_to_msg_id: %w", err) + return fmt.Errorf("unable to decode messages.sendMessage#1cc20387: field reply_to_msg_id: %w", err) } s.ReplyToMsgID = value } + if s.Flags.Has(9) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.sendMessage#1cc20387: field top_msg_id: %w", err) + } + s.TopMsgID = value + } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messages.sendMessage#d9d75a4: field message: %w", err) + return fmt.Errorf("unable to decode messages.sendMessage#1cc20387: field message: %w", err) } s.Message = value } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode messages.sendMessage#d9d75a4: field random_id: %w", err) + return fmt.Errorf("unable to decode messages.sendMessage#1cc20387: field random_id: %w", err) } s.RandomID = value } if s.Flags.Has(2) { value, err := DecodeReplyMarkup(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMessage#d9d75a4: field reply_markup: %w", err) + return fmt.Errorf("unable to decode messages.sendMessage#1cc20387: field reply_markup: %w", err) } s.ReplyMarkup = value } if s.Flags.Has(3) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode messages.sendMessage#d9d75a4: field entities: %w", err) + return fmt.Errorf("unable to decode messages.sendMessage#1cc20387: field entities: %w", err) } if headerLen > 0 { @@ -479,7 +509,7 @@ func (s *MessagesSendMessageRequest) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeMessageEntity(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMessage#d9d75a4: field entities: %w", err) + return fmt.Errorf("unable to decode messages.sendMessage#1cc20387: field entities: %w", err) } s.Entities = append(s.Entities, value) } @@ -487,14 +517,14 @@ func (s *MessagesSendMessageRequest) DecodeBare(b *bin.Buffer) error { if s.Flags.Has(10) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.sendMessage#d9d75a4: field schedule_date: %w", err) + return fmt.Errorf("unable to decode messages.sendMessage#1cc20387: field schedule_date: %w", err) } s.ScheduleDate = value } if s.Flags.Has(13) { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMessage#d9d75a4: field send_as: %w", err) + return fmt.Errorf("unable to decode messages.sendMessage#1cc20387: field send_as: %w", err) } s.SendAs = value } @@ -641,6 +671,24 @@ func (s *MessagesSendMessageRequest) GetReplyToMsgID() (value int, ok bool) { return s.ReplyToMsgID, true } +// SetTopMsgID sets value of TopMsgID conditional field. +func (s *MessagesSendMessageRequest) SetTopMsgID(value int) { + s.Flags.Set(9) + s.TopMsgID = value +} + +// GetTopMsgID returns value of TopMsgID conditional field and +// boolean which is true if field was set. +func (s *MessagesSendMessageRequest) GetTopMsgID() (value int, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(9) { + return value, false + } + return s.TopMsgID, true +} + // GetMessage returns value of Message field. func (s *MessagesSendMessageRequest) GetMessage() (value string) { if s == nil { @@ -737,7 +785,7 @@ func (s *MessagesSendMessageRequest) MapEntities() (value MessageEntityClassArra return MessageEntityClassArray(s.Entities), true } -// MessagesSendMessage invokes method messages.sendMessage#d9d75a4 returning error if any. +// MessagesSendMessage invokes method messages.sendMessage#1cc20387 returning error if any. // Sends a message to a chat // // Possible errors: diff --git a/tg/tl_messages_send_multi_media_gen.go b/tg/tl_messages_send_multi_media_gen.go index ae3adf238d..9b2e737951 100644 --- a/tg/tl_messages_send_multi_media_gen.go +++ b/tg/tl_messages_send_multi_media_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesSendMultiMediaRequest represents TL type `messages.sendMultiMedia#f803138f`. +// MessagesSendMultiMediaRequest represents TL type `messages.sendMultiMedia#b6f11a1c`. // Send an album or grouped media¹ // // Links: @@ -67,6 +67,10 @@ type MessagesSendMultiMediaRequest struct { // // Use SetReplyToMsgID and GetReplyToMsgID helpers. ReplyToMsgID int + // TopMsgID field of MessagesSendMultiMediaRequest. + // + // Use SetTopMsgID and GetTopMsgID helpers. + TopMsgID int // The medias to send MultiMedia []InputSingleMedia // Scheduled message date for scheduled messages @@ -80,7 +84,7 @@ type MessagesSendMultiMediaRequest struct { } // MessagesSendMultiMediaRequestTypeID is TL type id of MessagesSendMultiMediaRequest. -const MessagesSendMultiMediaRequestTypeID = 0xf803138f +const MessagesSendMultiMediaRequestTypeID = 0xb6f11a1c // Ensuring interfaces in compile-time for MessagesSendMultiMediaRequest. var ( @@ -118,6 +122,9 @@ func (s *MessagesSendMultiMediaRequest) Zero() bool { if !(s.ReplyToMsgID == 0) { return false } + if !(s.TopMsgID == 0) { + return false + } if !(s.MultiMedia == nil) { return false } @@ -149,6 +156,7 @@ func (s *MessagesSendMultiMediaRequest) FillFrom(from interface { GetUpdateStickersetsOrder() (value bool) GetPeer() (value InputPeerClass) GetReplyToMsgID() (value int, ok bool) + GetTopMsgID() (value int, ok bool) GetMultiMedia() (value []InputSingleMedia) GetScheduleDate() (value int, ok bool) GetSendAs() (value InputPeerClass, ok bool) @@ -163,6 +171,10 @@ func (s *MessagesSendMultiMediaRequest) FillFrom(from interface { s.ReplyToMsgID = val } + if val, ok := from.GetTopMsgID(); ok { + s.TopMsgID = val + } + s.MultiMedia = from.GetMultiMedia() if val, ok := from.GetScheduleDate(); ok { s.ScheduleDate = val @@ -231,6 +243,11 @@ func (s *MessagesSendMultiMediaRequest) TypeInfo() tdp.Type { SchemaName: "reply_to_msg_id", Null: !s.Flags.Has(0), }, + { + Name: "TopMsgID", + SchemaName: "top_msg_id", + Null: !s.Flags.Has(9), + }, { Name: "MultiMedia", SchemaName: "multi_media", @@ -269,6 +286,9 @@ func (s *MessagesSendMultiMediaRequest) SetFlags() { if !(s.ReplyToMsgID == 0) { s.Flags.Set(0) } + if !(s.TopMsgID == 0) { + s.Flags.Set(9) + } if !(s.ScheduleDate == 0) { s.Flags.Set(10) } @@ -280,7 +300,7 @@ func (s *MessagesSendMultiMediaRequest) SetFlags() { // Encode implements bin.Encoder. func (s *MessagesSendMultiMediaRequest) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.sendMultiMedia#f803138f as nil") + return fmt.Errorf("can't encode messages.sendMultiMedia#b6f11a1c as nil") } b.PutID(MessagesSendMultiMediaRequestTypeID) return s.EncodeBare(b) @@ -289,25 +309,28 @@ func (s *MessagesSendMultiMediaRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *MessagesSendMultiMediaRequest) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.sendMultiMedia#f803138f as nil") + return fmt.Errorf("can't encode messages.sendMultiMedia#b6f11a1c as nil") } s.SetFlags() if err := s.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMultiMedia#f803138f: field flags: %w", err) + return fmt.Errorf("unable to encode messages.sendMultiMedia#b6f11a1c: field flags: %w", err) } if s.Peer == nil { - return fmt.Errorf("unable to encode messages.sendMultiMedia#f803138f: field peer is nil") + return fmt.Errorf("unable to encode messages.sendMultiMedia#b6f11a1c: field peer is nil") } if err := s.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMultiMedia#f803138f: field peer: %w", err) + return fmt.Errorf("unable to encode messages.sendMultiMedia#b6f11a1c: field peer: %w", err) } if s.Flags.Has(0) { b.PutInt(s.ReplyToMsgID) } + if s.Flags.Has(9) { + b.PutInt(s.TopMsgID) + } b.PutVectorHeader(len(s.MultiMedia)) for idx, v := range s.MultiMedia { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMultiMedia#f803138f: field multi_media element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode messages.sendMultiMedia#b6f11a1c: field multi_media element with index %d: %w", idx, err) } } if s.Flags.Has(10) { @@ -315,10 +338,10 @@ func (s *MessagesSendMultiMediaRequest) EncodeBare(b *bin.Buffer) error { } if s.Flags.Has(13) { if s.SendAs == nil { - return fmt.Errorf("unable to encode messages.sendMultiMedia#f803138f: field send_as is nil") + return fmt.Errorf("unable to encode messages.sendMultiMedia#b6f11a1c: field send_as is nil") } if err := s.SendAs.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sendMultiMedia#f803138f: field send_as: %w", err) + return fmt.Errorf("unable to encode messages.sendMultiMedia#b6f11a1c: field send_as: %w", err) } } return nil @@ -327,10 +350,10 @@ func (s *MessagesSendMultiMediaRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *MessagesSendMultiMediaRequest) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.sendMultiMedia#f803138f to nil") + return fmt.Errorf("can't decode messages.sendMultiMedia#b6f11a1c to nil") } if err := b.ConsumeID(MessagesSendMultiMediaRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.sendMultiMedia#f803138f: %w", err) + return fmt.Errorf("unable to decode messages.sendMultiMedia#b6f11a1c: %w", err) } return s.DecodeBare(b) } @@ -338,11 +361,11 @@ func (s *MessagesSendMultiMediaRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *MessagesSendMultiMediaRequest) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.sendMultiMedia#f803138f to nil") + return fmt.Errorf("can't decode messages.sendMultiMedia#b6f11a1c to nil") } { if err := s.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.sendMultiMedia#f803138f: field flags: %w", err) + return fmt.Errorf("unable to decode messages.sendMultiMedia#b6f11a1c: field flags: %w", err) } } s.Silent = s.Flags.Has(5) @@ -353,21 +376,28 @@ func (s *MessagesSendMultiMediaRequest) DecodeBare(b *bin.Buffer) error { { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMultiMedia#f803138f: field peer: %w", err) + return fmt.Errorf("unable to decode messages.sendMultiMedia#b6f11a1c: field peer: %w", err) } s.Peer = value } if s.Flags.Has(0) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.sendMultiMedia#f803138f: field reply_to_msg_id: %w", err) + return fmt.Errorf("unable to decode messages.sendMultiMedia#b6f11a1c: field reply_to_msg_id: %w", err) } s.ReplyToMsgID = value } + if s.Flags.Has(9) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.sendMultiMedia#b6f11a1c: field top_msg_id: %w", err) + } + s.TopMsgID = value + } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode messages.sendMultiMedia#f803138f: field multi_media: %w", err) + return fmt.Errorf("unable to decode messages.sendMultiMedia#b6f11a1c: field multi_media: %w", err) } if headerLen > 0 { @@ -376,7 +406,7 @@ func (s *MessagesSendMultiMediaRequest) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value InputSingleMedia if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.sendMultiMedia#f803138f: field multi_media: %w", err) + return fmt.Errorf("unable to decode messages.sendMultiMedia#b6f11a1c: field multi_media: %w", err) } s.MultiMedia = append(s.MultiMedia, value) } @@ -384,14 +414,14 @@ func (s *MessagesSendMultiMediaRequest) DecodeBare(b *bin.Buffer) error { if s.Flags.Has(10) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.sendMultiMedia#f803138f: field schedule_date: %w", err) + return fmt.Errorf("unable to decode messages.sendMultiMedia#b6f11a1c: field schedule_date: %w", err) } s.ScheduleDate = value } if s.Flags.Has(13) { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.sendMultiMedia#f803138f: field send_as: %w", err) + return fmt.Errorf("unable to decode messages.sendMultiMedia#b6f11a1c: field send_as: %w", err) } s.SendAs = value } @@ -519,6 +549,24 @@ func (s *MessagesSendMultiMediaRequest) GetReplyToMsgID() (value int, ok bool) { return s.ReplyToMsgID, true } +// SetTopMsgID sets value of TopMsgID conditional field. +func (s *MessagesSendMultiMediaRequest) SetTopMsgID(value int) { + s.Flags.Set(9) + s.TopMsgID = value +} + +// GetTopMsgID returns value of TopMsgID conditional field and +// boolean which is true if field was set. +func (s *MessagesSendMultiMediaRequest) GetTopMsgID() (value int, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(9) { + return value, false + } + return s.TopMsgID, true +} + // GetMultiMedia returns value of MultiMedia field. func (s *MessagesSendMultiMediaRequest) GetMultiMedia() (value []InputSingleMedia) { if s == nil { @@ -563,7 +611,7 @@ func (s *MessagesSendMultiMediaRequest) GetSendAs() (value InputPeerClass, ok bo return s.SendAs, true } -// MessagesSendMultiMedia invokes method messages.sendMultiMedia#f803138f returning error if any. +// MessagesSendMultiMedia invokes method messages.sendMultiMedia#b6f11a1c returning error if any. // Send an album or grouped media¹ // // Links: diff --git a/tg/tl_messages_sponsored_messages_gen.go b/tg/tl_messages_sponsored_messages_gen.go index 007935f743..945dbd954f 100644 --- a/tg/tl_messages_sponsored_messages_gen.go +++ b/tg/tl_messages_sponsored_messages_gen.go @@ -31,11 +31,17 @@ var ( _ = tdjson.Encoder{} ) -// MessagesSponsoredMessages represents TL type `messages.sponsoredMessages#65a4c7d5`. +// MessagesSponsoredMessages represents TL type `messages.sponsoredMessages#c9ee1d87`. // A set of sponsored messages associated to a channel // // See https://core.telegram.org/constructor/messages.sponsoredMessages for reference. type MessagesSponsoredMessages struct { + // Flags field of MessagesSponsoredMessages. + Flags bin.Fields + // PostsBetween field of MessagesSponsoredMessages. + // + // Use SetPostsBetween and GetPostsBetween helpers. + PostsBetween int // Sponsored messages Messages []SponsoredMessage // Chats mentioned in the sponsored messages @@ -45,7 +51,10 @@ type MessagesSponsoredMessages struct { } // MessagesSponsoredMessagesTypeID is TL type id of MessagesSponsoredMessages. -const MessagesSponsoredMessagesTypeID = 0x65a4c7d5 +const MessagesSponsoredMessagesTypeID = 0xc9ee1d87 + +// construct implements constructor of MessagesSponsoredMessagesClass. +func (s MessagesSponsoredMessages) construct() MessagesSponsoredMessagesClass { return &s } // Ensuring interfaces in compile-time for MessagesSponsoredMessages. var ( @@ -53,12 +62,20 @@ var ( _ bin.Decoder = &MessagesSponsoredMessages{} _ bin.BareEncoder = &MessagesSponsoredMessages{} _ bin.BareDecoder = &MessagesSponsoredMessages{} + + _ MessagesSponsoredMessagesClass = &MessagesSponsoredMessages{} ) func (s *MessagesSponsoredMessages) Zero() bool { if s == nil { return true } + if !(s.Flags.Zero()) { + return false + } + if !(s.PostsBetween == 0) { + return false + } if !(s.Messages == nil) { return false } @@ -83,10 +100,15 @@ func (s *MessagesSponsoredMessages) String() string { // FillFrom fills MessagesSponsoredMessages from given interface. func (s *MessagesSponsoredMessages) FillFrom(from interface { + GetPostsBetween() (value int, ok bool) GetMessages() (value []SponsoredMessage) GetChats() (value []ChatClass) GetUsers() (value []UserClass) }) { + if val, ok := from.GetPostsBetween(); ok { + s.PostsBetween = val + } + s.Messages = from.GetMessages() s.Chats = from.GetChats() s.Users = from.GetUsers() @@ -115,6 +137,11 @@ func (s *MessagesSponsoredMessages) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "PostsBetween", + SchemaName: "posts_between", + Null: !s.Flags.Has(0), + }, { Name: "Messages", SchemaName: "messages", @@ -131,10 +158,17 @@ func (s *MessagesSponsoredMessages) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (s *MessagesSponsoredMessages) SetFlags() { + if !(s.PostsBetween == 0) { + s.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (s *MessagesSponsoredMessages) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.sponsoredMessages#65a4c7d5 as nil") + return fmt.Errorf("can't encode messages.sponsoredMessages#c9ee1d87 as nil") } b.PutID(MessagesSponsoredMessagesTypeID) return s.EncodeBare(b) @@ -143,30 +177,37 @@ func (s *MessagesSponsoredMessages) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *MessagesSponsoredMessages) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.sponsoredMessages#65a4c7d5 as nil") + return fmt.Errorf("can't encode messages.sponsoredMessages#c9ee1d87 as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.sponsoredMessages#c9ee1d87: field flags: %w", err) + } + if s.Flags.Has(0) { + b.PutInt(s.PostsBetween) } b.PutVectorHeader(len(s.Messages)) for idx, v := range s.Messages { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sponsoredMessages#65a4c7d5: field messages element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode messages.sponsoredMessages#c9ee1d87: field messages element with index %d: %w", idx, err) } } b.PutVectorHeader(len(s.Chats)) for idx, v := range s.Chats { if v == nil { - return fmt.Errorf("unable to encode messages.sponsoredMessages#65a4c7d5: field chats element with index %d is nil", idx) + return fmt.Errorf("unable to encode messages.sponsoredMessages#c9ee1d87: field chats element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sponsoredMessages#65a4c7d5: field chats element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode messages.sponsoredMessages#c9ee1d87: 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 messages.sponsoredMessages#65a4c7d5: field users element with index %d is nil", idx) + return fmt.Errorf("unable to encode messages.sponsoredMessages#c9ee1d87: field users element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.sponsoredMessages#65a4c7d5: field users element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode messages.sponsoredMessages#c9ee1d87: field users element with index %d: %w", idx, err) } } return nil @@ -175,10 +216,10 @@ func (s *MessagesSponsoredMessages) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *MessagesSponsoredMessages) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.sponsoredMessages#65a4c7d5 to nil") + return fmt.Errorf("can't decode messages.sponsoredMessages#c9ee1d87 to nil") } if err := b.ConsumeID(MessagesSponsoredMessagesTypeID); err != nil { - return fmt.Errorf("unable to decode messages.sponsoredMessages#65a4c7d5: %w", err) + return fmt.Errorf("unable to decode messages.sponsoredMessages#c9ee1d87: %w", err) } return s.DecodeBare(b) } @@ -186,12 +227,24 @@ func (s *MessagesSponsoredMessages) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *MessagesSponsoredMessages) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.sponsoredMessages#65a4c7d5 to nil") + return fmt.Errorf("can't decode messages.sponsoredMessages#c9ee1d87 to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.sponsoredMessages#c9ee1d87: field flags: %w", err) + } + } + if s.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.sponsoredMessages#c9ee1d87: field posts_between: %w", err) + } + s.PostsBetween = value } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode messages.sponsoredMessages#65a4c7d5: field messages: %w", err) + return fmt.Errorf("unable to decode messages.sponsoredMessages#c9ee1d87: field messages: %w", err) } if headerLen > 0 { @@ -200,7 +253,7 @@ func (s *MessagesSponsoredMessages) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value SponsoredMessage if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.sponsoredMessages#65a4c7d5: field messages: %w", err) + return fmt.Errorf("unable to decode messages.sponsoredMessages#c9ee1d87: field messages: %w", err) } s.Messages = append(s.Messages, value) } @@ -208,7 +261,7 @@ func (s *MessagesSponsoredMessages) DecodeBare(b *bin.Buffer) error { { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode messages.sponsoredMessages#65a4c7d5: field chats: %w", err) + return fmt.Errorf("unable to decode messages.sponsoredMessages#c9ee1d87: field chats: %w", err) } if headerLen > 0 { @@ -217,7 +270,7 @@ func (s *MessagesSponsoredMessages) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeChat(b) if err != nil { - return fmt.Errorf("unable to decode messages.sponsoredMessages#65a4c7d5: field chats: %w", err) + return fmt.Errorf("unable to decode messages.sponsoredMessages#c9ee1d87: field chats: %w", err) } s.Chats = append(s.Chats, value) } @@ -225,7 +278,7 @@ func (s *MessagesSponsoredMessages) DecodeBare(b *bin.Buffer) error { { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode messages.sponsoredMessages#65a4c7d5: field users: %w", err) + return fmt.Errorf("unable to decode messages.sponsoredMessages#c9ee1d87: field users: %w", err) } if headerLen > 0 { @@ -234,7 +287,7 @@ func (s *MessagesSponsoredMessages) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeUser(b) if err != nil { - return fmt.Errorf("unable to decode messages.sponsoredMessages#65a4c7d5: field users: %w", err) + return fmt.Errorf("unable to decode messages.sponsoredMessages#c9ee1d87: field users: %w", err) } s.Users = append(s.Users, value) } @@ -242,6 +295,24 @@ func (s *MessagesSponsoredMessages) DecodeBare(b *bin.Buffer) error { return nil } +// SetPostsBetween sets value of PostsBetween conditional field. +func (s *MessagesSponsoredMessages) SetPostsBetween(value int) { + s.Flags.Set(0) + s.PostsBetween = value +} + +// GetPostsBetween returns value of PostsBetween conditional field and +// boolean which is true if field was set. +func (s *MessagesSponsoredMessages) GetPostsBetween() (value int, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(0) { + return value, false + } + return s.PostsBetween, true +} + // GetMessages returns value of Messages field. func (s *MessagesSponsoredMessages) GetMessages() (value []SponsoredMessage) { if s == nil { @@ -275,3 +346,206 @@ func (s *MessagesSponsoredMessages) MapChats() (value ChatClassArray) { func (s *MessagesSponsoredMessages) MapUsers() (value UserClassArray) { return UserClassArray(s.Users) } + +// MessagesSponsoredMessagesEmpty represents TL type `messages.sponsoredMessagesEmpty#1839490f`. +// +// See https://core.telegram.org/constructor/messages.sponsoredMessagesEmpty for reference. +type MessagesSponsoredMessagesEmpty struct { +} + +// MessagesSponsoredMessagesEmptyTypeID is TL type id of MessagesSponsoredMessagesEmpty. +const MessagesSponsoredMessagesEmptyTypeID = 0x1839490f + +// construct implements constructor of MessagesSponsoredMessagesClass. +func (s MessagesSponsoredMessagesEmpty) construct() MessagesSponsoredMessagesClass { return &s } + +// Ensuring interfaces in compile-time for MessagesSponsoredMessagesEmpty. +var ( + _ bin.Encoder = &MessagesSponsoredMessagesEmpty{} + _ bin.Decoder = &MessagesSponsoredMessagesEmpty{} + _ bin.BareEncoder = &MessagesSponsoredMessagesEmpty{} + _ bin.BareDecoder = &MessagesSponsoredMessagesEmpty{} + + _ MessagesSponsoredMessagesClass = &MessagesSponsoredMessagesEmpty{} +) + +func (s *MessagesSponsoredMessagesEmpty) Zero() bool { + if s == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (s *MessagesSponsoredMessagesEmpty) String() string { + if s == nil { + return "MessagesSponsoredMessagesEmpty(nil)" + } + type Alias MessagesSponsoredMessagesEmpty + return fmt.Sprintf("MessagesSponsoredMessagesEmpty%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesSponsoredMessagesEmpty) TypeID() uint32 { + return MessagesSponsoredMessagesEmptyTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesSponsoredMessagesEmpty) TypeName() string { + return "messages.sponsoredMessagesEmpty" +} + +// TypeInfo returns info about TL type. +func (s *MessagesSponsoredMessagesEmpty) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.sponsoredMessagesEmpty", + ID: MessagesSponsoredMessagesEmptyTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (s *MessagesSponsoredMessagesEmpty) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode messages.sponsoredMessagesEmpty#1839490f as nil") + } + b.PutID(MessagesSponsoredMessagesEmptyTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *MessagesSponsoredMessagesEmpty) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode messages.sponsoredMessagesEmpty#1839490f as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (s *MessagesSponsoredMessagesEmpty) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode messages.sponsoredMessagesEmpty#1839490f to nil") + } + if err := b.ConsumeID(MessagesSponsoredMessagesEmptyTypeID); err != nil { + return fmt.Errorf("unable to decode messages.sponsoredMessagesEmpty#1839490f: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *MessagesSponsoredMessagesEmpty) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode messages.sponsoredMessagesEmpty#1839490f to nil") + } + return nil +} + +// MessagesSponsoredMessagesClassName is schema name of MessagesSponsoredMessagesClass. +const MessagesSponsoredMessagesClassName = "messages.SponsoredMessages" + +// MessagesSponsoredMessagesClass represents messages.SponsoredMessages generic type. +// +// See https://core.telegram.org/type/messages.SponsoredMessages for reference. +// +// Example: +// +// g, err := tg.DecodeMessagesSponsoredMessages(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.MessagesSponsoredMessages: // messages.sponsoredMessages#c9ee1d87 +// case *tg.MessagesSponsoredMessagesEmpty: // messages.sponsoredMessagesEmpty#1839490f +// default: panic(v) +// } +type MessagesSponsoredMessagesClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() MessagesSponsoredMessagesClass + + // 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 + + // AsNotEmpty tries to map MessagesSponsoredMessagesClass to MessagesSponsoredMessages. + AsNotEmpty() (*MessagesSponsoredMessages, bool) +} + +// AsNotEmpty tries to map MessagesSponsoredMessages to MessagesSponsoredMessages. +func (s *MessagesSponsoredMessages) AsNotEmpty() (*MessagesSponsoredMessages, bool) { + return s, true +} + +// AsNotEmpty tries to map MessagesSponsoredMessagesEmpty to MessagesSponsoredMessages. +func (s *MessagesSponsoredMessagesEmpty) AsNotEmpty() (*MessagesSponsoredMessages, bool) { + return nil, false +} + +// DecodeMessagesSponsoredMessages implements binary de-serialization for MessagesSponsoredMessagesClass. +func DecodeMessagesSponsoredMessages(buf *bin.Buffer) (MessagesSponsoredMessagesClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case MessagesSponsoredMessagesTypeID: + // Decoding messages.sponsoredMessages#c9ee1d87. + v := MessagesSponsoredMessages{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessagesSponsoredMessagesClass: %w", err) + } + return &v, nil + case MessagesSponsoredMessagesEmptyTypeID: + // Decoding messages.sponsoredMessagesEmpty#1839490f. + v := MessagesSponsoredMessagesEmpty{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessagesSponsoredMessagesClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode MessagesSponsoredMessagesClass: %w", bin.NewUnexpectedID(id)) + } +} + +// MessagesSponsoredMessages boxes the MessagesSponsoredMessagesClass providing a helper. +type MessagesSponsoredMessagesBox struct { + SponsoredMessages MessagesSponsoredMessagesClass +} + +// Decode implements bin.Decoder for MessagesSponsoredMessagesBox. +func (b *MessagesSponsoredMessagesBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode MessagesSponsoredMessagesBox to nil") + } + v, err := DecodeMessagesSponsoredMessages(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.SponsoredMessages = v + return nil +} + +// Encode implements bin.Encode for MessagesSponsoredMessagesBox. +func (b *MessagesSponsoredMessagesBox) Encode(buf *bin.Buffer) error { + if b == nil || b.SponsoredMessages == nil { + return fmt.Errorf("unable to encode MessagesSponsoredMessagesClass as nil") + } + return b.SponsoredMessages.Encode(buf) +} diff --git a/tg/tl_messages_sponsored_messages_slices_gen.go b/tg/tl_messages_sponsored_messages_slices_gen.go index fe21471a4c..620d648a8e 100644 --- a/tg/tl_messages_sponsored_messages_slices_gen.go +++ b/tg/tl_messages_sponsored_messages_slices_gen.go @@ -33,3 +33,235 @@ var ( _ = tgerr.Error{} _ = tdjson.Encoder{} ) + +// MessagesSponsoredMessagesClassArray is adapter for slice of MessagesSponsoredMessagesClass. +type MessagesSponsoredMessagesClassArray []MessagesSponsoredMessagesClass + +// Sort sorts slice of MessagesSponsoredMessagesClass. +func (s MessagesSponsoredMessagesClassArray) Sort(less func(a, b MessagesSponsoredMessagesClass) bool) MessagesSponsoredMessagesClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessagesSponsoredMessagesClass. +func (s MessagesSponsoredMessagesClassArray) SortStable(less func(a, b MessagesSponsoredMessagesClass) bool) MessagesSponsoredMessagesClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessagesSponsoredMessagesClass. +func (s MessagesSponsoredMessagesClassArray) Retain(keep func(x MessagesSponsoredMessagesClass) bool) MessagesSponsoredMessagesClassArray { + 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 MessagesSponsoredMessagesClassArray) First() (v MessagesSponsoredMessagesClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessagesSponsoredMessagesClassArray) Last() (v MessagesSponsoredMessagesClass, 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 *MessagesSponsoredMessagesClassArray) PopFirst() (v MessagesSponsoredMessagesClass, 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 MessagesSponsoredMessagesClass + 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 *MessagesSponsoredMessagesClassArray) Pop() (v MessagesSponsoredMessagesClass, 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 +} + +// AsMessagesSponsoredMessages returns copy with only MessagesSponsoredMessages constructors. +func (s MessagesSponsoredMessagesClassArray) AsMessagesSponsoredMessages() (to MessagesSponsoredMessagesArray) { + for _, elem := range s { + value, ok := elem.(*MessagesSponsoredMessages) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AppendOnlyNotEmpty appends only NotEmpty constructors to +// given slice. +func (s MessagesSponsoredMessagesClassArray) AppendOnlyNotEmpty(to []*MessagesSponsoredMessages) []*MessagesSponsoredMessages { + for _, elem := range s { + value, ok := elem.AsNotEmpty() + if !ok { + continue + } + to = append(to, value) + } + + return to +} + +// AsNotEmpty returns copy with only NotEmpty constructors. +func (s MessagesSponsoredMessagesClassArray) AsNotEmpty() (to []*MessagesSponsoredMessages) { + return s.AppendOnlyNotEmpty(to) +} + +// FirstAsNotEmpty returns first element of slice (if exists). +func (s MessagesSponsoredMessagesClassArray) FirstAsNotEmpty() (v *MessagesSponsoredMessages, ok bool) { + value, ok := s.First() + if !ok { + return + } + return value.AsNotEmpty() +} + +// LastAsNotEmpty returns last element of slice (if exists). +func (s MessagesSponsoredMessagesClassArray) LastAsNotEmpty() (v *MessagesSponsoredMessages, ok bool) { + value, ok := s.Last() + if !ok { + return + } + return value.AsNotEmpty() +} + +// PopFirstAsNotEmpty returns element of slice (if exists). +func (s *MessagesSponsoredMessagesClassArray) PopFirstAsNotEmpty() (v *MessagesSponsoredMessages, ok bool) { + value, ok := s.PopFirst() + if !ok { + return + } + return value.AsNotEmpty() +} + +// PopAsNotEmpty returns element of slice (if exists). +func (s *MessagesSponsoredMessagesClassArray) PopAsNotEmpty() (v *MessagesSponsoredMessages, ok bool) { + value, ok := s.Pop() + if !ok { + return + } + return value.AsNotEmpty() +} + +// MessagesSponsoredMessagesArray is adapter for slice of MessagesSponsoredMessages. +type MessagesSponsoredMessagesArray []MessagesSponsoredMessages + +// Sort sorts slice of MessagesSponsoredMessages. +func (s MessagesSponsoredMessagesArray) Sort(less func(a, b MessagesSponsoredMessages) bool) MessagesSponsoredMessagesArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessagesSponsoredMessages. +func (s MessagesSponsoredMessagesArray) SortStable(less func(a, b MessagesSponsoredMessages) bool) MessagesSponsoredMessagesArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessagesSponsoredMessages. +func (s MessagesSponsoredMessagesArray) Retain(keep func(x MessagesSponsoredMessages) bool) MessagesSponsoredMessagesArray { + 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 MessagesSponsoredMessagesArray) First() (v MessagesSponsoredMessages, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessagesSponsoredMessagesArray) Last() (v MessagesSponsoredMessages, 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 *MessagesSponsoredMessagesArray) PopFirst() (v MessagesSponsoredMessages, 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 MessagesSponsoredMessages + 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 *MessagesSponsoredMessagesArray) Pop() (v MessagesSponsoredMessages, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_messages_sticker_set_gen.go b/tg/tl_messages_sticker_set_gen.go index 58634773e7..c8f8258847 100644 --- a/tg/tl_messages_sticker_set_gen.go +++ b/tg/tl_messages_sticker_set_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesStickerSet represents TL type `messages.stickerSet#b60a24a6`. +// MessagesStickerSet represents TL type `messages.stickerSet#6e153f16`. // Stickerset and stickers inside it // // See https://core.telegram.org/constructor/messages.stickerSet for reference. @@ -40,12 +40,14 @@ type MessagesStickerSet struct { Set StickerSet // Emoji info for stickers Packs []StickerPack + // Keywords field of MessagesStickerSet. + Keywords []StickerKeyword // Stickers in stickerset Documents []DocumentClass } // MessagesStickerSetTypeID is TL type id of MessagesStickerSet. -const MessagesStickerSetTypeID = 0xb60a24a6 +const MessagesStickerSetTypeID = 0x6e153f16 // construct implements constructor of MessagesStickerSetClass. func (s MessagesStickerSet) construct() MessagesStickerSetClass { return &s } @@ -70,6 +72,9 @@ func (s *MessagesStickerSet) Zero() bool { if !(s.Packs == nil) { return false } + if !(s.Keywords == nil) { + return false + } if !(s.Documents == nil) { return false } @@ -90,10 +95,12 @@ func (s *MessagesStickerSet) String() string { func (s *MessagesStickerSet) FillFrom(from interface { GetSet() (value StickerSet) GetPacks() (value []StickerPack) + GetKeywords() (value []StickerKeyword) GetDocuments() (value []DocumentClass) }) { s.Set = from.GetSet() s.Packs = from.GetPacks() + s.Keywords = from.GetKeywords() s.Documents = from.GetDocuments() } @@ -128,6 +135,10 @@ func (s *MessagesStickerSet) TypeInfo() tdp.Type { Name: "Packs", SchemaName: "packs", }, + { + Name: "Keywords", + SchemaName: "keywords", + }, { Name: "Documents", SchemaName: "documents", @@ -139,7 +150,7 @@ func (s *MessagesStickerSet) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (s *MessagesStickerSet) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.stickerSet#b60a24a6 as nil") + return fmt.Errorf("can't encode messages.stickerSet#6e153f16 as nil") } b.PutID(MessagesStickerSetTypeID) return s.EncodeBare(b) @@ -148,24 +159,30 @@ func (s *MessagesStickerSet) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *MessagesStickerSet) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.stickerSet#b60a24a6 as nil") + return fmt.Errorf("can't encode messages.stickerSet#6e153f16 as nil") } if err := s.Set.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.stickerSet#b60a24a6: field set: %w", err) + return fmt.Errorf("unable to encode messages.stickerSet#6e153f16: field set: %w", err) } b.PutVectorHeader(len(s.Packs)) for idx, v := range s.Packs { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.stickerSet#b60a24a6: field packs element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode messages.stickerSet#6e153f16: field packs element with index %d: %w", idx, err) + } + } + b.PutVectorHeader(len(s.Keywords)) + for idx, v := range s.Keywords { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.stickerSet#6e153f16: field keywords element with index %d: %w", idx, err) } } b.PutVectorHeader(len(s.Documents)) for idx, v := range s.Documents { if v == nil { - return fmt.Errorf("unable to encode messages.stickerSet#b60a24a6: field documents element with index %d is nil", idx) + return fmt.Errorf("unable to encode messages.stickerSet#6e153f16: field documents element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.stickerSet#b60a24a6: field documents element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode messages.stickerSet#6e153f16: field documents element with index %d: %w", idx, err) } } return nil @@ -174,10 +191,10 @@ func (s *MessagesStickerSet) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *MessagesStickerSet) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.stickerSet#b60a24a6 to nil") + return fmt.Errorf("can't decode messages.stickerSet#6e153f16 to nil") } if err := b.ConsumeID(MessagesStickerSetTypeID); err != nil { - return fmt.Errorf("unable to decode messages.stickerSet#b60a24a6: %w", err) + return fmt.Errorf("unable to decode messages.stickerSet#6e153f16: %w", err) } return s.DecodeBare(b) } @@ -185,17 +202,17 @@ func (s *MessagesStickerSet) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *MessagesStickerSet) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.stickerSet#b60a24a6 to nil") + return fmt.Errorf("can't decode messages.stickerSet#6e153f16 to nil") } { if err := s.Set.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.stickerSet#b60a24a6: field set: %w", err) + return fmt.Errorf("unable to decode messages.stickerSet#6e153f16: field set: %w", err) } } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode messages.stickerSet#b60a24a6: field packs: %w", err) + return fmt.Errorf("unable to decode messages.stickerSet#6e153f16: field packs: %w", err) } if headerLen > 0 { @@ -204,7 +221,7 @@ func (s *MessagesStickerSet) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value StickerPack if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.stickerSet#b60a24a6: field packs: %w", err) + return fmt.Errorf("unable to decode messages.stickerSet#6e153f16: field packs: %w", err) } s.Packs = append(s.Packs, value) } @@ -212,7 +229,24 @@ func (s *MessagesStickerSet) DecodeBare(b *bin.Buffer) error { { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode messages.stickerSet#b60a24a6: field documents: %w", err) + return fmt.Errorf("unable to decode messages.stickerSet#6e153f16: field keywords: %w", err) + } + + if headerLen > 0 { + s.Keywords = make([]StickerKeyword, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value StickerKeyword + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.stickerSet#6e153f16: field keywords: %w", err) + } + s.Keywords = append(s.Keywords, value) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode messages.stickerSet#6e153f16: field documents: %w", err) } if headerLen > 0 { @@ -221,7 +255,7 @@ func (s *MessagesStickerSet) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeDocument(b) if err != nil { - return fmt.Errorf("unable to decode messages.stickerSet#b60a24a6: field documents: %w", err) + return fmt.Errorf("unable to decode messages.stickerSet#6e153f16: field documents: %w", err) } s.Documents = append(s.Documents, value) } @@ -245,6 +279,14 @@ func (s *MessagesStickerSet) GetPacks() (value []StickerPack) { return s.Packs } +// GetKeywords returns value of Keywords field. +func (s *MessagesStickerSet) GetKeywords() (value []StickerKeyword) { + if s == nil { + return + } + return s.Keywords +} + // GetDocuments returns value of Documents field. func (s *MessagesStickerSet) GetDocuments() (value []DocumentClass) { if s == nil { @@ -374,7 +416,7 @@ const MessagesStickerSetClassName = "messages.StickerSet" // panic(err) // } // switch v := g.(type) { -// case *tg.MessagesStickerSet: // messages.stickerSet#b60a24a6 +// case *tg.MessagesStickerSet: // messages.stickerSet#6e153f16 // case *tg.MessagesStickerSetNotModified: // messages.stickerSetNotModified#d3f924eb // default: panic(v) // } @@ -418,7 +460,7 @@ func DecodeMessagesStickerSet(buf *bin.Buffer) (MessagesStickerSetClass, error) } switch id { case MessagesStickerSetTypeID: - // Decoding messages.stickerSet#b60a24a6. + // Decoding messages.stickerSet#6e153f16. v := MessagesStickerSet{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode MessagesStickerSetClass: %w", err) diff --git a/tg/tl_messages_unpin_all_messages_gen.go b/tg/tl_messages_unpin_all_messages_gen.go index 05c0b19dd4..c1f1cf1008 100644 --- a/tg/tl_messages_unpin_all_messages_gen.go +++ b/tg/tl_messages_unpin_all_messages_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesUnpinAllMessagesRequest represents TL type `messages.unpinAllMessages#f025bc8b`. +// MessagesUnpinAllMessagesRequest represents TL type `messages.unpinAllMessages#ee22b9a8`. // Unpin¹ all pinned messages // // Links: @@ -39,12 +39,18 @@ var ( // // See https://core.telegram.org/method/messages.unpinAllMessages for reference. type MessagesUnpinAllMessagesRequest struct { + // Flags field of MessagesUnpinAllMessagesRequest. + Flags bin.Fields // Chat where to unpin Peer InputPeerClass + // TopMsgID field of MessagesUnpinAllMessagesRequest. + // + // Use SetTopMsgID and GetTopMsgID helpers. + TopMsgID int } // MessagesUnpinAllMessagesRequestTypeID is TL type id of MessagesUnpinAllMessagesRequest. -const MessagesUnpinAllMessagesRequestTypeID = 0xf025bc8b +const MessagesUnpinAllMessagesRequestTypeID = 0xee22b9a8 // Ensuring interfaces in compile-time for MessagesUnpinAllMessagesRequest. var ( @@ -58,9 +64,15 @@ func (u *MessagesUnpinAllMessagesRequest) Zero() bool { if u == nil { return true } + if !(u.Flags.Zero()) { + return false + } if !(u.Peer == nil) { return false } + if !(u.TopMsgID == 0) { + return false + } return true } @@ -77,8 +89,13 @@ func (u *MessagesUnpinAllMessagesRequest) String() string { // FillFrom fills MessagesUnpinAllMessagesRequest from given interface. func (u *MessagesUnpinAllMessagesRequest) FillFrom(from interface { GetPeer() (value InputPeerClass) + GetTopMsgID() (value int, ok bool) }) { u.Peer = from.GetPeer() + if val, ok := from.GetTopMsgID(); ok { + u.TopMsgID = val + } + } // TypeID returns type id in TL schema. @@ -108,14 +125,26 @@ func (u *MessagesUnpinAllMessagesRequest) TypeInfo() tdp.Type { Name: "Peer", SchemaName: "peer", }, + { + Name: "TopMsgID", + SchemaName: "top_msg_id", + Null: !u.Flags.Has(0), + }, } return typ } +// SetFlags sets flags for non-zero fields. +func (u *MessagesUnpinAllMessagesRequest) SetFlags() { + if !(u.TopMsgID == 0) { + u.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (u *MessagesUnpinAllMessagesRequest) Encode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode messages.unpinAllMessages#f025bc8b as nil") + return fmt.Errorf("can't encode messages.unpinAllMessages#ee22b9a8 as nil") } b.PutID(MessagesUnpinAllMessagesRequestTypeID) return u.EncodeBare(b) @@ -124,13 +153,20 @@ func (u *MessagesUnpinAllMessagesRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (u *MessagesUnpinAllMessagesRequest) EncodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode messages.unpinAllMessages#f025bc8b as nil") + return fmt.Errorf("can't encode messages.unpinAllMessages#ee22b9a8 as nil") + } + u.SetFlags() + if err := u.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.unpinAllMessages#ee22b9a8: field flags: %w", err) } if u.Peer == nil { - return fmt.Errorf("unable to encode messages.unpinAllMessages#f025bc8b: field peer is nil") + return fmt.Errorf("unable to encode messages.unpinAllMessages#ee22b9a8: field peer is nil") } if err := u.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.unpinAllMessages#f025bc8b: field peer: %w", err) + return fmt.Errorf("unable to encode messages.unpinAllMessages#ee22b9a8: field peer: %w", err) + } + if u.Flags.Has(0) { + b.PutInt(u.TopMsgID) } return nil } @@ -138,10 +174,10 @@ func (u *MessagesUnpinAllMessagesRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (u *MessagesUnpinAllMessagesRequest) Decode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode messages.unpinAllMessages#f025bc8b to nil") + return fmt.Errorf("can't decode messages.unpinAllMessages#ee22b9a8 to nil") } if err := b.ConsumeID(MessagesUnpinAllMessagesRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.unpinAllMessages#f025bc8b: %w", err) + return fmt.Errorf("unable to decode messages.unpinAllMessages#ee22b9a8: %w", err) } return u.DecodeBare(b) } @@ -149,15 +185,27 @@ func (u *MessagesUnpinAllMessagesRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (u *MessagesUnpinAllMessagesRequest) DecodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode messages.unpinAllMessages#f025bc8b to nil") + return fmt.Errorf("can't decode messages.unpinAllMessages#ee22b9a8 to nil") + } + { + if err := u.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.unpinAllMessages#ee22b9a8: field flags: %w", err) + } } { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.unpinAllMessages#f025bc8b: field peer: %w", err) + return fmt.Errorf("unable to decode messages.unpinAllMessages#ee22b9a8: field peer: %w", err) } u.Peer = value } + if u.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.unpinAllMessages#ee22b9a8: field top_msg_id: %w", err) + } + u.TopMsgID = value + } return nil } @@ -169,7 +217,25 @@ func (u *MessagesUnpinAllMessagesRequest) GetPeer() (value InputPeerClass) { return u.Peer } -// MessagesUnpinAllMessages invokes method messages.unpinAllMessages#f025bc8b returning error if any. +// SetTopMsgID sets value of TopMsgID conditional field. +func (u *MessagesUnpinAllMessagesRequest) SetTopMsgID(value int) { + u.Flags.Set(0) + u.TopMsgID = value +} + +// GetTopMsgID returns value of TopMsgID conditional field and +// boolean which is true if field was set. +func (u *MessagesUnpinAllMessagesRequest) GetTopMsgID() (value int, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(0) { + return value, false + } + return u.TopMsgID, true +} + +// MessagesUnpinAllMessages invokes method messages.unpinAllMessages#ee22b9a8 returning error if any. // Unpin¹ all pinned messages // // Links: @@ -182,12 +248,9 @@ func (u *MessagesUnpinAllMessagesRequest) GetPeer() (value InputPeerClass) { // // See https://core.telegram.org/method/messages.unpinAllMessages for reference. // Can be used by bots. -func (c *Client) MessagesUnpinAllMessages(ctx context.Context, peer InputPeerClass) (*MessagesAffectedHistory, error) { +func (c *Client) MessagesUnpinAllMessages(ctx context.Context, request *MessagesUnpinAllMessagesRequest) (*MessagesAffectedHistory, error) { var result MessagesAffectedHistory - request := &MessagesUnpinAllMessagesRequest{ - Peer: peer, - } if err := c.rpc.Invoke(ctx, request, &result); err != nil { return nil, err } diff --git a/tg/tl_notify_peer_gen.go b/tg/tl_notify_peer_gen.go index f352e049ae..cd2411f5c3 100644 --- a/tg/tl_notify_peer_gen.go +++ b/tg/tl_notify_peer_gen.go @@ -477,6 +477,172 @@ func (n *NotifyBroadcasts) DecodeBare(b *bin.Buffer) error { return nil } +// NotifyForumTopic represents TL type `notifyForumTopic#226e6308`. +// +// See https://core.telegram.org/constructor/notifyForumTopic for reference. +type NotifyForumTopic struct { + // Peer field of NotifyForumTopic. + Peer PeerClass + // TopMsgID field of NotifyForumTopic. + TopMsgID int +} + +// NotifyForumTopicTypeID is TL type id of NotifyForumTopic. +const NotifyForumTopicTypeID = 0x226e6308 + +// construct implements constructor of NotifyPeerClass. +func (n NotifyForumTopic) construct() NotifyPeerClass { return &n } + +// Ensuring interfaces in compile-time for NotifyForumTopic. +var ( + _ bin.Encoder = &NotifyForumTopic{} + _ bin.Decoder = &NotifyForumTopic{} + _ bin.BareEncoder = &NotifyForumTopic{} + _ bin.BareDecoder = &NotifyForumTopic{} + + _ NotifyPeerClass = &NotifyForumTopic{} +) + +func (n *NotifyForumTopic) Zero() bool { + if n == nil { + return true + } + if !(n.Peer == nil) { + return false + } + if !(n.TopMsgID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (n *NotifyForumTopic) String() string { + if n == nil { + return "NotifyForumTopic(nil)" + } + type Alias NotifyForumTopic + return fmt.Sprintf("NotifyForumTopic%+v", Alias(*n)) +} + +// FillFrom fills NotifyForumTopic from given interface. +func (n *NotifyForumTopic) FillFrom(from interface { + GetPeer() (value PeerClass) + GetTopMsgID() (value int) +}) { + n.Peer = from.GetPeer() + n.TopMsgID = from.GetTopMsgID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*NotifyForumTopic) TypeID() uint32 { + return NotifyForumTopicTypeID +} + +// TypeName returns name of type in TL schema. +func (*NotifyForumTopic) TypeName() string { + return "notifyForumTopic" +} + +// TypeInfo returns info about TL type. +func (n *NotifyForumTopic) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "notifyForumTopic", + ID: NotifyForumTopicTypeID, + } + if n == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "TopMsgID", + SchemaName: "top_msg_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (n *NotifyForumTopic) Encode(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't encode notifyForumTopic#226e6308 as nil") + } + b.PutID(NotifyForumTopicTypeID) + return n.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (n *NotifyForumTopic) EncodeBare(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't encode notifyForumTopic#226e6308 as nil") + } + if n.Peer == nil { + return fmt.Errorf("unable to encode notifyForumTopic#226e6308: field peer is nil") + } + if err := n.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode notifyForumTopic#226e6308: field peer: %w", err) + } + b.PutInt(n.TopMsgID) + return nil +} + +// Decode implements bin.Decoder. +func (n *NotifyForumTopic) Decode(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't decode notifyForumTopic#226e6308 to nil") + } + if err := b.ConsumeID(NotifyForumTopicTypeID); err != nil { + return fmt.Errorf("unable to decode notifyForumTopic#226e6308: %w", err) + } + return n.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (n *NotifyForumTopic) DecodeBare(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't decode notifyForumTopic#226e6308 to nil") + } + { + value, err := DecodePeer(b) + if err != nil { + return fmt.Errorf("unable to decode notifyForumTopic#226e6308: field peer: %w", err) + } + n.Peer = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode notifyForumTopic#226e6308: field top_msg_id: %w", err) + } + n.TopMsgID = value + } + return nil +} + +// GetPeer returns value of Peer field. +func (n *NotifyForumTopic) GetPeer() (value PeerClass) { + if n == nil { + return + } + return n.Peer +} + +// GetTopMsgID returns value of TopMsgID field. +func (n *NotifyForumTopic) GetTopMsgID() (value int) { + if n == nil { + return + } + return n.TopMsgID +} + // NotifyPeerClassName is schema name of NotifyPeerClass. const NotifyPeerClassName = "NotifyPeer" @@ -495,6 +661,7 @@ const NotifyPeerClassName = "NotifyPeer" // case *tg.NotifyUsers: // notifyUsers#b4c83b4c // case *tg.NotifyChats: // notifyChats#c007cec3 // case *tg.NotifyBroadcasts: // notifyBroadcasts#d612e8ef +// case *tg.NotifyForumTopic: // notifyForumTopic#226e6308 // default: panic(v) // } type NotifyPeerClass interface { @@ -551,6 +718,13 @@ func DecodeNotifyPeer(buf *bin.Buffer) (NotifyPeerClass, error) { return nil, fmt.Errorf("unable to decode NotifyPeerClass: %w", err) } return &v, nil + case NotifyForumTopicTypeID: + // Decoding notifyForumTopic#226e6308. + v := NotifyForumTopic{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode NotifyPeerClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode NotifyPeerClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_notify_peer_slices_gen.go b/tg/tl_notify_peer_slices_gen.go index b356e6d678..aee68fc26d 100644 --- a/tg/tl_notify_peer_slices_gen.go +++ b/tg/tl_notify_peer_slices_gen.go @@ -129,6 +129,19 @@ func (s NotifyPeerClassArray) AsNotifyPeer() (to NotifyPeerArray) { return to } +// AsNotifyForumTopic returns copy with only NotifyForumTopic constructors. +func (s NotifyPeerClassArray) AsNotifyForumTopic() (to NotifyForumTopicArray) { + for _, elem := range s { + value, ok := elem.(*NotifyForumTopic) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // NotifyPeerArray is adapter for slice of NotifyPeer. type NotifyPeerArray []NotifyPeer @@ -210,3 +223,85 @@ func (s *NotifyPeerArray) Pop() (v NotifyPeer, ok bool) { return v, true } + +// NotifyForumTopicArray is adapter for slice of NotifyForumTopic. +type NotifyForumTopicArray []NotifyForumTopic + +// Sort sorts slice of NotifyForumTopic. +func (s NotifyForumTopicArray) Sort(less func(a, b NotifyForumTopic) bool) NotifyForumTopicArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of NotifyForumTopic. +func (s NotifyForumTopicArray) SortStable(less func(a, b NotifyForumTopic) bool) NotifyForumTopicArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of NotifyForumTopic. +func (s NotifyForumTopicArray) Retain(keep func(x NotifyForumTopic) bool) NotifyForumTopicArray { + 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 NotifyForumTopicArray) First() (v NotifyForumTopic, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s NotifyForumTopicArray) Last() (v NotifyForumTopic, 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 *NotifyForumTopicArray) PopFirst() (v NotifyForumTopic, 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 NotifyForumTopic + 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 *NotifyForumTopicArray) Pop() (v NotifyForumTopic, 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_registry_gen.go b/tg/tl_registry_gen.go index 941c414f38..d97f24314b 100644 --- a/tg/tl_registry_gen.go +++ b/tg/tl_registry_gen.go @@ -32,7 +32,7 @@ var ( ) // Layer version of schema. -const Layer = 146 +const Layer = 148 // TypesMap returns mapping from type ids to TL type names. func TypesMap() map[uint32]string { @@ -102,7 +102,7 @@ func TypesMap() map[uint32]string { StorageFileMp4TypeID: "storage.fileMp4#b3cea0e4", StorageFileWebpTypeID: "storage.fileWebp#1081464c", UserEmptyTypeID: "userEmpty#d3bc4b7a", - UserTypeID: "user#5d99adee", + UserTypeID: "user#8f97c628", UserProfilePhotoEmptyTypeID: "userProfilePhotoEmpty#4f11bae1", UserProfilePhotoTypeID: "userProfilePhoto#82d1f706", UserStatusEmptyTypeID: "userStatusEmpty#9d05049", @@ -114,7 +114,7 @@ func TypesMap() map[uint32]string { ChatEmptyTypeID: "chatEmpty#29562865", ChatTypeID: "chat#41cbf256", ChatForbiddenTypeID: "chatForbidden#6592a1a7", - ChannelTypeID: "channel#8261ac61", + ChannelTypeID: "channel#83259464", ChannelForbiddenTypeID: "channelForbidden#17d493d5", ChatFullTypeID: "chatFull#c9d31138", ChannelFullTypeID: "channelFull#f2355507", @@ -174,6 +174,8 @@ func TypesMap() map[uint32]string { MessageActionWebViewDataSentMeTypeID: "messageActionWebViewDataSentMe#47dd8079", MessageActionWebViewDataSentTypeID: "messageActionWebViewDataSent#b4c38cb5", MessageActionGiftPremiumTypeID: "messageActionGiftPremium#aba0f5c6", + MessageActionTopicCreateTypeID: "messageActionTopicCreate#d999256", + MessageActionTopicEditTypeID: "messageActionTopicEdit#b18a431c", DialogTypeID: "dialog#a8edd0f5", DialogFolderTypeID: "dialogFolder#71bd134c", PhotoEmptyTypeID: "photoEmpty#2331b22d", @@ -194,6 +196,7 @@ func TypesMap() map[uint32]string { InputNotifyUsersTypeID: "inputNotifyUsers#193b4417", InputNotifyChatsTypeID: "inputNotifyChats#4a95e84e", InputNotifyBroadcastsTypeID: "inputNotifyBroadcasts#b1db7c7e", + InputNotifyForumTopicTypeID: "inputNotifyForumTopic#5c467992", InputPeerNotifySettingsTypeID: "inputPeerNotifySettings#df1f002b", PeerNotifySettingsTypeID: "peerNotifySettings#a83b0426", PeerSettingsTypeID: "peerSettings#a518110d", @@ -253,7 +256,7 @@ func TypesMap() map[uint32]string { UpdateChatUserTypingTypeID: "updateChatUserTyping#83487af0", UpdateChatParticipantsTypeID: "updateChatParticipants#7761198", UpdateUserStatusTypeID: "updateUserStatus#e5bdf8de", - UpdateUserNameTypeID: "updateUserName#c3f202e0", + UpdateUserNameTypeID: "updateUserName#a7848924", UpdateUserPhotoTypeID: "updateUserPhoto#f227868c", UpdateNewEncryptedMessageTypeID: "updateNewEncryptedMessage#12bcbd9a", UpdateEncryptedChatTypingTypeID: "updateEncryptedChatTyping#1710f156", @@ -288,7 +291,7 @@ func TypesMap() map[uint32]string { UpdateEditMessageTypeID: "updateEditMessage#e40370a3", UpdateInlineBotCallbackQueryTypeID: "updateInlineBotCallbackQuery#691e9052", UpdateReadChannelOutboxTypeID: "updateReadChannelOutbox#b75f99a9", - UpdateDraftMessageTypeID: "updateDraftMessage#ee2bb969", + UpdateDraftMessageTypeID: "updateDraftMessage#1b49ec6d", UpdateReadFeaturedStickersTypeID: "updateReadFeaturedStickers#571d2742", UpdateRecentStickersTypeID: "updateRecentStickers#9a422c20", UpdateConfigTypeID: "updateConfig#a229dd06", @@ -304,7 +307,7 @@ func TypesMap() map[uint32]string { UpdateLangPackTooLongTypeID: "updateLangPackTooLong#46560264", UpdateLangPackTypeID: "updateLangPack#56022f4d", UpdateFavedStickersTypeID: "updateFavedStickers#e511996d", - UpdateChannelReadMessagesContentsTypeID: "updateChannelReadMessagesContents#44bdd535", + UpdateChannelReadMessagesContentsTypeID: "updateChannelReadMessagesContents#ea29055d", UpdateContactsResetTypeID: "updateContactsReset#7084a7be", UpdateChannelAvailableMessagesTypeID: "updateChannelAvailableMessages#b23fc698", UpdateDialogUnreadMarkTypeID: "updateDialogUnreadMark#e16459c3", @@ -341,7 +344,7 @@ func TypesMap() map[uint32]string { UpdateBotCommandsTypeID: "updateBotCommands#4d712f2e", UpdatePendingJoinRequestsTypeID: "updatePendingJoinRequests#7063c3db", UpdateBotChatInviteRequesterTypeID: "updateBotChatInviteRequester#11dfa986", - UpdateMessageReactionsTypeID: "updateMessageReactions#154798c3", + UpdateMessageReactionsTypeID: "updateMessageReactions#5e1b3cb8", UpdateAttachMenuBotsTypeID: "updateAttachMenuBots#17b7a20b", UpdateWebViewResultSentTypeID: "updateWebViewResultSent#1592b79d", UpdateBotMenuButtonTypeID: "updateBotMenuButton#14b85813", @@ -353,6 +356,7 @@ func TypesMap() map[uint32]string { UpdateRecentReactionsTypeID: "updateRecentReactions#6f7863f4", UpdateMoveStickerSetToTopTypeID: "updateMoveStickerSetToTop#86fccf85", UpdateMessageExtendedMediaTypeID: "updateMessageExtendedMedia#5a73a98c", + UpdateChannelPinnedTopicTypeID: "updateChannelPinnedTopic#f694b0ae", UpdatesStateTypeID: "updates.state#a56c2a3e", UpdatesDifferenceEmptyTypeID: "updates.differenceEmpty#5d75a138", UpdatesDifferenceTypeID: "updates.difference#f49ca0", @@ -403,6 +407,7 @@ func TypesMap() map[uint32]string { NotifyUsersTypeID: "notifyUsers#b4c83b4c", NotifyChatsTypeID: "notifyChats#c007cec3", NotifyBroadcastsTypeID: "notifyBroadcasts#d612e8ef", + NotifyForumTopicTypeID: "notifyForumTopic#226e6308", SendMessageTypingActionTypeID: "sendMessageTypingAction#16bf744e", SendMessageCancelActionTypeID: "sendMessageCancelAction#fd5ec8f5", SendMessageRecordVideoActionTypeID: "sendMessageRecordVideoAction#a187d66f", @@ -497,8 +502,9 @@ func TypesMap() map[uint32]string { InputStickerSetPremiumGiftsTypeID: "inputStickerSetPremiumGifts#c88b3b02", InputStickerSetEmojiGenericAnimationsTypeID: "inputStickerSetEmojiGenericAnimations#4c4d4ce", InputStickerSetEmojiDefaultStatusesTypeID: "inputStickerSetEmojiDefaultStatuses#29d0f5ee", + InputStickerSetEmojiDefaultTopicIconsTypeID: "inputStickerSetEmojiDefaultTopicIcons#44c1f8e9", StickerSetTypeID: "stickerSet#2dd14edc", - MessagesStickerSetTypeID: "messages.stickerSet#b60a24a6", + MessagesStickerSetTypeID: "messages.stickerSet#6e153f16", MessagesStickerSetNotModifiedTypeID: "messages.stickerSetNotModified#d3f924eb", BotCommandTypeID: "botCommand#c27ac8c7", BotInfoTypeID: "botInfo#8f300b57", @@ -636,7 +642,7 @@ func TypesMap() map[uint32]string { MessagesStickerSetInstallResultArchiveTypeID: "messages.stickerSetInstallResultArchive#35e410a8", StickerSetCoveredTypeID: "stickerSetCovered#6410a5d2", StickerSetMultiCoveredTypeID: "stickerSetMultiCovered#3407e51b", - StickerSetFullCoveredTypeID: "stickerSetFullCovered#1aed5ee5", + StickerSetFullCoveredTypeID: "stickerSetFullCovered#40d13c0e", MaskCoordsTypeID: "maskCoords#aed6dbb2", InputStickeredMediaPhotoTypeID: "inputStickeredMediaPhoto#4a992157", InputStickeredMediaDocumentTypeID: "inputStickeredMediaDocument#438865b", @@ -777,6 +783,12 @@ func TypesMap() map[uint32]string { ChannelAdminLogEventActionToggleNoForwardsTypeID: "channelAdminLogEventActionToggleNoForwards#cb2ac766", ChannelAdminLogEventActionSendMessageTypeID: "channelAdminLogEventActionSendMessage#278f2868", ChannelAdminLogEventActionChangeAvailableReactionsTypeID: "channelAdminLogEventActionChangeAvailableReactions#be4e0ef8", + ChannelAdminLogEventActionChangeUsernamesTypeID: "channelAdminLogEventActionChangeUsernames#f04fb3a9", + ChannelAdminLogEventActionToggleForumTypeID: "channelAdminLogEventActionToggleForum#2cc6383", + ChannelAdminLogEventActionCreateTopicTypeID: "channelAdminLogEventActionCreateTopic#58707d28", + ChannelAdminLogEventActionEditTopicTypeID: "channelAdminLogEventActionEditTopic#f06fe208", + ChannelAdminLogEventActionDeleteTopicTypeID: "channelAdminLogEventActionDeleteTopic#ae168909", + ChannelAdminLogEventActionPinTopicTypeID: "channelAdminLogEventActionPinTopic#5d8d353b", ChannelAdminLogEventTypeID: "channelAdminLogEvent#1fad68cd", ChannelsAdminLogResultsTypeID: "channels.adminLogResults#ed8af74d", ChannelAdminLogEventsFilterTypeID: "channelAdminLogEventsFilter#ea107ae4", @@ -1003,7 +1015,8 @@ func TypesMap() map[uint32]string { AccountResetPasswordRequestedWaitTypeID: "account.resetPasswordRequestedWait#e9effc7d", AccountResetPasswordOkTypeID: "account.resetPasswordOk#e926d63e", SponsoredMessageTypeID: "sponsoredMessage#3a836df8", - MessagesSponsoredMessagesTypeID: "messages.sponsoredMessages#65a4c7d5", + MessagesSponsoredMessagesTypeID: "messages.sponsoredMessages#c9ee1d87", + MessagesSponsoredMessagesEmptyTypeID: "messages.sponsoredMessagesEmpty#1839490f", SearchResultsCalendarPeriodTypeID: "searchResultsCalendarPeriod#c9b0539f", MessagesSearchResultsCalendarTypeID: "messages.searchResultsCalendar#147ee23c", SearchResultPositionTypeID: "searchResultPosition#7f648b67", @@ -1083,6 +1096,11 @@ func TypesMap() map[uint32]string { SendAsPeerTypeID: "sendAsPeer#b81c7034", MessageExtendedMediaPreviewTypeID: "messageExtendedMediaPreview#ad628cc8", MessageExtendedMediaTypeID: "messageExtendedMedia#ee479c64", + StickerKeywordTypeID: "stickerKeyword#fcfeb29c", + UsernameTypeID: "username#b4073647", + ForumTopicDeletedTypeID: "forumTopicDeleted#23f109b", + ForumTopicTypeID: "forumTopic#71701da9", + MessagesForumTopicsTypeID: "messages.forumTopics#367617d3", InvokeAfterMsgRequestTypeID: "invokeAfterMsg#cb9f372d", InvokeAfterMsgsRequestTypeID: "invokeAfterMsgs#3dc4b4f0", InitConnectionRequestTypeID: "initConnection#c1cd5ea9", @@ -1169,7 +1187,7 @@ func TypesMap() map[uint32]string { AccountUpdateThemeRequestTypeID: "account.updateTheme#2bf40ccc", AccountSaveThemeRequestTypeID: "account.saveTheme#f257106c", AccountInstallThemeRequestTypeID: "account.installTheme#c727bb3b", - AccountGetThemeRequestTypeID: "account.getTheme#8d9d742b", + AccountGetThemeRequestTypeID: "account.getTheme#3a5869ec", AccountGetThemesRequestTypeID: "account.getThemes#7206e458", AccountSetContentSettingsRequestTypeID: "account.setContentSettings#b574b16b", AccountGetContentSettingsRequestTypeID: "account.getContentSettings#8b9b4dae", @@ -1189,6 +1207,8 @@ func TypesMap() map[uint32]string { AccountGetDefaultEmojiStatusesRequestTypeID: "account.getDefaultEmojiStatuses#d6753386", AccountGetRecentEmojiStatusesRequestTypeID: "account.getRecentEmojiStatuses#f578105", AccountClearRecentEmojiStatusesRequestTypeID: "account.clearRecentEmojiStatuses#18201aae", + AccountReorderUsernamesRequestTypeID: "account.reorderUsernames#ef500eab", + AccountToggleUsernameRequestTypeID: "account.toggleUsername#58d6b376", UsersGetUsersRequestTypeID: "users.getUsers#d91a548", UsersGetFullUserRequestTypeID: "users.getFullUser#b60f5918", UsersSetSecureValueErrorsRequestTypeID: "users.setSecureValueErrors#90c894b5", @@ -1222,9 +1242,9 @@ func TypesMap() map[uint32]string { MessagesDeleteMessagesRequestTypeID: "messages.deleteMessages#e58e95d2", MessagesReceivedMessagesRequestTypeID: "messages.receivedMessages#5a954c0", MessagesSetTypingRequestTypeID: "messages.setTyping#58943ee2", - MessagesSendMessageRequestTypeID: "messages.sendMessage#d9d75a4", - MessagesSendMediaRequestTypeID: "messages.sendMedia#e25ff8e0", - MessagesForwardMessagesRequestTypeID: "messages.forwardMessages#cc30290b", + MessagesSendMessageRequestTypeID: "messages.sendMessage#1cc20387", + MessagesSendMediaRequestTypeID: "messages.sendMedia#7547c966", + MessagesForwardMessagesRequestTypeID: "messages.forwardMessages#c661bbc4", MessagesReportSpamRequestTypeID: "messages.reportSpam#cf1592db", MessagesGetPeerSettingsRequestTypeID: "messages.getPeerSettings#efd9a6a2", MessagesReportRequestTypeID: "messages.report#8953ab4e", @@ -1267,14 +1287,14 @@ func TypesMap() map[uint32]string { MessagesSaveGifRequestTypeID: "messages.saveGif#327a30cb", MessagesGetInlineBotResultsRequestTypeID: "messages.getInlineBotResults#514e999d", MessagesSetInlineBotResultsRequestTypeID: "messages.setInlineBotResults#eb5ea206", - MessagesSendInlineBotResultRequestTypeID: "messages.sendInlineBotResult#7aa11297", + MessagesSendInlineBotResultRequestTypeID: "messages.sendInlineBotResult#d3fbdccb", MessagesGetMessageEditDataRequestTypeID: "messages.getMessageEditData#fda68d36", MessagesEditMessageRequestTypeID: "messages.editMessage#48f71778", MessagesEditInlineBotMessageRequestTypeID: "messages.editInlineBotMessage#83557dba", MessagesGetBotCallbackAnswerRequestTypeID: "messages.getBotCallbackAnswer#9342ca07", MessagesSetBotCallbackAnswerRequestTypeID: "messages.setBotCallbackAnswer#d58f130a", MessagesGetPeerDialogsRequestTypeID: "messages.getPeerDialogs#e470bcfd", - MessagesSaveDraftRequestTypeID: "messages.saveDraft#bc39e14b", + MessagesSaveDraftRequestTypeID: "messages.saveDraft#b4331e3f", MessagesGetAllDraftsRequestTypeID: "messages.getAllDrafts#6a3f8d65", MessagesGetFeaturedStickersRequestTypeID: "messages.getFeaturedStickers#64780b14", MessagesReadFeaturedStickersRequestTypeID: "messages.readFeaturedStickers#5b118126", @@ -1300,10 +1320,10 @@ func TypesMap() map[uint32]string { MessagesSendScreenshotNotificationRequestTypeID: "messages.sendScreenshotNotification#c97df020", MessagesGetFavedStickersRequestTypeID: "messages.getFavedStickers#4f1aaa9", MessagesFaveStickerRequestTypeID: "messages.faveSticker#b9ffc55b", - MessagesGetUnreadMentionsRequestTypeID: "messages.getUnreadMentions#46578472", - MessagesReadMentionsRequestTypeID: "messages.readMentions#f0189d3", + MessagesGetUnreadMentionsRequestTypeID: "messages.getUnreadMentions#f107e790", + MessagesReadMentionsRequestTypeID: "messages.readMentions#36e5bf4d", MessagesGetRecentLocationsRequestTypeID: "messages.getRecentLocations#702a40e0", - MessagesSendMultiMediaRequestTypeID: "messages.sendMultiMedia#f803138f", + MessagesSendMultiMediaRequestTypeID: "messages.sendMultiMedia#b6f11a1c", MessagesUploadEncryptedFileRequestTypeID: "messages.uploadEncryptedFile#5057c497", MessagesSearchStickerSetsRequestTypeID: "messages.searchStickerSets#35705b8a", MessagesGetSplitRangesRequestTypeID: "messages.getSplitRanges#1cff7e08", @@ -1320,7 +1340,7 @@ func TypesMap() map[uint32]string { MessagesGetEmojiKeywordsDifferenceRequestTypeID: "messages.getEmojiKeywordsDifference#1508b6af", MessagesGetEmojiKeywordsLanguagesRequestTypeID: "messages.getEmojiKeywordsLanguages#4e9963b2", MessagesGetEmojiURLRequestTypeID: "messages.getEmojiURL#d5b10c26", - MessagesGetSearchCountersRequestTypeID: "messages.getSearchCounters#732eef00", + MessagesGetSearchCountersRequestTypeID: "messages.getSearchCounters#ae7cc1", MessagesRequestURLAuthRequestTypeID: "messages.requestUrlAuth#198fb446", MessagesAcceptURLAuthRequestTypeID: "messages.acceptUrlAuth#b12c7125", MessagesHidePeerSettingsBarRequestTypeID: "messages.hidePeerSettingsBar#4facb138", @@ -1338,7 +1358,7 @@ func TypesMap() map[uint32]string { MessagesGetRepliesRequestTypeID: "messages.getReplies#22ddd30c", MessagesGetDiscussionMessageRequestTypeID: "messages.getDiscussionMessage#446972fd", MessagesReadDiscussionRequestTypeID: "messages.readDiscussion#f731a9f4", - MessagesUnpinAllMessagesRequestTypeID: "messages.unpinAllMessages#f025bc8b", + MessagesUnpinAllMessagesRequestTypeID: "messages.unpinAllMessages#ee22b9a8", MessagesDeleteChatRequestTypeID: "messages.deleteChat#5bd0ee50", MessagesDeletePhoneCallHistoryRequestTypeID: "messages.deletePhoneCallHistory#f9cbe409", MessagesCheckHistoryImportRequestTypeID: "messages.checkHistoryImport#43fe19f3", @@ -1369,14 +1389,14 @@ func TypesMap() map[uint32]string { MessagesGetAvailableReactionsRequestTypeID: "messages.getAvailableReactions#18dea0ac", MessagesSetDefaultReactionRequestTypeID: "messages.setDefaultReaction#4f47a016", MessagesTranslateTextRequestTypeID: "messages.translateText#24ce6dee", - MessagesGetUnreadReactionsRequestTypeID: "messages.getUnreadReactions#e85bae1a", - MessagesReadReactionsRequestTypeID: "messages.readReactions#82e251d7", + MessagesGetUnreadReactionsRequestTypeID: "messages.getUnreadReactions#3223495b", + MessagesReadReactionsRequestTypeID: "messages.readReactions#54aa7f8e", MessagesSearchSentMediaRequestTypeID: "messages.searchSentMedia#107e31a0", MessagesGetAttachMenuBotsRequestTypeID: "messages.getAttachMenuBots#16fcc2cb", MessagesGetAttachMenuBotRequestTypeID: "messages.getAttachMenuBot#77216192", MessagesToggleBotInAttachMenuRequestTypeID: "messages.toggleBotInAttachMenu#1aee33af", - MessagesRequestWebViewRequestTypeID: "messages.requestWebView#fc87a53c", - MessagesProlongWebViewRequestTypeID: "messages.prolongWebView#ea5fbcce", + MessagesRequestWebViewRequestTypeID: "messages.requestWebView#178b480b", + MessagesProlongWebViewRequestTypeID: "messages.prolongWebView#7ff34309", MessagesRequestSimpleWebViewRequestTypeID: "messages.requestSimpleWebView#299bec8e", MessagesSendWebViewResultMessageRequestTypeID: "messages.sendWebViewResultMessage#a4314f5", MessagesSendWebViewDataRequestTypeID: "messages.sendWebViewData#dc0242c8", @@ -1469,6 +1489,16 @@ func TypesMap() map[uint32]string { ChannelsDeleteParticipantHistoryRequestTypeID: "channels.deleteParticipantHistory#367544db", ChannelsToggleJoinToSendRequestTypeID: "channels.toggleJoinToSend#e4cb9580", ChannelsToggleJoinRequestRequestTypeID: "channels.toggleJoinRequest#4c2985b6", + ChannelsReorderUsernamesRequestTypeID: "channels.reorderUsernames#b45ced1d", + ChannelsToggleUsernameRequestTypeID: "channels.toggleUsername#50f24105", + ChannelsDeactivateAllUsernamesRequestTypeID: "channels.deactivateAllUsernames#a245dd3", + ChannelsToggleForumRequestTypeID: "channels.toggleForum#a4298b29", + ChannelsCreateForumTopicRequestTypeID: "channels.createForumTopic#f40c0224", + ChannelsGetForumTopicsRequestTypeID: "channels.getForumTopics#de560d1", + ChannelsGetForumTopicsByIDRequestTypeID: "channels.getForumTopicsByID#b0831eb9", + ChannelsEditForumTopicRequestTypeID: "channels.editForumTopic#6c883e2d", + ChannelsUpdatePinnedForumTopicRequestTypeID: "channels.updatePinnedForumTopic#6c2d9026", + ChannelsDeleteTopicHistoryRequestTypeID: "channels.deleteTopicHistory#34435f2d", BotsSendCustomRequestRequestTypeID: "bots.sendCustomRequest#aa2769ed", BotsAnswerWebhookJSONQueryRequestTypeID: "bots.answerWebhookJSONQuery#e6213f4d", BotsSetBotCommandsRequestTypeID: "bots.setBotCommands#517165a", @@ -1695,6 +1725,8 @@ func NamesMap() map[string]uint32 { "messageActionWebViewDataSentMe": MessageActionWebViewDataSentMeTypeID, "messageActionWebViewDataSent": MessageActionWebViewDataSentTypeID, "messageActionGiftPremium": MessageActionGiftPremiumTypeID, + "messageActionTopicCreate": MessageActionTopicCreateTypeID, + "messageActionTopicEdit": MessageActionTopicEditTypeID, "dialog": DialogTypeID, "dialogFolder": DialogFolderTypeID, "photoEmpty": PhotoEmptyTypeID, @@ -1715,6 +1747,7 @@ func NamesMap() map[string]uint32 { "inputNotifyUsers": InputNotifyUsersTypeID, "inputNotifyChats": InputNotifyChatsTypeID, "inputNotifyBroadcasts": InputNotifyBroadcastsTypeID, + "inputNotifyForumTopic": InputNotifyForumTopicTypeID, "inputPeerNotifySettings": InputPeerNotifySettingsTypeID, "peerNotifySettings": PeerNotifySettingsTypeID, "peerSettings": PeerSettingsTypeID, @@ -1874,6 +1907,7 @@ func NamesMap() map[string]uint32 { "updateRecentReactions": UpdateRecentReactionsTypeID, "updateMoveStickerSetToTop": UpdateMoveStickerSetToTopTypeID, "updateMessageExtendedMedia": UpdateMessageExtendedMediaTypeID, + "updateChannelPinnedTopic": UpdateChannelPinnedTopicTypeID, "updates.state": UpdatesStateTypeID, "updates.differenceEmpty": UpdatesDifferenceEmptyTypeID, "updates.difference": UpdatesDifferenceTypeID, @@ -1924,6 +1958,7 @@ func NamesMap() map[string]uint32 { "notifyUsers": NotifyUsersTypeID, "notifyChats": NotifyChatsTypeID, "notifyBroadcasts": NotifyBroadcastsTypeID, + "notifyForumTopic": NotifyForumTopicTypeID, "sendMessageTypingAction": SendMessageTypingActionTypeID, "sendMessageCancelAction": SendMessageCancelActionTypeID, "sendMessageRecordVideoAction": SendMessageRecordVideoActionTypeID, @@ -2018,6 +2053,7 @@ func NamesMap() map[string]uint32 { "inputStickerSetPremiumGifts": InputStickerSetPremiumGiftsTypeID, "inputStickerSetEmojiGenericAnimations": InputStickerSetEmojiGenericAnimationsTypeID, "inputStickerSetEmojiDefaultStatuses": InputStickerSetEmojiDefaultStatusesTypeID, + "inputStickerSetEmojiDefaultTopicIcons": InputStickerSetEmojiDefaultTopicIconsTypeID, "stickerSet": StickerSetTypeID, "messages.stickerSet": MessagesStickerSetTypeID, "messages.stickerSetNotModified": MessagesStickerSetNotModifiedTypeID, @@ -2298,6 +2334,12 @@ func NamesMap() map[string]uint32 { "channelAdminLogEventActionToggleNoForwards": ChannelAdminLogEventActionToggleNoForwardsTypeID, "channelAdminLogEventActionSendMessage": ChannelAdminLogEventActionSendMessageTypeID, "channelAdminLogEventActionChangeAvailableReactions": ChannelAdminLogEventActionChangeAvailableReactionsTypeID, + "channelAdminLogEventActionChangeUsernames": ChannelAdminLogEventActionChangeUsernamesTypeID, + "channelAdminLogEventActionToggleForum": ChannelAdminLogEventActionToggleForumTypeID, + "channelAdminLogEventActionCreateTopic": ChannelAdminLogEventActionCreateTopicTypeID, + "channelAdminLogEventActionEditTopic": ChannelAdminLogEventActionEditTopicTypeID, + "channelAdminLogEventActionDeleteTopic": ChannelAdminLogEventActionDeleteTopicTypeID, + "channelAdminLogEventActionPinTopic": ChannelAdminLogEventActionPinTopicTypeID, "channelAdminLogEvent": ChannelAdminLogEventTypeID, "channels.adminLogResults": ChannelsAdminLogResultsTypeID, "channelAdminLogEventsFilter": ChannelAdminLogEventsFilterTypeID, @@ -2525,6 +2567,7 @@ func NamesMap() map[string]uint32 { "account.resetPasswordOk": AccountResetPasswordOkTypeID, "sponsoredMessage": SponsoredMessageTypeID, "messages.sponsoredMessages": MessagesSponsoredMessagesTypeID, + "messages.sponsoredMessagesEmpty": MessagesSponsoredMessagesEmptyTypeID, "searchResultsCalendarPeriod": SearchResultsCalendarPeriodTypeID, "messages.searchResultsCalendar": MessagesSearchResultsCalendarTypeID, "searchResultPosition": SearchResultPositionTypeID, @@ -2604,6 +2647,11 @@ func NamesMap() map[string]uint32 { "sendAsPeer": SendAsPeerTypeID, "messageExtendedMediaPreview": MessageExtendedMediaPreviewTypeID, "messageExtendedMedia": MessageExtendedMediaTypeID, + "stickerKeyword": StickerKeywordTypeID, + "username": UsernameTypeID, + "forumTopicDeleted": ForumTopicDeletedTypeID, + "forumTopic": ForumTopicTypeID, + "messages.forumTopics": MessagesForumTopicsTypeID, "invokeAfterMsg": InvokeAfterMsgRequestTypeID, "invokeAfterMsgs": InvokeAfterMsgsRequestTypeID, "initConnection": InitConnectionRequestTypeID, @@ -2710,6 +2758,8 @@ func NamesMap() map[string]uint32 { "account.getDefaultEmojiStatuses": AccountGetDefaultEmojiStatusesRequestTypeID, "account.getRecentEmojiStatuses": AccountGetRecentEmojiStatusesRequestTypeID, "account.clearRecentEmojiStatuses": AccountClearRecentEmojiStatusesRequestTypeID, + "account.reorderUsernames": AccountReorderUsernamesRequestTypeID, + "account.toggleUsername": AccountToggleUsernameRequestTypeID, "users.getUsers": UsersGetUsersRequestTypeID, "users.getFullUser": UsersGetFullUserRequestTypeID, "users.setSecureValueErrors": UsersSetSecureValueErrorsRequestTypeID, @@ -2990,6 +3040,16 @@ func NamesMap() map[string]uint32 { "channels.deleteParticipantHistory": ChannelsDeleteParticipantHistoryRequestTypeID, "channels.toggleJoinToSend": ChannelsToggleJoinToSendRequestTypeID, "channels.toggleJoinRequest": ChannelsToggleJoinRequestRequestTypeID, + "channels.reorderUsernames": ChannelsReorderUsernamesRequestTypeID, + "channels.toggleUsername": ChannelsToggleUsernameRequestTypeID, + "channels.deactivateAllUsernames": ChannelsDeactivateAllUsernamesRequestTypeID, + "channels.toggleForum": ChannelsToggleForumRequestTypeID, + "channels.createForumTopic": ChannelsCreateForumTopicRequestTypeID, + "channels.getForumTopics": ChannelsGetForumTopicsRequestTypeID, + "channels.getForumTopicsByID": ChannelsGetForumTopicsByIDRequestTypeID, + "channels.editForumTopic": ChannelsEditForumTopicRequestTypeID, + "channels.updatePinnedForumTopic": ChannelsUpdatePinnedForumTopicRequestTypeID, + "channels.deleteTopicHistory": ChannelsDeleteTopicHistoryRequestTypeID, "bots.sendCustomRequest": BotsSendCustomRequestRequestTypeID, "bots.answerWebhookJSONQuery": BotsAnswerWebhookJSONQueryRequestTypeID, "bots.setBotCommands": BotsSetBotCommandsRequestTypeID, @@ -3216,6 +3276,8 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MessageActionWebViewDataSentMeTypeID: func() bin.Object { return &MessageActionWebViewDataSentMe{} }, MessageActionWebViewDataSentTypeID: func() bin.Object { return &MessageActionWebViewDataSent{} }, MessageActionGiftPremiumTypeID: func() bin.Object { return &MessageActionGiftPremium{} }, + MessageActionTopicCreateTypeID: func() bin.Object { return &MessageActionTopicCreate{} }, + MessageActionTopicEditTypeID: func() bin.Object { return &MessageActionTopicEdit{} }, DialogTypeID: func() bin.Object { return &Dialog{} }, DialogFolderTypeID: func() bin.Object { return &DialogFolder{} }, PhotoEmptyTypeID: func() bin.Object { return &PhotoEmpty{} }, @@ -3236,6 +3298,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { InputNotifyUsersTypeID: func() bin.Object { return &InputNotifyUsers{} }, InputNotifyChatsTypeID: func() bin.Object { return &InputNotifyChats{} }, InputNotifyBroadcastsTypeID: func() bin.Object { return &InputNotifyBroadcasts{} }, + InputNotifyForumTopicTypeID: func() bin.Object { return &InputNotifyForumTopic{} }, InputPeerNotifySettingsTypeID: func() bin.Object { return &InputPeerNotifySettings{} }, PeerNotifySettingsTypeID: func() bin.Object { return &PeerNotifySettings{} }, PeerSettingsTypeID: func() bin.Object { return &PeerSettings{} }, @@ -3395,6 +3458,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { UpdateRecentReactionsTypeID: func() bin.Object { return &UpdateRecentReactions{} }, UpdateMoveStickerSetToTopTypeID: func() bin.Object { return &UpdateMoveStickerSetToTop{} }, UpdateMessageExtendedMediaTypeID: func() bin.Object { return &UpdateMessageExtendedMedia{} }, + UpdateChannelPinnedTopicTypeID: func() bin.Object { return &UpdateChannelPinnedTopic{} }, UpdatesStateTypeID: func() bin.Object { return &UpdatesState{} }, UpdatesDifferenceEmptyTypeID: func() bin.Object { return &UpdatesDifferenceEmpty{} }, UpdatesDifferenceTypeID: func() bin.Object { return &UpdatesDifference{} }, @@ -3445,6 +3509,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { NotifyUsersTypeID: func() bin.Object { return &NotifyUsers{} }, NotifyChatsTypeID: func() bin.Object { return &NotifyChats{} }, NotifyBroadcastsTypeID: func() bin.Object { return &NotifyBroadcasts{} }, + NotifyForumTopicTypeID: func() bin.Object { return &NotifyForumTopic{} }, SendMessageTypingActionTypeID: func() bin.Object { return &SendMessageTypingAction{} }, SendMessageCancelActionTypeID: func() bin.Object { return &SendMessageCancelAction{} }, SendMessageRecordVideoActionTypeID: func() bin.Object { return &SendMessageRecordVideoAction{} }, @@ -3539,6 +3604,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { InputStickerSetPremiumGiftsTypeID: func() bin.Object { return &InputStickerSetPremiumGifts{} }, InputStickerSetEmojiGenericAnimationsTypeID: func() bin.Object { return &InputStickerSetEmojiGenericAnimations{} }, InputStickerSetEmojiDefaultStatusesTypeID: func() bin.Object { return &InputStickerSetEmojiDefaultStatuses{} }, + InputStickerSetEmojiDefaultTopicIconsTypeID: func() bin.Object { return &InputStickerSetEmojiDefaultTopicIcons{} }, StickerSetTypeID: func() bin.Object { return &StickerSet{} }, MessagesStickerSetTypeID: func() bin.Object { return &MessagesStickerSet{} }, MessagesStickerSetNotModifiedTypeID: func() bin.Object { return &MessagesStickerSetNotModified{} }, @@ -3819,6 +3885,12 @@ func TypesConstructorMap() map[uint32]func() bin.Object { ChannelAdminLogEventActionToggleNoForwardsTypeID: func() bin.Object { return &ChannelAdminLogEventActionToggleNoForwards{} }, ChannelAdminLogEventActionSendMessageTypeID: func() bin.Object { return &ChannelAdminLogEventActionSendMessage{} }, ChannelAdminLogEventActionChangeAvailableReactionsTypeID: func() bin.Object { return &ChannelAdminLogEventActionChangeAvailableReactions{} }, + ChannelAdminLogEventActionChangeUsernamesTypeID: func() bin.Object { return &ChannelAdminLogEventActionChangeUsernames{} }, + ChannelAdminLogEventActionToggleForumTypeID: func() bin.Object { return &ChannelAdminLogEventActionToggleForum{} }, + ChannelAdminLogEventActionCreateTopicTypeID: func() bin.Object { return &ChannelAdminLogEventActionCreateTopic{} }, + ChannelAdminLogEventActionEditTopicTypeID: func() bin.Object { return &ChannelAdminLogEventActionEditTopic{} }, + ChannelAdminLogEventActionDeleteTopicTypeID: func() bin.Object { return &ChannelAdminLogEventActionDeleteTopic{} }, + ChannelAdminLogEventActionPinTopicTypeID: func() bin.Object { return &ChannelAdminLogEventActionPinTopic{} }, ChannelAdminLogEventTypeID: func() bin.Object { return &ChannelAdminLogEvent{} }, ChannelsAdminLogResultsTypeID: func() bin.Object { return &ChannelsAdminLogResults{} }, ChannelAdminLogEventsFilterTypeID: func() bin.Object { return &ChannelAdminLogEventsFilter{} }, @@ -4046,6 +4118,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { AccountResetPasswordOkTypeID: func() bin.Object { return &AccountResetPasswordOk{} }, SponsoredMessageTypeID: func() bin.Object { return &SponsoredMessage{} }, MessagesSponsoredMessagesTypeID: func() bin.Object { return &MessagesSponsoredMessages{} }, + MessagesSponsoredMessagesEmptyTypeID: func() bin.Object { return &MessagesSponsoredMessagesEmpty{} }, SearchResultsCalendarPeriodTypeID: func() bin.Object { return &SearchResultsCalendarPeriod{} }, MessagesSearchResultsCalendarTypeID: func() bin.Object { return &MessagesSearchResultsCalendar{} }, SearchResultPositionTypeID: func() bin.Object { return &SearchResultPosition{} }, @@ -4125,6 +4198,11 @@ func TypesConstructorMap() map[uint32]func() bin.Object { SendAsPeerTypeID: func() bin.Object { return &SendAsPeer{} }, MessageExtendedMediaPreviewTypeID: func() bin.Object { return &MessageExtendedMediaPreview{} }, MessageExtendedMediaTypeID: func() bin.Object { return &MessageExtendedMedia{} }, + StickerKeywordTypeID: func() bin.Object { return &StickerKeyword{} }, + UsernameTypeID: func() bin.Object { return &Username{} }, + ForumTopicDeletedTypeID: func() bin.Object { return &ForumTopicDeleted{} }, + ForumTopicTypeID: func() bin.Object { return &ForumTopic{} }, + MessagesForumTopicsTypeID: func() bin.Object { return &MessagesForumTopics{} }, InvokeAfterMsgRequestTypeID: func() bin.Object { return &InvokeAfterMsgRequest{} }, InvokeAfterMsgsRequestTypeID: func() bin.Object { return &InvokeAfterMsgsRequest{} }, InitConnectionRequestTypeID: func() bin.Object { return &InitConnectionRequest{} }, @@ -4231,6 +4309,8 @@ func TypesConstructorMap() map[uint32]func() bin.Object { AccountGetDefaultEmojiStatusesRequestTypeID: func() bin.Object { return &AccountGetDefaultEmojiStatusesRequest{} }, AccountGetRecentEmojiStatusesRequestTypeID: func() bin.Object { return &AccountGetRecentEmojiStatusesRequest{} }, AccountClearRecentEmojiStatusesRequestTypeID: func() bin.Object { return &AccountClearRecentEmojiStatusesRequest{} }, + AccountReorderUsernamesRequestTypeID: func() bin.Object { return &AccountReorderUsernamesRequest{} }, + AccountToggleUsernameRequestTypeID: func() bin.Object { return &AccountToggleUsernameRequest{} }, UsersGetUsersRequestTypeID: func() bin.Object { return &UsersGetUsersRequest{} }, UsersGetFullUserRequestTypeID: func() bin.Object { return &UsersGetFullUserRequest{} }, UsersSetSecureValueErrorsRequestTypeID: func() bin.Object { return &UsersSetSecureValueErrorsRequest{} }, @@ -4511,6 +4591,16 @@ func TypesConstructorMap() map[uint32]func() bin.Object { ChannelsDeleteParticipantHistoryRequestTypeID: func() bin.Object { return &ChannelsDeleteParticipantHistoryRequest{} }, ChannelsToggleJoinToSendRequestTypeID: func() bin.Object { return &ChannelsToggleJoinToSendRequest{} }, ChannelsToggleJoinRequestRequestTypeID: func() bin.Object { return &ChannelsToggleJoinRequestRequest{} }, + ChannelsReorderUsernamesRequestTypeID: func() bin.Object { return &ChannelsReorderUsernamesRequest{} }, + ChannelsToggleUsernameRequestTypeID: func() bin.Object { return &ChannelsToggleUsernameRequest{} }, + ChannelsDeactivateAllUsernamesRequestTypeID: func() bin.Object { return &ChannelsDeactivateAllUsernamesRequest{} }, + ChannelsToggleForumRequestTypeID: func() bin.Object { return &ChannelsToggleForumRequest{} }, + ChannelsCreateForumTopicRequestTypeID: func() bin.Object { return &ChannelsCreateForumTopicRequest{} }, + ChannelsGetForumTopicsRequestTypeID: func() bin.Object { return &ChannelsGetForumTopicsRequest{} }, + ChannelsGetForumTopicsByIDRequestTypeID: func() bin.Object { return &ChannelsGetForumTopicsByIDRequest{} }, + ChannelsEditForumTopicRequestTypeID: func() bin.Object { return &ChannelsEditForumTopicRequest{} }, + ChannelsUpdatePinnedForumTopicRequestTypeID: func() bin.Object { return &ChannelsUpdatePinnedForumTopicRequest{} }, + ChannelsDeleteTopicHistoryRequestTypeID: func() bin.Object { return &ChannelsDeleteTopicHistoryRequest{} }, BotsSendCustomRequestRequestTypeID: func() bin.Object { return &BotsSendCustomRequestRequest{} }, BotsAnswerWebhookJSONQueryRequestTypeID: func() bin.Object { return &BotsAnswerWebhookJSONQueryRequest{} }, BotsSetBotCommandsRequestTypeID: func() bin.Object { return &BotsSetBotCommandsRequest{} }, @@ -4738,6 +4828,12 @@ func ClassConstructorsMap() map[string][]uint32 { ChannelAdminLogEventActionToggleNoForwardsTypeID, ChannelAdminLogEventActionSendMessageTypeID, ChannelAdminLogEventActionChangeAvailableReactionsTypeID, + ChannelAdminLogEventActionChangeUsernamesTypeID, + ChannelAdminLogEventActionToggleForumTypeID, + ChannelAdminLogEventActionCreateTopicTypeID, + ChannelAdminLogEventActionEditTopicTypeID, + ChannelAdminLogEventActionDeleteTopicTypeID, + ChannelAdminLogEventActionPinTopicTypeID, }, ChannelLocationClassName: { ChannelLocationEmptyTypeID, @@ -4884,6 +4980,10 @@ func ClassConstructorsMap() map[string][]uint32 { ChatInviteExportedTypeID, ChatInvitePublicJoinRequestsTypeID, }, + ForumTopicClassName: { + ForumTopicDeletedTypeID, + ForumTopicTypeID, + }, GeoPointClassName: { GeoPointEmptyTypeID, GeoPointTypeID, @@ -5036,6 +5136,7 @@ func ClassConstructorsMap() map[string][]uint32 { InputNotifyUsersTypeID, InputNotifyChatsTypeID, InputNotifyBroadcastsTypeID, + InputNotifyForumTopicTypeID, }, InputPaymentCredentialsClassName: { InputPaymentCredentialsSavedTypeID, @@ -5091,6 +5192,7 @@ func ClassConstructorsMap() map[string][]uint32 { InputStickerSetPremiumGiftsTypeID, InputStickerSetEmojiGenericAnimationsTypeID, InputStickerSetEmojiDefaultStatusesTypeID, + InputStickerSetEmojiDefaultTopicIconsTypeID, }, InputStickeredMediaClassName: { InputStickeredMediaPhotoTypeID, @@ -5184,6 +5286,8 @@ func ClassConstructorsMap() map[string][]uint32 { MessageActionWebViewDataSentMeTypeID, MessageActionWebViewDataSentTypeID, MessageActionGiftPremiumTypeID, + MessageActionTopicCreateTypeID, + MessageActionTopicEditTypeID, }, MessageClassName: { MessageEmptyTypeID, @@ -5315,6 +5419,10 @@ func ClassConstructorsMap() map[string][]uint32 { MessagesSentEncryptedMessageTypeID, MessagesSentEncryptedFileTypeID, }, + MessagesSponsoredMessagesClassName: { + MessagesSponsoredMessagesTypeID, + MessagesSponsoredMessagesEmptyTypeID, + }, MessagesStickerSetClassName: { MessagesStickerSetTypeID, MessagesStickerSetNotModifiedTypeID, @@ -5342,6 +5450,7 @@ func ClassConstructorsMap() map[string][]uint32 { NotifyUsersTypeID, NotifyChatsTypeID, NotifyBroadcastsTypeID, + NotifyForumTopicTypeID, }, PageBlockClassName: { PageBlockUnsupportedTypeID, @@ -5710,6 +5819,7 @@ func ClassConstructorsMap() map[string][]uint32 { UpdateRecentReactionsTypeID, UpdateMoveStickerSetToTopTypeID, UpdateMessageExtendedMediaTypeID, + UpdateChannelPinnedTopicTypeID, }, UpdatesChannelDifferenceClassName: { UpdatesChannelDifferenceEmptyTypeID, diff --git a/tg/tl_server_gen.go b/tg/tl_server_gen.go index 9b4bd5f331..3e2f56010a 100644 --- a/tg/tl_server_gen.go +++ b/tg/tl_server_gen.go @@ -1908,6 +1908,48 @@ func (s *ServerDispatcher) OnAccountClearRecentEmojiStatuses(f func(ctx context. s.handlers[AccountClearRecentEmojiStatusesRequestTypeID] = handler } +func (s *ServerDispatcher) OnAccountReorderUsernames(f func(ctx context.Context, order []string) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request AccountReorderUsernamesRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, request.Order) + if err != nil { + return nil, err + } + if response { + return &BoolBox{Bool: &BoolTrue{}}, nil + } + + return &BoolBox{Bool: &BoolFalse{}}, nil + } + + s.handlers[AccountReorderUsernamesRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnAccountToggleUsername(f func(ctx context.Context, request *AccountToggleUsernameRequest) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request AccountToggleUsernameRequest + 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[AccountToggleUsernameRequestTypeID] = 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 @@ -3936,14 +3978,14 @@ func (s *ServerDispatcher) OnMessagesGetUnreadMentions(f func(ctx context.Contex s.handlers[MessagesGetUnreadMentionsRequestTypeID] = handler } -func (s *ServerDispatcher) OnMessagesReadMentions(f func(ctx context.Context, peer InputPeerClass) (*MessagesAffectedHistory, error)) { +func (s *ServerDispatcher) OnMessagesReadMentions(f func(ctx context.Context, request *MessagesReadMentionsRequest) (*MessagesAffectedHistory, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request MessagesReadMentionsRequest if err := request.Decode(b); err != nil { return nil, err } - response, err := f(ctx, request.Peer) + response, err := f(ctx, &request) if err != nil { return nil, err } @@ -4597,14 +4639,14 @@ func (s *ServerDispatcher) OnMessagesReadDiscussion(f func(ctx context.Context, s.handlers[MessagesReadDiscussionRequestTypeID] = handler } -func (s *ServerDispatcher) OnMessagesUnpinAllMessages(f func(ctx context.Context, peer InputPeerClass) (*MessagesAffectedHistory, error)) { +func (s *ServerDispatcher) OnMessagesUnpinAllMessages(f func(ctx context.Context, request *MessagesUnpinAllMessagesRequest) (*MessagesAffectedHistory, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request MessagesUnpinAllMessagesRequest if err := request.Decode(b); err != nil { return nil, err } - response, err := f(ctx, request.Peer) + response, err := f(ctx, &request) if err != nil { return nil, err } @@ -5165,14 +5207,14 @@ func (s *ServerDispatcher) OnMessagesGetUnreadReactions(f func(ctx context.Conte s.handlers[MessagesGetUnreadReactionsRequestTypeID] = handler } -func (s *ServerDispatcher) OnMessagesReadReactions(f func(ctx context.Context, peer InputPeerClass) (*MessagesAffectedHistory, error)) { +func (s *ServerDispatcher) OnMessagesReadReactions(f func(ctx context.Context, request *MessagesReadReactionsRequest) (*MessagesAffectedHistory, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request MessagesReadReactionsRequest if err := request.Decode(b); err != nil { return nil, err } - response, err := f(ctx, request.Peer) + response, err := f(ctx, &request) if err != nil { return nil, err } @@ -6847,7 +6889,7 @@ func (s *ServerDispatcher) OnChannelsViewSponsoredMessage(f func(ctx context.Con s.handlers[ChannelsViewSponsoredMessageRequestTypeID] = handler } -func (s *ServerDispatcher) OnChannelsGetSponsoredMessages(f func(ctx context.Context, channel InputChannelClass) (*MessagesSponsoredMessages, error)) { +func (s *ServerDispatcher) OnChannelsGetSponsoredMessages(f func(ctx context.Context, channel InputChannelClass) (MessagesSponsoredMessagesClass, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request ChannelsGetSponsoredMessagesRequest if err := request.Decode(b); err != nil { @@ -6858,7 +6900,7 @@ func (s *ServerDispatcher) OnChannelsGetSponsoredMessages(f func(ctx context.Con if err != nil { return nil, err } - return response, nil + return &MessagesSponsoredMessagesBox{SponsoredMessages: response}, nil } s.handlers[ChannelsGetSponsoredMessagesRequestTypeID] = handler @@ -6932,6 +6974,188 @@ func (s *ServerDispatcher) OnChannelsToggleJoinRequest(f func(ctx context.Contex s.handlers[ChannelsToggleJoinRequestRequestTypeID] = handler } +func (s *ServerDispatcher) OnChannelsReorderUsernames(f func(ctx context.Context, request *ChannelsReorderUsernamesRequest) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request ChannelsReorderUsernamesRequest + 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[ChannelsReorderUsernamesRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnChannelsToggleUsername(f func(ctx context.Context, request *ChannelsToggleUsernameRequest) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request ChannelsToggleUsernameRequest + 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[ChannelsToggleUsernameRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnChannelsDeactivateAllUsernames(f func(ctx context.Context, channel InputChannelClass) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request ChannelsDeactivateAllUsernamesRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, request.Channel) + if err != nil { + return nil, err + } + if response { + return &BoolBox{Bool: &BoolTrue{}}, nil + } + + return &BoolBox{Bool: &BoolFalse{}}, nil + } + + s.handlers[ChannelsDeactivateAllUsernamesRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnChannelsToggleForum(f func(ctx context.Context, request *ChannelsToggleForumRequest) (UpdatesClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request ChannelsToggleForumRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return &UpdatesBox{Updates: response}, nil + } + + s.handlers[ChannelsToggleForumRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnChannelsCreateForumTopic(f func(ctx context.Context, request *ChannelsCreateForumTopicRequest) (UpdatesClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request ChannelsCreateForumTopicRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return &UpdatesBox{Updates: response}, nil + } + + s.handlers[ChannelsCreateForumTopicRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnChannelsGetForumTopics(f func(ctx context.Context, request *ChannelsGetForumTopicsRequest) (*MessagesForumTopics, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request ChannelsGetForumTopicsRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return response, nil + } + + s.handlers[ChannelsGetForumTopicsRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnChannelsGetForumTopicsByID(f func(ctx context.Context, request *ChannelsGetForumTopicsByIDRequest) (*MessagesForumTopics, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request ChannelsGetForumTopicsByIDRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return response, nil + } + + s.handlers[ChannelsGetForumTopicsByIDRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnChannelsEditForumTopic(f func(ctx context.Context, request *ChannelsEditForumTopicRequest) (UpdatesClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request ChannelsEditForumTopicRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return &UpdatesBox{Updates: response}, nil + } + + s.handlers[ChannelsEditForumTopicRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnChannelsUpdatePinnedForumTopic(f func(ctx context.Context, request *ChannelsUpdatePinnedForumTopicRequest) (UpdatesClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request ChannelsUpdatePinnedForumTopicRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return &UpdatesBox{Updates: response}, nil + } + + s.handlers[ChannelsUpdatePinnedForumTopicRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnChannelsDeleteTopicHistory(f func(ctx context.Context, request *ChannelsDeleteTopicHistoryRequest) (*MessagesAffectedHistory, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request ChannelsDeleteTopicHistoryRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return response, nil + } + + s.handlers[ChannelsDeleteTopicHistoryRequestTypeID] = handler +} + func (s *ServerDispatcher) OnBotsSendCustomRequest(f func(ctx context.Context, request *BotsSendCustomRequestRequest) (*DataJSON, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request BotsSendCustomRequestRequest diff --git a/tg/tl_sponsored_message_gen.go b/tg/tl_sponsored_message_gen.go index d3ba3d3faa..5e94d9cb7e 100644 --- a/tg/tl_sponsored_message_gen.go +++ b/tg/tl_sponsored_message_gen.go @@ -46,6 +46,8 @@ type SponsoredMessage struct { Flags bin.Fields // Whether the message needs to be labeled as "recommended" instead of "sponsored" Recommended bool + // ShowPeerPhoto field of SponsoredMessage. + ShowPeerPhoto bool // Message ID RandomID []byte // ID of the sender of the message @@ -100,6 +102,9 @@ func (s *SponsoredMessage) Zero() bool { if !(s.Recommended == false) { return false } + if !(s.ShowPeerPhoto == false) { + return false + } if !(s.RandomID == nil) { return false } @@ -140,6 +145,7 @@ func (s *SponsoredMessage) String() string { // FillFrom fills SponsoredMessage from given interface. func (s *SponsoredMessage) FillFrom(from interface { GetRecommended() (value bool) + GetShowPeerPhoto() (value bool) GetRandomID() (value []byte) GetFromID() (value PeerClass, ok bool) GetChatInvite() (value ChatInviteClass, ok bool) @@ -150,6 +156,7 @@ func (s *SponsoredMessage) FillFrom(from interface { GetEntities() (value []MessageEntityClass, ok bool) }) { s.Recommended = from.GetRecommended() + s.ShowPeerPhoto = from.GetShowPeerPhoto() s.RandomID = from.GetRandomID() if val, ok := from.GetFromID(); ok { s.FromID = val @@ -206,6 +213,11 @@ 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: "RandomID", SchemaName: "random_id", @@ -253,6 +265,9 @@ func (s *SponsoredMessage) SetFlags() { if !(s.Recommended == false) { s.Flags.Set(5) } + if !(s.ShowPeerPhoto == false) { + s.Flags.Set(6) + } if !(s.FromID == nil) { s.Flags.Set(3) } @@ -354,6 +369,7 @@ func (s *SponsoredMessage) DecodeBare(b *bin.Buffer) error { } } s.Recommended = s.Flags.Has(5) + s.ShowPeerPhoto = s.Flags.Has(6) { value, err := b.Bytes() if err != nil { @@ -442,6 +458,25 @@ 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) +} + // GetRandomID returns value of RandomID field. func (s *SponsoredMessage) GetRandomID() (value []byte) { if s == nil { diff --git a/tg/tl_sticker_keyword_gen.go b/tg/tl_sticker_keyword_gen.go new file mode 100644 index 0000000000..1cd2d9b0e7 --- /dev/null +++ b/tg/tl_sticker_keyword_gen.go @@ -0,0 +1,201 @@ +// 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{} +) + +// StickerKeyword represents TL type `stickerKeyword#fcfeb29c`. +// +// See https://core.telegram.org/constructor/stickerKeyword for reference. +type StickerKeyword struct { + // DocumentID field of StickerKeyword. + DocumentID int64 + // Keyword field of StickerKeyword. + Keyword []string +} + +// StickerKeywordTypeID is TL type id of StickerKeyword. +const StickerKeywordTypeID = 0xfcfeb29c + +// Ensuring interfaces in compile-time for StickerKeyword. +var ( + _ bin.Encoder = &StickerKeyword{} + _ bin.Decoder = &StickerKeyword{} + _ bin.BareEncoder = &StickerKeyword{} + _ bin.BareDecoder = &StickerKeyword{} +) + +func (s *StickerKeyword) Zero() bool { + if s == nil { + return true + } + if !(s.DocumentID == 0) { + return false + } + if !(s.Keyword == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StickerKeyword) String() string { + if s == nil { + return "StickerKeyword(nil)" + } + type Alias StickerKeyword + return fmt.Sprintf("StickerKeyword%+v", Alias(*s)) +} + +// FillFrom fills StickerKeyword from given interface. +func (s *StickerKeyword) FillFrom(from interface { + GetDocumentID() (value int64) + GetKeyword() (value []string) +}) { + s.DocumentID = from.GetDocumentID() + s.Keyword = from.GetKeyword() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StickerKeyword) TypeID() uint32 { + return StickerKeywordTypeID +} + +// TypeName returns name of type in TL schema. +func (*StickerKeyword) TypeName() string { + return "stickerKeyword" +} + +// TypeInfo returns info about TL type. +func (s *StickerKeyword) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "stickerKeyword", + ID: StickerKeywordTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "DocumentID", + SchemaName: "document_id", + }, + { + Name: "Keyword", + SchemaName: "keyword", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StickerKeyword) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode stickerKeyword#fcfeb29c as nil") + } + b.PutID(StickerKeywordTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StickerKeyword) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode stickerKeyword#fcfeb29c as nil") + } + b.PutLong(s.DocumentID) + b.PutVectorHeader(len(s.Keyword)) + for _, v := range s.Keyword { + b.PutString(v) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StickerKeyword) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode stickerKeyword#fcfeb29c to nil") + } + if err := b.ConsumeID(StickerKeywordTypeID); err != nil { + return fmt.Errorf("unable to decode stickerKeyword#fcfeb29c: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StickerKeyword) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode stickerKeyword#fcfeb29c to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode stickerKeyword#fcfeb29c: field document_id: %w", err) + } + s.DocumentID = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode stickerKeyword#fcfeb29c: field keyword: %w", err) + } + + if headerLen > 0 { + s.Keyword = make([]string, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode stickerKeyword#fcfeb29c: field keyword: %w", err) + } + s.Keyword = append(s.Keyword, value) + } + } + return nil +} + +// GetDocumentID returns value of DocumentID field. +func (s *StickerKeyword) GetDocumentID() (value int64) { + if s == nil { + return + } + return s.DocumentID +} + +// GetKeyword returns value of Keyword field. +func (s *StickerKeyword) GetKeyword() (value []string) { + if s == nil { + return + } + return s.Keyword +} diff --git a/tg/tl_sticker_keyword_slices_gen.go b/tg/tl_sticker_keyword_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_sticker_keyword_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_sticker_set_covered_gen.go b/tg/tl_sticker_set_covered_gen.go index f0f4f1f80a..30d2f5daec 100644 --- a/tg/tl_sticker_set_covered_gen.go +++ b/tg/tl_sticker_set_covered_gen.go @@ -383,7 +383,7 @@ func (s *StickerSetMultiCovered) MapCovers() (value DocumentClassArray) { return DocumentClassArray(s.Covers) } -// StickerSetFullCovered represents TL type `stickerSetFullCovered#1aed5ee5`. +// StickerSetFullCovered represents TL type `stickerSetFullCovered#40d13c0e`. // Stickerset preview with all stickers of the stickerset included. // Currently used only for custom emoji stickersets¹, to avoid a further call to // messages.getStickerSet². @@ -398,12 +398,14 @@ type StickerSetFullCovered struct { Set StickerSet // Emoji information about every sticker in the stickerset Packs []StickerPack + // Keywords field of StickerSetFullCovered. + Keywords []StickerKeyword // Stickers Documents []DocumentClass } // StickerSetFullCoveredTypeID is TL type id of StickerSetFullCovered. -const StickerSetFullCoveredTypeID = 0x1aed5ee5 +const StickerSetFullCoveredTypeID = 0x40d13c0e // construct implements constructor of StickerSetCoveredClass. func (s StickerSetFullCovered) construct() StickerSetCoveredClass { return &s } @@ -428,6 +430,9 @@ func (s *StickerSetFullCovered) Zero() bool { if !(s.Packs == nil) { return false } + if !(s.Keywords == nil) { + return false + } if !(s.Documents == nil) { return false } @@ -448,10 +453,12 @@ func (s *StickerSetFullCovered) String() string { func (s *StickerSetFullCovered) FillFrom(from interface { GetSet() (value StickerSet) GetPacks() (value []StickerPack) + GetKeywords() (value []StickerKeyword) GetDocuments() (value []DocumentClass) }) { s.Set = from.GetSet() s.Packs = from.GetPacks() + s.Keywords = from.GetKeywords() s.Documents = from.GetDocuments() } @@ -486,6 +493,10 @@ func (s *StickerSetFullCovered) TypeInfo() tdp.Type { Name: "Packs", SchemaName: "packs", }, + { + Name: "Keywords", + SchemaName: "keywords", + }, { Name: "Documents", SchemaName: "documents", @@ -497,7 +508,7 @@ func (s *StickerSetFullCovered) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (s *StickerSetFullCovered) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode stickerSetFullCovered#1aed5ee5 as nil") + return fmt.Errorf("can't encode stickerSetFullCovered#40d13c0e as nil") } b.PutID(StickerSetFullCoveredTypeID) return s.EncodeBare(b) @@ -506,24 +517,30 @@ func (s *StickerSetFullCovered) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *StickerSetFullCovered) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode stickerSetFullCovered#1aed5ee5 as nil") + return fmt.Errorf("can't encode stickerSetFullCovered#40d13c0e as nil") } if err := s.Set.Encode(b); err != nil { - return fmt.Errorf("unable to encode stickerSetFullCovered#1aed5ee5: field set: %w", err) + return fmt.Errorf("unable to encode stickerSetFullCovered#40d13c0e: field set: %w", err) } b.PutVectorHeader(len(s.Packs)) for idx, v := range s.Packs { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode stickerSetFullCovered#1aed5ee5: field packs element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode stickerSetFullCovered#40d13c0e: field packs element with index %d: %w", idx, err) + } + } + b.PutVectorHeader(len(s.Keywords)) + for idx, v := range s.Keywords { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode stickerSetFullCovered#40d13c0e: field keywords element with index %d: %w", idx, err) } } b.PutVectorHeader(len(s.Documents)) for idx, v := range s.Documents { if v == nil { - return fmt.Errorf("unable to encode stickerSetFullCovered#1aed5ee5: field documents element with index %d is nil", idx) + return fmt.Errorf("unable to encode stickerSetFullCovered#40d13c0e: field documents element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode stickerSetFullCovered#1aed5ee5: field documents element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode stickerSetFullCovered#40d13c0e: field documents element with index %d: %w", idx, err) } } return nil @@ -532,10 +549,10 @@ func (s *StickerSetFullCovered) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *StickerSetFullCovered) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode stickerSetFullCovered#1aed5ee5 to nil") + return fmt.Errorf("can't decode stickerSetFullCovered#40d13c0e to nil") } if err := b.ConsumeID(StickerSetFullCoveredTypeID); err != nil { - return fmt.Errorf("unable to decode stickerSetFullCovered#1aed5ee5: %w", err) + return fmt.Errorf("unable to decode stickerSetFullCovered#40d13c0e: %w", err) } return s.DecodeBare(b) } @@ -543,17 +560,17 @@ func (s *StickerSetFullCovered) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *StickerSetFullCovered) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode stickerSetFullCovered#1aed5ee5 to nil") + return fmt.Errorf("can't decode stickerSetFullCovered#40d13c0e to nil") } { if err := s.Set.Decode(b); err != nil { - return fmt.Errorf("unable to decode stickerSetFullCovered#1aed5ee5: field set: %w", err) + return fmt.Errorf("unable to decode stickerSetFullCovered#40d13c0e: field set: %w", err) } } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode stickerSetFullCovered#1aed5ee5: field packs: %w", err) + return fmt.Errorf("unable to decode stickerSetFullCovered#40d13c0e: field packs: %w", err) } if headerLen > 0 { @@ -562,7 +579,7 @@ func (s *StickerSetFullCovered) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value StickerPack if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode stickerSetFullCovered#1aed5ee5: field packs: %w", err) + return fmt.Errorf("unable to decode stickerSetFullCovered#40d13c0e: field packs: %w", err) } s.Packs = append(s.Packs, value) } @@ -570,7 +587,24 @@ func (s *StickerSetFullCovered) DecodeBare(b *bin.Buffer) error { { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode stickerSetFullCovered#1aed5ee5: field documents: %w", err) + return fmt.Errorf("unable to decode stickerSetFullCovered#40d13c0e: field keywords: %w", err) + } + + if headerLen > 0 { + s.Keywords = make([]StickerKeyword, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value StickerKeyword + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode stickerSetFullCovered#40d13c0e: field keywords: %w", err) + } + s.Keywords = append(s.Keywords, value) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode stickerSetFullCovered#40d13c0e: field documents: %w", err) } if headerLen > 0 { @@ -579,7 +613,7 @@ func (s *StickerSetFullCovered) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeDocument(b) if err != nil { - return fmt.Errorf("unable to decode stickerSetFullCovered#1aed5ee5: field documents: %w", err) + return fmt.Errorf("unable to decode stickerSetFullCovered#40d13c0e: field documents: %w", err) } s.Documents = append(s.Documents, value) } @@ -603,6 +637,14 @@ func (s *StickerSetFullCovered) GetPacks() (value []StickerPack) { return s.Packs } +// GetKeywords returns value of Keywords field. +func (s *StickerSetFullCovered) GetKeywords() (value []StickerKeyword) { + if s == nil { + return + } + return s.Keywords +} + // GetDocuments returns value of Documents field. func (s *StickerSetFullCovered) GetDocuments() (value []DocumentClass) { if s == nil { @@ -632,7 +674,7 @@ const StickerSetCoveredClassName = "StickerSetCovered" // switch v := g.(type) { // case *tg.StickerSetCovered: // stickerSetCovered#6410a5d2 // case *tg.StickerSetMultiCovered: // stickerSetMultiCovered#3407e51b -// case *tg.StickerSetFullCovered: // stickerSetFullCovered#1aed5ee5 +// case *tg.StickerSetFullCovered: // stickerSetFullCovered#40d13c0e // default: panic(v) // } type StickerSetCoveredClass interface { @@ -679,7 +721,7 @@ func DecodeStickerSetCovered(buf *bin.Buffer) (StickerSetCoveredClass, error) { } return &v, nil case StickerSetFullCoveredTypeID: - // Decoding stickerSetFullCovered#1aed5ee5. + // Decoding stickerSetFullCovered#40d13c0e. v := StickerSetFullCovered{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode StickerSetCoveredClass: %w", err) diff --git a/tg/tl_update_gen.go b/tg/tl_update_gen.go index a23ad70796..1174b2f0cd 100644 --- a/tg/tl_update_gen.go +++ b/tg/tl_update_gen.go @@ -1275,7 +1275,7 @@ func (u *UpdateUserStatus) GetStatus() (value UserStatusClass) { return u.Status } -// UpdateUserName represents TL type `updateUserName#c3f202e0`. +// UpdateUserName represents TL type `updateUserName#a7848924`. // Changes the user's first name, last name and username. // // See https://core.telegram.org/constructor/updateUserName for reference. @@ -1294,12 +1294,12 @@ type UpdateUserName struct { // Links: // 1) https://core.telegram.org/constructor/userFull LastName string - // New username. - Username string + // Usernames field of UpdateUserName. + Usernames []Username } // UpdateUserNameTypeID is TL type id of UpdateUserName. -const UpdateUserNameTypeID = 0xc3f202e0 +const UpdateUserNameTypeID = 0xa7848924 // construct implements constructor of UpdateClass. func (u UpdateUserName) construct() UpdateClass { return &u } @@ -1327,7 +1327,7 @@ func (u *UpdateUserName) Zero() bool { if !(u.LastName == "") { return false } - if !(u.Username == "") { + if !(u.Usernames == nil) { return false } @@ -1348,12 +1348,12 @@ func (u *UpdateUserName) FillFrom(from interface { GetUserID() (value int64) GetFirstName() (value string) GetLastName() (value string) - GetUsername() (value string) + GetUsernames() (value []Username) }) { u.UserID = from.GetUserID() u.FirstName = from.GetFirstName() u.LastName = from.GetLastName() - u.Username = from.GetUsername() + u.Usernames = from.GetUsernames() } // TypeID returns type id in TL schema. @@ -1392,8 +1392,8 @@ func (u *UpdateUserName) TypeInfo() tdp.Type { SchemaName: "last_name", }, { - Name: "Username", - SchemaName: "username", + Name: "Usernames", + SchemaName: "usernames", }, } return typ @@ -1402,7 +1402,7 @@ func (u *UpdateUserName) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (u *UpdateUserName) Encode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode updateUserName#c3f202e0 as nil") + return fmt.Errorf("can't encode updateUserName#a7848924 as nil") } b.PutID(UpdateUserNameTypeID) return u.EncodeBare(b) @@ -1411,22 +1411,27 @@ func (u *UpdateUserName) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (u *UpdateUserName) EncodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode updateUserName#c3f202e0 as nil") + return fmt.Errorf("can't encode updateUserName#a7848924 as nil") } b.PutLong(u.UserID) b.PutString(u.FirstName) b.PutString(u.LastName) - b.PutString(u.Username) + b.PutVectorHeader(len(u.Usernames)) + for idx, v := range u.Usernames { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode updateUserName#a7848924: field usernames element with index %d: %w", idx, err) + } + } return nil } // Decode implements bin.Decoder. func (u *UpdateUserName) Decode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode updateUserName#c3f202e0 to nil") + return fmt.Errorf("can't decode updateUserName#a7848924 to nil") } if err := b.ConsumeID(UpdateUserNameTypeID); err != nil { - return fmt.Errorf("unable to decode updateUserName#c3f202e0: %w", err) + return fmt.Errorf("unable to decode updateUserName#a7848924: %w", err) } return u.DecodeBare(b) } @@ -1434,35 +1439,45 @@ func (u *UpdateUserName) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (u *UpdateUserName) DecodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode updateUserName#c3f202e0 to nil") + return fmt.Errorf("can't decode updateUserName#a7848924 to nil") } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode updateUserName#c3f202e0: field user_id: %w", err) + return fmt.Errorf("unable to decode updateUserName#a7848924: field user_id: %w", err) } u.UserID = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode updateUserName#c3f202e0: field first_name: %w", err) + return fmt.Errorf("unable to decode updateUserName#a7848924: field first_name: %w", err) } u.FirstName = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode updateUserName#c3f202e0: field last_name: %w", err) + return fmt.Errorf("unable to decode updateUserName#a7848924: field last_name: %w", err) } u.LastName = value } { - value, err := b.String() + headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode updateUserName#c3f202e0: field username: %w", err) + return fmt.Errorf("unable to decode updateUserName#a7848924: field usernames: %w", err) + } + + if headerLen > 0 { + u.Usernames = make([]Username, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value Username + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode updateUserName#a7848924: field usernames: %w", err) + } + u.Usernames = append(u.Usernames, value) } - u.Username = value } return nil } @@ -1491,12 +1506,12 @@ func (u *UpdateUserName) GetLastName() (value string) { return u.LastName } -// GetUsername returns value of Username field. -func (u *UpdateUserName) GetUsername() (value string) { +// GetUsernames returns value of Usernames field. +func (u *UpdateUserName) GetUsernames() (value []Username) { if u == nil { return } - return u.Username + return u.Usernames } // UpdateUserPhoto represents TL type `updateUserPhoto#f227868c`. @@ -8930,7 +8945,7 @@ func (u *UpdateReadChannelOutbox) GetMaxID() (value int) { return u.MaxID } -// UpdateDraftMessage represents TL type `updateDraftMessage#ee2bb969`. +// UpdateDraftMessage represents TL type `updateDraftMessage#1b49ec6d`. // Notifies a change of a message draft¹. // // Links: @@ -8938,14 +8953,20 @@ func (u *UpdateReadChannelOutbox) GetMaxID() (value int) { // // See https://core.telegram.org/constructor/updateDraftMessage for reference. type UpdateDraftMessage struct { + // Flags field of UpdateDraftMessage. + Flags bin.Fields // The peer to which the draft is associated Peer PeerClass + // TopMsgID field of UpdateDraftMessage. + // + // Use SetTopMsgID and GetTopMsgID helpers. + TopMsgID int // The draft Draft DraftMessageClass } // UpdateDraftMessageTypeID is TL type id of UpdateDraftMessage. -const UpdateDraftMessageTypeID = 0xee2bb969 +const UpdateDraftMessageTypeID = 0x1b49ec6d // construct implements constructor of UpdateClass. func (u UpdateDraftMessage) construct() UpdateClass { return &u } @@ -8964,9 +8985,15 @@ func (u *UpdateDraftMessage) Zero() bool { if u == nil { return true } + if !(u.Flags.Zero()) { + return false + } if !(u.Peer == nil) { return false } + if !(u.TopMsgID == 0) { + return false + } if !(u.Draft == nil) { return false } @@ -8986,9 +9013,14 @@ func (u *UpdateDraftMessage) String() string { // FillFrom fills UpdateDraftMessage from given interface. func (u *UpdateDraftMessage) FillFrom(from interface { GetPeer() (value PeerClass) + GetTopMsgID() (value int, ok bool) GetDraft() (value DraftMessageClass) }) { u.Peer = from.GetPeer() + if val, ok := from.GetTopMsgID(); ok { + u.TopMsgID = val + } + u.Draft = from.GetDraft() } @@ -9019,6 +9051,11 @@ func (u *UpdateDraftMessage) TypeInfo() tdp.Type { Name: "Peer", SchemaName: "peer", }, + { + Name: "TopMsgID", + SchemaName: "top_msg_id", + Null: !u.Flags.Has(0), + }, { Name: "Draft", SchemaName: "draft", @@ -9027,10 +9064,17 @@ func (u *UpdateDraftMessage) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (u *UpdateDraftMessage) SetFlags() { + if !(u.TopMsgID == 0) { + u.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (u *UpdateDraftMessage) Encode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode updateDraftMessage#ee2bb969 as nil") + return fmt.Errorf("can't encode updateDraftMessage#1b49ec6d as nil") } b.PutID(UpdateDraftMessageTypeID) return u.EncodeBare(b) @@ -9039,19 +9083,26 @@ func (u *UpdateDraftMessage) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (u *UpdateDraftMessage) EncodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode updateDraftMessage#ee2bb969 as nil") + return fmt.Errorf("can't encode updateDraftMessage#1b49ec6d as nil") + } + u.SetFlags() + if err := u.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode updateDraftMessage#1b49ec6d: field flags: %w", err) } if u.Peer == nil { - return fmt.Errorf("unable to encode updateDraftMessage#ee2bb969: field peer is nil") + return fmt.Errorf("unable to encode updateDraftMessage#1b49ec6d: field peer is nil") } if err := u.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode updateDraftMessage#ee2bb969: field peer: %w", err) + return fmt.Errorf("unable to encode updateDraftMessage#1b49ec6d: field peer: %w", err) + } + if u.Flags.Has(0) { + b.PutInt(u.TopMsgID) } if u.Draft == nil { - return fmt.Errorf("unable to encode updateDraftMessage#ee2bb969: field draft is nil") + return fmt.Errorf("unable to encode updateDraftMessage#1b49ec6d: field draft is nil") } if err := u.Draft.Encode(b); err != nil { - return fmt.Errorf("unable to encode updateDraftMessage#ee2bb969: field draft: %w", err) + return fmt.Errorf("unable to encode updateDraftMessage#1b49ec6d: field draft: %w", err) } return nil } @@ -9059,10 +9110,10 @@ func (u *UpdateDraftMessage) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (u *UpdateDraftMessage) Decode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode updateDraftMessage#ee2bb969 to nil") + return fmt.Errorf("can't decode updateDraftMessage#1b49ec6d to nil") } if err := b.ConsumeID(UpdateDraftMessageTypeID); err != nil { - return fmt.Errorf("unable to decode updateDraftMessage#ee2bb969: %w", err) + return fmt.Errorf("unable to decode updateDraftMessage#1b49ec6d: %w", err) } return u.DecodeBare(b) } @@ -9070,19 +9121,31 @@ func (u *UpdateDraftMessage) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (u *UpdateDraftMessage) DecodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode updateDraftMessage#ee2bb969 to nil") + return fmt.Errorf("can't decode updateDraftMessage#1b49ec6d to nil") + } + { + if err := u.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode updateDraftMessage#1b49ec6d: field flags: %w", err) + } } { value, err := DecodePeer(b) if err != nil { - return fmt.Errorf("unable to decode updateDraftMessage#ee2bb969: field peer: %w", err) + return fmt.Errorf("unable to decode updateDraftMessage#1b49ec6d: field peer: %w", err) } u.Peer = value } + if u.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode updateDraftMessage#1b49ec6d: field top_msg_id: %w", err) + } + u.TopMsgID = value + } { value, err := DecodeDraftMessage(b) if err != nil { - return fmt.Errorf("unable to decode updateDraftMessage#ee2bb969: field draft: %w", err) + return fmt.Errorf("unable to decode updateDraftMessage#1b49ec6d: field draft: %w", err) } u.Draft = value } @@ -9097,6 +9160,24 @@ func (u *UpdateDraftMessage) GetPeer() (value PeerClass) { return u.Peer } +// SetTopMsgID sets value of TopMsgID conditional field. +func (u *UpdateDraftMessage) SetTopMsgID(value int) { + u.Flags.Set(0) + u.TopMsgID = value +} + +// GetTopMsgID returns value of TopMsgID conditional field and +// boolean which is true if field was set. +func (u *UpdateDraftMessage) GetTopMsgID() (value int, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(0) { + return value, false + } + return u.TopMsgID, true +} + // GetDraft returns value of Draft field. func (u *UpdateDraftMessage) GetDraft() (value DraftMessageClass) { if u == nil { @@ -11685,7 +11766,7 @@ func (u *UpdateFavedStickers) DecodeBare(b *bin.Buffer) error { return nil } -// UpdateChannelReadMessagesContents represents TL type `updateChannelReadMessagesContents#44bdd535`. +// UpdateChannelReadMessagesContents represents TL type `updateChannelReadMessagesContents#ea29055d`. // The specified channel/supergroup¹ messages were read // // Links: @@ -11693,17 +11774,23 @@ func (u *UpdateFavedStickers) DecodeBare(b *bin.Buffer) error { // // See https://core.telegram.org/constructor/updateChannelReadMessagesContents for reference. type UpdateChannelReadMessagesContents struct { + // Flags field of UpdateChannelReadMessagesContents. + Flags bin.Fields // Channel/supergroup¹ ID // // Links: // 1) https://core.telegram.org/api/channel ChannelID int64 + // TopMsgID field of UpdateChannelReadMessagesContents. + // + // Use SetTopMsgID and GetTopMsgID helpers. + TopMsgID int // IDs of messages that were read Messages []int } // UpdateChannelReadMessagesContentsTypeID is TL type id of UpdateChannelReadMessagesContents. -const UpdateChannelReadMessagesContentsTypeID = 0x44bdd535 +const UpdateChannelReadMessagesContentsTypeID = 0xea29055d // construct implements constructor of UpdateClass. func (u UpdateChannelReadMessagesContents) construct() UpdateClass { return &u } @@ -11722,9 +11809,15 @@ func (u *UpdateChannelReadMessagesContents) Zero() bool { if u == nil { return true } + if !(u.Flags.Zero()) { + return false + } if !(u.ChannelID == 0) { return false } + if !(u.TopMsgID == 0) { + return false + } if !(u.Messages == nil) { return false } @@ -11744,9 +11837,14 @@ func (u *UpdateChannelReadMessagesContents) String() string { // FillFrom fills UpdateChannelReadMessagesContents from given interface. func (u *UpdateChannelReadMessagesContents) FillFrom(from interface { GetChannelID() (value int64) + GetTopMsgID() (value int, ok bool) GetMessages() (value []int) }) { u.ChannelID = from.GetChannelID() + if val, ok := from.GetTopMsgID(); ok { + u.TopMsgID = val + } + u.Messages = from.GetMessages() } @@ -11777,6 +11875,11 @@ func (u *UpdateChannelReadMessagesContents) TypeInfo() tdp.Type { Name: "ChannelID", SchemaName: "channel_id", }, + { + Name: "TopMsgID", + SchemaName: "top_msg_id", + Null: !u.Flags.Has(0), + }, { Name: "Messages", SchemaName: "messages", @@ -11785,10 +11888,17 @@ func (u *UpdateChannelReadMessagesContents) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (u *UpdateChannelReadMessagesContents) SetFlags() { + if !(u.TopMsgID == 0) { + u.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (u *UpdateChannelReadMessagesContents) Encode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode updateChannelReadMessagesContents#44bdd535 as nil") + return fmt.Errorf("can't encode updateChannelReadMessagesContents#ea29055d as nil") } b.PutID(UpdateChannelReadMessagesContentsTypeID) return u.EncodeBare(b) @@ -11797,9 +11907,16 @@ func (u *UpdateChannelReadMessagesContents) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (u *UpdateChannelReadMessagesContents) EncodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode updateChannelReadMessagesContents#44bdd535 as nil") + return fmt.Errorf("can't encode updateChannelReadMessagesContents#ea29055d as nil") + } + u.SetFlags() + if err := u.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode updateChannelReadMessagesContents#ea29055d: field flags: %w", err) } b.PutLong(u.ChannelID) + if u.Flags.Has(0) { + b.PutInt(u.TopMsgID) + } b.PutVectorHeader(len(u.Messages)) for _, v := range u.Messages { b.PutInt(v) @@ -11810,10 +11927,10 @@ func (u *UpdateChannelReadMessagesContents) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (u *UpdateChannelReadMessagesContents) Decode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode updateChannelReadMessagesContents#44bdd535 to nil") + return fmt.Errorf("can't decode updateChannelReadMessagesContents#ea29055d to nil") } if err := b.ConsumeID(UpdateChannelReadMessagesContentsTypeID); err != nil { - return fmt.Errorf("unable to decode updateChannelReadMessagesContents#44bdd535: %w", err) + return fmt.Errorf("unable to decode updateChannelReadMessagesContents#ea29055d: %w", err) } return u.DecodeBare(b) } @@ -11821,19 +11938,31 @@ func (u *UpdateChannelReadMessagesContents) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (u *UpdateChannelReadMessagesContents) DecodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode updateChannelReadMessagesContents#44bdd535 to nil") + return fmt.Errorf("can't decode updateChannelReadMessagesContents#ea29055d to nil") + } + { + if err := u.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode updateChannelReadMessagesContents#ea29055d: field flags: %w", err) + } } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode updateChannelReadMessagesContents#44bdd535: field channel_id: %w", err) + return fmt.Errorf("unable to decode updateChannelReadMessagesContents#ea29055d: field channel_id: %w", err) } u.ChannelID = value } + if u.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode updateChannelReadMessagesContents#ea29055d: field top_msg_id: %w", err) + } + u.TopMsgID = value + } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode updateChannelReadMessagesContents#44bdd535: field messages: %w", err) + return fmt.Errorf("unable to decode updateChannelReadMessagesContents#ea29055d: field messages: %w", err) } if headerLen > 0 { @@ -11842,7 +11971,7 @@ func (u *UpdateChannelReadMessagesContents) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode updateChannelReadMessagesContents#44bdd535: field messages: %w", err) + return fmt.Errorf("unable to decode updateChannelReadMessagesContents#ea29055d: field messages: %w", err) } u.Messages = append(u.Messages, value) } @@ -11858,6 +11987,24 @@ func (u *UpdateChannelReadMessagesContents) GetChannelID() (value int64) { return u.ChannelID } +// SetTopMsgID sets value of TopMsgID conditional field. +func (u *UpdateChannelReadMessagesContents) SetTopMsgID(value int) { + u.Flags.Set(0) + u.TopMsgID = value +} + +// GetTopMsgID returns value of TopMsgID conditional field and +// boolean which is true if field was set. +func (u *UpdateChannelReadMessagesContents) GetTopMsgID() (value int, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(0) { + return value, false + } + return u.TopMsgID, true +} + // GetMessages returns value of Messages field. func (u *UpdateChannelReadMessagesContents) GetMessages() (value []int) { if u == nil { @@ -19350,7 +19497,7 @@ func (u *UpdateBotChatInviteRequester) GetQts() (value int) { return u.Qts } -// UpdateMessageReactions represents TL type `updateMessageReactions#154798c3`. +// UpdateMessageReactions represents TL type `updateMessageReactions#5e1b3cb8`. // New message reactions »¹ are available // // Links: @@ -19358,16 +19505,22 @@ func (u *UpdateBotChatInviteRequester) GetQts() (value int) { // // See https://core.telegram.org/constructor/updateMessageReactions for reference. type UpdateMessageReactions struct { + // Flags field of UpdateMessageReactions. + Flags bin.Fields // Peer Peer PeerClass // Message ID MsgID int + // TopMsgID field of UpdateMessageReactions. + // + // Use SetTopMsgID and GetTopMsgID helpers. + TopMsgID int // Reactions Reactions MessageReactions } // UpdateMessageReactionsTypeID is TL type id of UpdateMessageReactions. -const UpdateMessageReactionsTypeID = 0x154798c3 +const UpdateMessageReactionsTypeID = 0x5e1b3cb8 // construct implements constructor of UpdateClass. func (u UpdateMessageReactions) construct() UpdateClass { return &u } @@ -19386,12 +19539,18 @@ func (u *UpdateMessageReactions) Zero() bool { if u == nil { return true } + if !(u.Flags.Zero()) { + return false + } if !(u.Peer == nil) { return false } if !(u.MsgID == 0) { return false } + if !(u.TopMsgID == 0) { + return false + } if !(u.Reactions.Zero()) { return false } @@ -19412,10 +19571,15 @@ func (u *UpdateMessageReactions) String() string { func (u *UpdateMessageReactions) FillFrom(from interface { GetPeer() (value PeerClass) GetMsgID() (value int) + GetTopMsgID() (value int, ok bool) GetReactions() (value MessageReactions) }) { u.Peer = from.GetPeer() u.MsgID = from.GetMsgID() + if val, ok := from.GetTopMsgID(); ok { + u.TopMsgID = val + } + u.Reactions = from.GetReactions() } @@ -19450,6 +19614,11 @@ func (u *UpdateMessageReactions) TypeInfo() tdp.Type { Name: "MsgID", SchemaName: "msg_id", }, + { + Name: "TopMsgID", + SchemaName: "top_msg_id", + Null: !u.Flags.Has(0), + }, { Name: "Reactions", SchemaName: "reactions", @@ -19458,10 +19627,17 @@ func (u *UpdateMessageReactions) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (u *UpdateMessageReactions) SetFlags() { + if !(u.TopMsgID == 0) { + u.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (u *UpdateMessageReactions) Encode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode updateMessageReactions#154798c3 as nil") + return fmt.Errorf("can't encode updateMessageReactions#5e1b3cb8 as nil") } b.PutID(UpdateMessageReactionsTypeID) return u.EncodeBare(b) @@ -19470,17 +19646,24 @@ func (u *UpdateMessageReactions) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (u *UpdateMessageReactions) EncodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode updateMessageReactions#154798c3 as nil") + return fmt.Errorf("can't encode updateMessageReactions#5e1b3cb8 as nil") + } + u.SetFlags() + if err := u.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode updateMessageReactions#5e1b3cb8: field flags: %w", err) } if u.Peer == nil { - return fmt.Errorf("unable to encode updateMessageReactions#154798c3: field peer is nil") + return fmt.Errorf("unable to encode updateMessageReactions#5e1b3cb8: field peer is nil") } if err := u.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode updateMessageReactions#154798c3: field peer: %w", err) + return fmt.Errorf("unable to encode updateMessageReactions#5e1b3cb8: field peer: %w", err) } b.PutInt(u.MsgID) + if u.Flags.Has(0) { + b.PutInt(u.TopMsgID) + } if err := u.Reactions.Encode(b); err != nil { - return fmt.Errorf("unable to encode updateMessageReactions#154798c3: field reactions: %w", err) + return fmt.Errorf("unable to encode updateMessageReactions#5e1b3cb8: field reactions: %w", err) } return nil } @@ -19488,10 +19671,10 @@ func (u *UpdateMessageReactions) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (u *UpdateMessageReactions) Decode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode updateMessageReactions#154798c3 to nil") + return fmt.Errorf("can't decode updateMessageReactions#5e1b3cb8 to nil") } if err := b.ConsumeID(UpdateMessageReactionsTypeID); err != nil { - return fmt.Errorf("unable to decode updateMessageReactions#154798c3: %w", err) + return fmt.Errorf("unable to decode updateMessageReactions#5e1b3cb8: %w", err) } return u.DecodeBare(b) } @@ -19499,25 +19682,37 @@ func (u *UpdateMessageReactions) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (u *UpdateMessageReactions) DecodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode updateMessageReactions#154798c3 to nil") + return fmt.Errorf("can't decode updateMessageReactions#5e1b3cb8 to nil") + } + { + if err := u.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode updateMessageReactions#5e1b3cb8: field flags: %w", err) + } } { value, err := DecodePeer(b) if err != nil { - return fmt.Errorf("unable to decode updateMessageReactions#154798c3: field peer: %w", err) + return fmt.Errorf("unable to decode updateMessageReactions#5e1b3cb8: field peer: %w", err) } u.Peer = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode updateMessageReactions#154798c3: field msg_id: %w", err) + return fmt.Errorf("unable to decode updateMessageReactions#5e1b3cb8: field msg_id: %w", err) } u.MsgID = value } + if u.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode updateMessageReactions#5e1b3cb8: field top_msg_id: %w", err) + } + u.TopMsgID = value + } { if err := u.Reactions.Decode(b); err != nil { - return fmt.Errorf("unable to decode updateMessageReactions#154798c3: field reactions: %w", err) + return fmt.Errorf("unable to decode updateMessageReactions#5e1b3cb8: field reactions: %w", err) } } return nil @@ -19539,6 +19734,24 @@ func (u *UpdateMessageReactions) GetMsgID() (value int) { return u.MsgID } +// SetTopMsgID sets value of TopMsgID conditional field. +func (u *UpdateMessageReactions) SetTopMsgID(value int) { + u.Flags.Set(0) + u.TopMsgID = value +} + +// GetTopMsgID returns value of TopMsgID conditional field and +// boolean which is true if field was set. +func (u *UpdateMessageReactions) GetTopMsgID() (value int, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(0) { + return value, false + } + return u.TopMsgID, true +} + // GetReactions returns value of Reactions field. func (u *UpdateMessageReactions) GetReactions() (value MessageReactions) { if u == nil { @@ -21245,6 +21458,206 @@ func (u *UpdateMessageExtendedMedia) GetExtendedMedia() (value MessageExtendedMe return u.ExtendedMedia } +// UpdateChannelPinnedTopic represents TL type `updateChannelPinnedTopic#f694b0ae`. +// +// See https://core.telegram.org/constructor/updateChannelPinnedTopic for reference. +type UpdateChannelPinnedTopic struct { + // Flags field of UpdateChannelPinnedTopic. + Flags bin.Fields + // ChannelID field of UpdateChannelPinnedTopic. + ChannelID int64 + // TopicID field of UpdateChannelPinnedTopic. + // + // Use SetTopicID and GetTopicID helpers. + TopicID int +} + +// UpdateChannelPinnedTopicTypeID is TL type id of UpdateChannelPinnedTopic. +const UpdateChannelPinnedTopicTypeID = 0xf694b0ae + +// construct implements constructor of UpdateClass. +func (u UpdateChannelPinnedTopic) construct() UpdateClass { return &u } + +// Ensuring interfaces in compile-time for UpdateChannelPinnedTopic. +var ( + _ bin.Encoder = &UpdateChannelPinnedTopic{} + _ bin.Decoder = &UpdateChannelPinnedTopic{} + _ bin.BareEncoder = &UpdateChannelPinnedTopic{} + _ bin.BareDecoder = &UpdateChannelPinnedTopic{} + + _ UpdateClass = &UpdateChannelPinnedTopic{} +) + +func (u *UpdateChannelPinnedTopic) Zero() bool { + if u == nil { + return true + } + if !(u.Flags.Zero()) { + return false + } + if !(u.ChannelID == 0) { + return false + } + if !(u.TopicID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *UpdateChannelPinnedTopic) String() string { + if u == nil { + return "UpdateChannelPinnedTopic(nil)" + } + type Alias UpdateChannelPinnedTopic + return fmt.Sprintf("UpdateChannelPinnedTopic%+v", Alias(*u)) +} + +// FillFrom fills UpdateChannelPinnedTopic from given interface. +func (u *UpdateChannelPinnedTopic) FillFrom(from interface { + GetChannelID() (value int64) + GetTopicID() (value int, ok bool) +}) { + u.ChannelID = from.GetChannelID() + if val, ok := from.GetTopicID(); ok { + u.TopicID = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*UpdateChannelPinnedTopic) TypeID() uint32 { + return UpdateChannelPinnedTopicTypeID +} + +// TypeName returns name of type in TL schema. +func (*UpdateChannelPinnedTopic) TypeName() string { + return "updateChannelPinnedTopic" +} + +// TypeInfo returns info about TL type. +func (u *UpdateChannelPinnedTopic) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "updateChannelPinnedTopic", + ID: UpdateChannelPinnedTopicTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ChannelID", + SchemaName: "channel_id", + }, + { + Name: "TopicID", + SchemaName: "topic_id", + Null: !u.Flags.Has(0), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (u *UpdateChannelPinnedTopic) SetFlags() { + if !(u.TopicID == 0) { + u.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (u *UpdateChannelPinnedTopic) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateChannelPinnedTopic#f694b0ae as nil") + } + b.PutID(UpdateChannelPinnedTopicTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *UpdateChannelPinnedTopic) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateChannelPinnedTopic#f694b0ae as nil") + } + u.SetFlags() + if err := u.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode updateChannelPinnedTopic#f694b0ae: field flags: %w", err) + } + b.PutLong(u.ChannelID) + if u.Flags.Has(0) { + b.PutInt(u.TopicID) + } + return nil +} + +// Decode implements bin.Decoder. +func (u *UpdateChannelPinnedTopic) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateChannelPinnedTopic#f694b0ae to nil") + } + if err := b.ConsumeID(UpdateChannelPinnedTopicTypeID); err != nil { + return fmt.Errorf("unable to decode updateChannelPinnedTopic#f694b0ae: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *UpdateChannelPinnedTopic) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateChannelPinnedTopic#f694b0ae to nil") + } + { + if err := u.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode updateChannelPinnedTopic#f694b0ae: field flags: %w", err) + } + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode updateChannelPinnedTopic#f694b0ae: field channel_id: %w", err) + } + u.ChannelID = value + } + if u.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode updateChannelPinnedTopic#f694b0ae: field topic_id: %w", err) + } + u.TopicID = value + } + return nil +} + +// GetChannelID returns value of ChannelID field. +func (u *UpdateChannelPinnedTopic) GetChannelID() (value int64) { + if u == nil { + return + } + return u.ChannelID +} + +// SetTopicID sets value of TopicID conditional field. +func (u *UpdateChannelPinnedTopic) SetTopicID(value int) { + u.Flags.Set(0) + u.TopicID = value +} + +// GetTopicID returns value of TopicID conditional field and +// boolean which is true if field was set. +func (u *UpdateChannelPinnedTopic) GetTopicID() (value int, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(0) { + return value, false + } + return u.TopicID, true +} + // UpdateClassName is schema name of UpdateClass. const UpdateClassName = "Update" @@ -21266,7 +21679,7 @@ const UpdateClassName = "Update" // case *tg.UpdateChatUserTyping: // updateChatUserTyping#83487af0 // case *tg.UpdateChatParticipants: // updateChatParticipants#7761198 // case *tg.UpdateUserStatus: // updateUserStatus#e5bdf8de -// case *tg.UpdateUserName: // updateUserName#c3f202e0 +// case *tg.UpdateUserName: // updateUserName#a7848924 // case *tg.UpdateUserPhoto: // updateUserPhoto#f227868c // case *tg.UpdateNewEncryptedMessage: // updateNewEncryptedMessage#12bcbd9a // case *tg.UpdateEncryptedChatTyping: // updateEncryptedChatTyping#1710f156 @@ -21301,7 +21714,7 @@ const UpdateClassName = "Update" // case *tg.UpdateEditMessage: // updateEditMessage#e40370a3 // case *tg.UpdateInlineBotCallbackQuery: // updateInlineBotCallbackQuery#691e9052 // case *tg.UpdateReadChannelOutbox: // updateReadChannelOutbox#b75f99a9 -// case *tg.UpdateDraftMessage: // updateDraftMessage#ee2bb969 +// case *tg.UpdateDraftMessage: // updateDraftMessage#1b49ec6d // case *tg.UpdateReadFeaturedStickers: // updateReadFeaturedStickers#571d2742 // case *tg.UpdateRecentStickers: // updateRecentStickers#9a422c20 // case *tg.UpdateConfig: // updateConfig#a229dd06 @@ -21317,7 +21730,7 @@ const UpdateClassName = "Update" // case *tg.UpdateLangPackTooLong: // updateLangPackTooLong#46560264 // case *tg.UpdateLangPack: // updateLangPack#56022f4d // case *tg.UpdateFavedStickers: // updateFavedStickers#e511996d -// case *tg.UpdateChannelReadMessagesContents: // updateChannelReadMessagesContents#44bdd535 +// case *tg.UpdateChannelReadMessagesContents: // updateChannelReadMessagesContents#ea29055d // case *tg.UpdateContactsReset: // updateContactsReset#7084a7be // case *tg.UpdateChannelAvailableMessages: // updateChannelAvailableMessages#b23fc698 // case *tg.UpdateDialogUnreadMark: // updateDialogUnreadMark#e16459c3 @@ -21354,7 +21767,7 @@ const UpdateClassName = "Update" // case *tg.UpdateBotCommands: // updateBotCommands#4d712f2e // case *tg.UpdatePendingJoinRequests: // updatePendingJoinRequests#7063c3db // case *tg.UpdateBotChatInviteRequester: // updateBotChatInviteRequester#11dfa986 -// case *tg.UpdateMessageReactions: // updateMessageReactions#154798c3 +// case *tg.UpdateMessageReactions: // updateMessageReactions#5e1b3cb8 // case *tg.UpdateAttachMenuBots: // updateAttachMenuBots#17b7a20b // case *tg.UpdateWebViewResultSent: // updateWebViewResultSent#1592b79d // case *tg.UpdateBotMenuButton: // updateBotMenuButton#14b85813 @@ -21366,6 +21779,7 @@ const UpdateClassName = "Update" // case *tg.UpdateRecentReactions: // updateRecentReactions#6f7863f4 // case *tg.UpdateMoveStickerSetToTop: // updateMoveStickerSetToTop#86fccf85 // case *tg.UpdateMessageExtendedMedia: // updateMessageExtendedMedia#5a73a98c +// case *tg.UpdateChannelPinnedTopic: // updateChannelPinnedTopic#f694b0ae // default: panic(v) // } type UpdateClass interface { @@ -21444,7 +21858,7 @@ func DecodeUpdate(buf *bin.Buffer) (UpdateClass, error) { } return &v, nil case UpdateUserNameTypeID: - // Decoding updateUserName#c3f202e0. + // Decoding updateUserName#a7848924. v := UpdateUserName{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) @@ -21689,7 +22103,7 @@ func DecodeUpdate(buf *bin.Buffer) (UpdateClass, error) { } return &v, nil case UpdateDraftMessageTypeID: - // Decoding updateDraftMessage#ee2bb969. + // Decoding updateDraftMessage#1b49ec6d. v := UpdateDraftMessage{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) @@ -21801,7 +22215,7 @@ func DecodeUpdate(buf *bin.Buffer) (UpdateClass, error) { } return &v, nil case UpdateChannelReadMessagesContentsTypeID: - // Decoding updateChannelReadMessagesContents#44bdd535. + // Decoding updateChannelReadMessagesContents#ea29055d. v := UpdateChannelReadMessagesContents{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) @@ -22060,7 +22474,7 @@ func DecodeUpdate(buf *bin.Buffer) (UpdateClass, error) { } return &v, nil case UpdateMessageReactionsTypeID: - // Decoding updateMessageReactions#154798c3. + // Decoding updateMessageReactions#5e1b3cb8. v := UpdateMessageReactions{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) @@ -22143,6 +22557,13 @@ func DecodeUpdate(buf *bin.Buffer) (UpdateClass, error) { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) } return &v, nil + case UpdateChannelPinnedTopicTypeID: + // Decoding updateChannelPinnedTopic#f694b0ae. + v := UpdateChannelPinnedTopic{} + 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 7b7c73c852..2773a03a82 100644 --- a/tg/tl_update_slices_gen.go +++ b/tg/tl_update_slices_gen.go @@ -1325,6 +1325,19 @@ func (s UpdateClassArray) AsUpdateMessageExtendedMedia() (to UpdateMessageExtend return to } +// AsUpdateChannelPinnedTopic returns copy with only UpdateChannelPinnedTopic constructors. +func (s UpdateClassArray) AsUpdateChannelPinnedTopic() (to UpdateChannelPinnedTopicArray) { + for _, elem := range s { + value, ok := elem.(*UpdateChannelPinnedTopic) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // UpdateNewMessageArray is adapter for slice of UpdateNewMessage. type UpdateNewMessageArray []UpdateNewMessage @@ -9174,3 +9187,85 @@ func (s *UpdateMessageExtendedMediaArray) Pop() (v UpdateMessageExtendedMedia, o return v, true } + +// UpdateChannelPinnedTopicArray is adapter for slice of UpdateChannelPinnedTopic. +type UpdateChannelPinnedTopicArray []UpdateChannelPinnedTopic + +// Sort sorts slice of UpdateChannelPinnedTopic. +func (s UpdateChannelPinnedTopicArray) Sort(less func(a, b UpdateChannelPinnedTopic) bool) UpdateChannelPinnedTopicArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of UpdateChannelPinnedTopic. +func (s UpdateChannelPinnedTopicArray) SortStable(less func(a, b UpdateChannelPinnedTopic) bool) UpdateChannelPinnedTopicArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of UpdateChannelPinnedTopic. +func (s UpdateChannelPinnedTopicArray) Retain(keep func(x UpdateChannelPinnedTopic) bool) UpdateChannelPinnedTopicArray { + 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 UpdateChannelPinnedTopicArray) First() (v UpdateChannelPinnedTopic, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s UpdateChannelPinnedTopicArray) Last() (v UpdateChannelPinnedTopic, 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 *UpdateChannelPinnedTopicArray) PopFirst() (v UpdateChannelPinnedTopic, 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 UpdateChannelPinnedTopic + 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 *UpdateChannelPinnedTopicArray) Pop() (v UpdateChannelPinnedTopic, 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_gen.go b/tg/tl_user_gen.go index edd5feb694..2d202e8629 100644 --- a/tg/tl_user_gen.go +++ b/tg/tl_user_gen.go @@ -166,7 +166,7 @@ func (u *UserEmpty) GetID() (value int64) { return u.ID } -// User represents TL type `user#5d99adee`. +// User represents TL type `user#8f97c628`. // Indicates info about a certain user // // See https://core.telegram.org/constructor/user for reference. @@ -222,6 +222,8 @@ type User struct { // Links: // 1) https://core.telegram.org/api/bots/attach AttachMenuEnabled bool + // Flags2 field of User. + Flags2 bin.Fields // ID of the user ID int64 // Access hash of the user @@ -275,10 +277,14 @@ type User struct { // // Use SetEmojiStatus and GetEmojiStatus helpers. EmojiStatus EmojiStatusClass + // Usernames field of User. + // + // Use SetUsernames and GetUsernames helpers. + Usernames []Username } // UserTypeID is TL type id of User. -const UserTypeID = 0x5d99adee +const UserTypeID = 0x8f97c628 // construct implements constructor of UserClass. func (u User) construct() UserClass { return &u } @@ -354,6 +360,9 @@ func (u *User) Zero() bool { if !(u.AttachMenuEnabled == false) { return false } + if !(u.Flags2.Zero()) { + return false + } if !(u.ID == 0) { return false } @@ -393,6 +402,9 @@ func (u *User) Zero() bool { if !(u.EmojiStatus == nil) { return false } + if !(u.Usernames == nil) { + return false + } return true } @@ -439,6 +451,7 @@ func (u *User) FillFrom(from interface { GetBotInlinePlaceholder() (value string, ok bool) GetLangCode() (value string, ok bool) GetEmojiStatus() (value EmojiStatusClass, ok bool) + GetUsernames() (value []Username, ok bool) }) { u.Self = from.GetSelf() u.Contact = from.GetContact() @@ -507,6 +520,10 @@ func (u *User) FillFrom(from interface { u.EmojiStatus = val } + if val, ok := from.GetUsernames(); ok { + u.Usernames = val + } + } // TypeID returns type id in TL schema. @@ -686,6 +703,11 @@ func (u *User) TypeInfo() tdp.Type { SchemaName: "emoji_status", Null: !u.Flags.Has(30), }, + { + Name: "Usernames", + SchemaName: "usernames", + Null: !u.Flags2.Has(0), + }, } return typ } @@ -782,12 +804,15 @@ func (u *User) SetFlags() { if !(u.EmojiStatus == nil) { u.Flags.Set(30) } + if !(u.Usernames == nil) { + u.Flags2.Set(0) + } } // Encode implements bin.Encoder. func (u *User) Encode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode user#5d99adee as nil") + return fmt.Errorf("can't encode user#8f97c628 as nil") } b.PutID(UserTypeID) return u.EncodeBare(b) @@ -796,11 +821,14 @@ func (u *User) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (u *User) EncodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode user#5d99adee as nil") + return fmt.Errorf("can't encode user#8f97c628 as nil") } u.SetFlags() if err := u.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode user#5d99adee: field flags: %w", err) + return fmt.Errorf("unable to encode user#8f97c628: field flags: %w", err) + } + if err := u.Flags2.Encode(b); err != nil { + return fmt.Errorf("unable to encode user#8f97c628: field flags2: %w", err) } b.PutLong(u.ID) if u.Flags.Has(0) { @@ -820,18 +848,18 @@ func (u *User) EncodeBare(b *bin.Buffer) error { } if u.Flags.Has(5) { if u.Photo == nil { - return fmt.Errorf("unable to encode user#5d99adee: field photo is nil") + return fmt.Errorf("unable to encode user#8f97c628: field photo is nil") } if err := u.Photo.Encode(b); err != nil { - return fmt.Errorf("unable to encode user#5d99adee: field photo: %w", err) + return fmt.Errorf("unable to encode user#8f97c628: field photo: %w", err) } } if u.Flags.Has(6) { if u.Status == nil { - return fmt.Errorf("unable to encode user#5d99adee: field status is nil") + return fmt.Errorf("unable to encode user#8f97c628: field status is nil") } if err := u.Status.Encode(b); err != nil { - return fmt.Errorf("unable to encode user#5d99adee: field status: %w", err) + return fmt.Errorf("unable to encode user#8f97c628: field status: %w", err) } } if u.Flags.Has(14) { @@ -841,7 +869,7 @@ func (u *User) EncodeBare(b *bin.Buffer) error { b.PutVectorHeader(len(u.RestrictionReason)) for idx, v := range u.RestrictionReason { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode user#5d99adee: field restriction_reason element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode user#8f97c628: field restriction_reason element with index %d: %w", idx, err) } } } @@ -853,10 +881,18 @@ func (u *User) EncodeBare(b *bin.Buffer) error { } if u.Flags.Has(30) { if u.EmojiStatus == nil { - return fmt.Errorf("unable to encode user#5d99adee: field emoji_status is nil") + return fmt.Errorf("unable to encode user#8f97c628: field emoji_status is nil") } if err := u.EmojiStatus.Encode(b); err != nil { - return fmt.Errorf("unable to encode user#5d99adee: field emoji_status: %w", err) + return fmt.Errorf("unable to encode user#8f97c628: field emoji_status: %w", err) + } + } + if u.Flags2.Has(0) { + b.PutVectorHeader(len(u.Usernames)) + for idx, v := range u.Usernames { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode user#8f97c628: field usernames element with index %d: %w", idx, err) + } } } return nil @@ -865,10 +901,10 @@ func (u *User) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (u *User) Decode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode user#5d99adee to nil") + return fmt.Errorf("can't decode user#8f97c628 to nil") } if err := b.ConsumeID(UserTypeID); err != nil { - return fmt.Errorf("unable to decode user#5d99adee: %w", err) + return fmt.Errorf("unable to decode user#8f97c628: %w", err) } return u.DecodeBare(b) } @@ -876,11 +912,11 @@ func (u *User) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (u *User) DecodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode user#5d99adee to nil") + return fmt.Errorf("can't decode user#8f97c628 to nil") } { if err := u.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode user#5d99adee: field flags: %w", err) + return fmt.Errorf("unable to decode user#8f97c628: field flags: %w", err) } } u.Self = u.Flags.Has(10) @@ -901,73 +937,78 @@ func (u *User) DecodeBare(b *bin.Buffer) error { u.BotAttachMenu = u.Flags.Has(27) u.Premium = u.Flags.Has(28) u.AttachMenuEnabled = u.Flags.Has(29) + { + if err := u.Flags2.Decode(b); err != nil { + return fmt.Errorf("unable to decode user#8f97c628: field flags2: %w", err) + } + } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode user#5d99adee: field id: %w", err) + return fmt.Errorf("unable to decode user#8f97c628: field id: %w", err) } u.ID = value } if u.Flags.Has(0) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode user#5d99adee: field access_hash: %w", err) + return fmt.Errorf("unable to decode user#8f97c628: field access_hash: %w", err) } u.AccessHash = value } if u.Flags.Has(1) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode user#5d99adee: field first_name: %w", err) + return fmt.Errorf("unable to decode user#8f97c628: field first_name: %w", err) } u.FirstName = value } if u.Flags.Has(2) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode user#5d99adee: field last_name: %w", err) + return fmt.Errorf("unable to decode user#8f97c628: field last_name: %w", err) } u.LastName = value } if u.Flags.Has(3) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode user#5d99adee: field username: %w", err) + return fmt.Errorf("unable to decode user#8f97c628: field username: %w", err) } u.Username = value } if u.Flags.Has(4) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode user#5d99adee: field phone: %w", err) + return fmt.Errorf("unable to decode user#8f97c628: field phone: %w", err) } u.Phone = value } if u.Flags.Has(5) { value, err := DecodeUserProfilePhoto(b) if err != nil { - return fmt.Errorf("unable to decode user#5d99adee: field photo: %w", err) + return fmt.Errorf("unable to decode user#8f97c628: field photo: %w", err) } u.Photo = value } if u.Flags.Has(6) { value, err := DecodeUserStatus(b) if err != nil { - return fmt.Errorf("unable to decode user#5d99adee: field status: %w", err) + return fmt.Errorf("unable to decode user#8f97c628: field status: %w", err) } u.Status = value } if u.Flags.Has(14) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode user#5d99adee: field bot_info_version: %w", err) + return fmt.Errorf("unable to decode user#8f97c628: field bot_info_version: %w", err) } u.BotInfoVersion = value } if u.Flags.Has(18) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode user#5d99adee: field restriction_reason: %w", err) + return fmt.Errorf("unable to decode user#8f97c628: field restriction_reason: %w", err) } if headerLen > 0 { @@ -976,7 +1017,7 @@ func (u *User) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value RestrictionReason if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode user#5d99adee: field restriction_reason: %w", err) + return fmt.Errorf("unable to decode user#8f97c628: field restriction_reason: %w", err) } u.RestrictionReason = append(u.RestrictionReason, value) } @@ -984,24 +1025,41 @@ func (u *User) DecodeBare(b *bin.Buffer) error { if u.Flags.Has(19) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode user#5d99adee: field bot_inline_placeholder: %w", err) + return fmt.Errorf("unable to decode user#8f97c628: field bot_inline_placeholder: %w", err) } u.BotInlinePlaceholder = value } if u.Flags.Has(22) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode user#5d99adee: field lang_code: %w", err) + return fmt.Errorf("unable to decode user#8f97c628: field lang_code: %w", err) } u.LangCode = value } if u.Flags.Has(30) { value, err := DecodeEmojiStatus(b) if err != nil { - return fmt.Errorf("unable to decode user#5d99adee: field emoji_status: %w", err) + return fmt.Errorf("unable to decode user#8f97c628: field emoji_status: %w", err) } u.EmojiStatus = value } + if u.Flags2.Has(0) { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode user#8f97c628: field usernames: %w", err) + } + + if headerLen > 0 { + u.Usernames = make([]Username, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value Username + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode user#8f97c628: field usernames: %w", err) + } + u.Usernames = append(u.Usernames, value) + } + } return nil } @@ -1571,6 +1629,24 @@ func (u *User) GetEmojiStatus() (value EmojiStatusClass, ok bool) { return u.EmojiStatus, true } +// SetUsernames sets value of Usernames conditional field. +func (u *User) SetUsernames(value []Username) { + u.Flags2.Set(0) + u.Usernames = value +} + +// GetUsernames returns value of Usernames conditional field and +// boolean which is true if field was set. +func (u *User) GetUsernames() (value []Username, ok bool) { + if u == nil { + return + } + if !u.Flags2.Has(0) { + return value, false + } + return u.Usernames, true +} + // UserClassName is schema name of UserClass. const UserClassName = "User" @@ -1586,7 +1662,7 @@ const UserClassName = "User" // } // switch v := g.(type) { // case *tg.UserEmpty: // userEmpty#d3bc4b7a -// case *tg.User: // user#5d99adee +// case *tg.User: // user#8f97c628 // default: panic(v) // } type UserClass interface { @@ -1661,7 +1737,7 @@ func DecodeUser(buf *bin.Buffer) (UserClass, error) { } return &v, nil case UserTypeID: - // Decoding user#5d99adee. + // Decoding user#8f97c628. v := User{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode UserClass: %w", err) diff --git a/tg/tl_username_gen.go b/tg/tl_username_gen.go new file mode 100644 index 0000000000..fe1964da85 --- /dev/null +++ b/tg/tl_username_gen.go @@ -0,0 +1,249 @@ +// 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{} +) + +// Username represents TL type `username#b4073647`. +// +// See https://core.telegram.org/constructor/username for reference. +type Username struct { + // Flags field of Username. + Flags bin.Fields + // Editable field of Username. + Editable bool + // Active field of Username. + Active bool + // Username field of Username. + Username string +} + +// UsernameTypeID is TL type id of Username. +const UsernameTypeID = 0xb4073647 + +// Ensuring interfaces in compile-time for Username. +var ( + _ bin.Encoder = &Username{} + _ bin.Decoder = &Username{} + _ bin.BareEncoder = &Username{} + _ bin.BareDecoder = &Username{} +) + +func (u *Username) Zero() bool { + if u == nil { + return true + } + if !(u.Flags.Zero()) { + return false + } + if !(u.Editable == false) { + return false + } + if !(u.Active == false) { + return false + } + if !(u.Username == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *Username) String() string { + if u == nil { + return "Username(nil)" + } + type Alias Username + return fmt.Sprintf("Username%+v", Alias(*u)) +} + +// FillFrom fills Username from given interface. +func (u *Username) FillFrom(from interface { + GetEditable() (value bool) + GetActive() (value bool) + GetUsername() (value string) +}) { + u.Editable = from.GetEditable() + u.Active = from.GetActive() + u.Username = from.GetUsername() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*Username) TypeID() uint32 { + return UsernameTypeID +} + +// TypeName returns name of type in TL schema. +func (*Username) TypeName() string { + return "username" +} + +// TypeInfo returns info about TL type. +func (u *Username) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "username", + ID: UsernameTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Editable", + SchemaName: "editable", + Null: !u.Flags.Has(0), + }, + { + Name: "Active", + SchemaName: "active", + Null: !u.Flags.Has(1), + }, + { + Name: "Username", + SchemaName: "username", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (u *Username) SetFlags() { + if !(u.Editable == false) { + u.Flags.Set(0) + } + if !(u.Active == false) { + u.Flags.Set(1) + } +} + +// Encode implements bin.Encoder. +func (u *Username) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode username#b4073647 as nil") + } + b.PutID(UsernameTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *Username) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode username#b4073647 as nil") + } + u.SetFlags() + if err := u.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode username#b4073647: field flags: %w", err) + } + b.PutString(u.Username) + return nil +} + +// Decode implements bin.Decoder. +func (u *Username) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode username#b4073647 to nil") + } + if err := b.ConsumeID(UsernameTypeID); err != nil { + return fmt.Errorf("unable to decode username#b4073647: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *Username) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode username#b4073647 to nil") + } + { + if err := u.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode username#b4073647: field flags: %w", err) + } + } + u.Editable = u.Flags.Has(0) + u.Active = u.Flags.Has(1) + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode username#b4073647: field username: %w", err) + } + u.Username = value + } + return nil +} + +// SetEditable sets value of Editable conditional field. +func (u *Username) SetEditable(value bool) { + if value { + u.Flags.Set(0) + u.Editable = true + } else { + u.Flags.Unset(0) + u.Editable = false + } +} + +// GetEditable returns value of Editable conditional field. +func (u *Username) GetEditable() (value bool) { + if u == nil { + return + } + return u.Flags.Has(0) +} + +// SetActive sets value of Active conditional field. +func (u *Username) SetActive(value bool) { + if value { + u.Flags.Set(1) + u.Active = true + } else { + u.Flags.Unset(1) + u.Active = false + } +} + +// GetActive returns value of Active conditional field. +func (u *Username) GetActive() (value bool) { + if u == nil { + return + } + return u.Flags.Has(1) +} + +// GetUsername returns value of Username field. +func (u *Username) GetUsername() (value string) { + if u == nil { + return + } + return u.Username +} diff --git a/tg/tl_username_slices_gen.go b/tg/tl_username_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_username_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{} +)