From f51550374594ab6c293258b217d45320c8ca5301 Mon Sep 17 00:00:00 2001 From: GitHub Date: Mon, 1 Jan 2024 07:44:51 +0000 Subject: [PATCH] feat(schema): update Telegram to the latest layer --- _schema/tdesktop.tl | 44 +- _schema/telegram.tl | 44 +- telegram/query/messages/queries.gen.go | 122 ++- tg/tl_handlers_gen.go | 20 + tg/tl_message_fwd_header_gen.go | 226 ++++- tg/tl_message_gen.go | 151 ++- tg/tl_message_media_gen.go | 105 ++ tg/tl_messages_delete_saved_history_gen.go | 319 ++++++ ...essages_delete_saved_history_slices_gen.go | 35 + ...l_messages_get_pinned_saved_dialogs_gen.go | 141 +++ ...ges_get_pinned_saved_dialogs_slices_gen.go | 35 + tg/tl_messages_get_saved_dialogs_gen.go | 339 +++++++ ...l_messages_get_saved_dialogs_slices_gen.go | 35 + tg/tl_messages_get_saved_history_gen.go | 367 +++++++ ...l_messages_get_saved_history_slices_gen.go | 35 + tg/tl_messages_get_search_counters_gen.go | 89 +- ...essages_get_search_results_calendar_gen.go | 103 +- ...ssages_get_search_results_positions_gen.go | 103 +- ...ssages_reorder_pinned_saved_dialogs_gen.go | 250 +++++ ...reorder_pinned_saved_dialogs_slices_gen.go | 35 + tg/tl_messages_saved_dialogs_gen.go | 941 ++++++++++++++++++ tg/tl_messages_saved_dialogs_slices_gen.go | 457 +++++++++ tg/tl_messages_search_gen.go | 111 ++- tg/tl_messages_toggle_saved_dialog_pin_gen.go | 232 +++++ ...ages_toggle_saved_dialog_pin_slices_gen.go | 35 + tg/tl_registry_gen.go | 57 +- tg/tl_saved_dialog_gen.go | 246 +++++ tg/tl_saved_dialog_slices_gen.go | 35 + tg/tl_server_gen.go | 110 ++ tg/tl_update_gen.go | 407 ++++++++ tg/tl_update_slices_gen.go | 190 ++++ 31 files changed, 5240 insertions(+), 179 deletions(-) create mode 100644 tg/tl_messages_delete_saved_history_gen.go create mode 100644 tg/tl_messages_delete_saved_history_slices_gen.go create mode 100644 tg/tl_messages_get_pinned_saved_dialogs_gen.go create mode 100644 tg/tl_messages_get_pinned_saved_dialogs_slices_gen.go create mode 100644 tg/tl_messages_get_saved_dialogs_gen.go create mode 100644 tg/tl_messages_get_saved_dialogs_slices_gen.go create mode 100644 tg/tl_messages_get_saved_history_gen.go create mode 100644 tg/tl_messages_get_saved_history_slices_gen.go create mode 100644 tg/tl_messages_reorder_pinned_saved_dialogs_gen.go create mode 100644 tg/tl_messages_reorder_pinned_saved_dialogs_slices_gen.go create mode 100644 tg/tl_messages_saved_dialogs_gen.go create mode 100644 tg/tl_messages_saved_dialogs_slices_gen.go create mode 100644 tg/tl_messages_toggle_saved_dialog_pin_gen.go create mode 100644 tg/tl_messages_toggle_saved_dialog_pin_slices_gen.go create mode 100644 tg/tl_saved_dialog_gen.go create mode 100644 tg/tl_saved_dialog_slices_gen.go diff --git a/_schema/tdesktop.tl b/_schema/tdesktop.tl index 6277c05822..4460979c27 100644 --- a/_schema/tdesktop.tl +++ b/_schema/tdesktop.tl @@ -1,8 +1,8 @@ // Code generated by ./cmd/dltl, DO NOT EDIT. // // Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/SourceFiles/mtproto/scheme/api.tl -// Layer: 169 -// SHA256: af77ecca722a36320c78d681dac9a9ccdfa2ba5282c0d7426619c6d866a4865e +// Layer: 170 +// SHA256: 8b65a10c0b08104a5e6db51a611e61bc23c6d57d13888de4c941bd251a180e3c boolFalse#bc799737 = Bool; @@ -186,7 +186,7 @@ chatPhoto#1c6e1c11 flags:# has_video:flags.0?true photo_id:long stripped_thumb:f messageEmpty#90a6ca84 flags:# id:int peer_id:flags.0?Peer = Message; -message#38116ee0 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true pinned:flags.24?true noforwards:flags.26?true invert_media:flags.27?true id:int from_id:flags.8?Peer peer_id:Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?long reply_to:flags.3?MessageReplyHeader date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector views:flags.10?int forwards:flags.10?int replies:flags.23?MessageReplies edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long reactions:flags.20?MessageReactions restriction_reason:flags.22?Vector ttl_period:flags.25?int = Message; +message#76bec211 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true pinned:flags.24?true noforwards:flags.26?true invert_media:flags.27?true id:int from_id:flags.8?Peer peer_id:Peer saved_peer_id:flags.28?Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?long reply_to:flags.3?MessageReplyHeader date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector views:flags.10?int forwards:flags.10?int replies:flags.23?MessageReplies edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long reactions:flags.20?MessageReactions restriction_reason:flags.22?Vector ttl_period:flags.25?int = Message; messageService#2b085862 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true legacy:flags.19?true id:int from_id:flags.8?Peer peer_id:Peer reply_to:flags.3?MessageReplyHeader date:int action:MessageAction ttl_period:flags.25?int = Message; @@ -200,7 +200,7 @@ messageMediaContact#70322949 phone_number:string first_name:string last_name:str messageMediaUnsupported#9f84f49e = MessageMedia; -messageMediaDocument#4cf4d72d flags:# nopremium:flags.3?true spoiler:flags.4?true document:flags.0?Document alt_document:flags.5?Document ttl_seconds:flags.2?int = MessageMedia; +messageMediaDocument#4cf4d72d flags:# nopremium:flags.3?true spoiler:flags.4?true video:flags.6?true round:flags.7?true voice:flags.8?true document:flags.0?Document alt_document:flags.5?Document ttl_seconds:flags.2?int = MessageMedia; messageMediaWebPage#ddf10c3b flags:# force_large_media:flags.0?true force_small_media:flags.1?true manual:flags.3?true safe:flags.4?true webpage:WebPage = MessageMedia; @@ -696,6 +696,10 @@ updateBotMessageReaction#ac21d3ce peer:Peer msg_id:int date:int actor:Peer old_r updateBotMessageReactions#9cb7759 peer:Peer msg_id:int date:int reactions:Vector qts:int = Update; +updateSavedDialogPinned#aeaf9e74 flags:# pinned:flags.0?true peer:DialogPeer = Update; + +updatePinnedSavedDialogs#686c85a6 flags:# order:flags.0?Vector = 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; @@ -1198,7 +1202,7 @@ messages.botResults#e021f2f6 flags:# gallery:flags.0?true query_id:long next_off exportedMessageLink#5dab1af4 link:string html:string = ExportedMessageLink; -messageFwdHeader#5f777dce flags:# imported:flags.7?true from_id:flags.0?Peer from_name:flags.5?string date:int channel_post:flags.2?int post_author:flags.3?string saved_from_peer:flags.4?Peer saved_from_msg_id:flags.4?int psa_type:flags.6?string = MessageFwdHeader; +messageFwdHeader#4e4df4bb flags:# imported:flags.7?true saved_out:flags.11?true from_id:flags.0?Peer from_name:flags.5?string date:int channel_post:flags.2?int post_author:flags.3?string saved_from_peer:flags.4?Peer saved_from_msg_id:flags.4?int saved_from_id:flags.8?Peer saved_from_name:flags.9?string saved_date:flags.10?int psa_type:flags.6?string = MessageFwdHeader; auth.codeTypeSms#72a3158c = auth.CodeType; @@ -2404,6 +2408,14 @@ storyReactionPublicRepost#cfcd0f13 peer_id:Peer story:StoryItem = StoryReaction; stories.storyReactionsList#aa5f789c flags:# count:int reactions:Vector chats:Vector users:Vector next_offset:flags.0?string = stories.StoryReactionsList; +savedDialog#bd87cb6c flags:# pinned:flags.2?true peer:Peer top_message:int = SavedDialog; + +messages.savedDialogs#f83ae221 dialogs:Vector messages:Vector chats:Vector users:Vector = messages.SavedDialogs; + +messages.savedDialogsSlice#44ba9dd9 count:int dialogs:Vector messages:Vector chats:Vector users:Vector = messages.SavedDialogs; + +messages.savedDialogsNotModified#c01f6fe8 count:int = messages.SavedDialogs; + ---functions--- @@ -2711,7 +2723,7 @@ messages.getDialogs#a0f4cb4f flags:# exclude_pinned:flags.0?true folder_id:flags messages.getHistory#4423e6c5 peer:InputPeer offset_id:int offset_date:int add_offset:int limit:int max_id:int min_id:int hash:long = messages.Messages; -messages.search#a0fda762 flags:# peer:InputPeer q:string from_id:flags.0?InputPeer top_msg_id:flags.1?int filter:MessagesFilter min_date:int max_date:int offset_id:int add_offset:int limit:int max_id:int min_id:int hash:long = messages.Messages; +messages.search#a7b4e929 flags:# peer:InputPeer q:string from_id:flags.0?InputPeer saved_peer_id:flags.2?InputPeer top_msg_id:flags.1?int filter:MessagesFilter min_date:int max_date:int offset_id:int add_offset:int limit:int max_id:int min_id:int hash:long = messages.Messages; messages.readHistory#e306d3a peer:InputPeer max_id:int = messages.AffectedMessages; @@ -2917,7 +2929,7 @@ messages.getEmojiKeywordsLanguages#4e9963b2 lang_codes:Vector = Vector = Vector; +messages.getSearchCounters#1bbcf300 flags:# peer:InputPeer saved_peer_id:flags.2?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; @@ -2989,9 +3001,9 @@ messages.setChatTheme#e63be13f peer:InputPeer emoticon:string = Updates; messages.getMessageReadParticipants#31c1c44f peer:InputPeer msg_id:int = Vector; -messages.getSearchResultsCalendar#49f0bde9 peer:InputPeer filter:MessagesFilter offset_id:int offset_date:int = messages.SearchResultsCalendar; +messages.getSearchResultsCalendar#6aa3f6bd flags:# peer:InputPeer saved_peer_id:flags.2?InputPeer filter:MessagesFilter offset_id:int offset_date:int = messages.SearchResultsCalendar; -messages.getSearchResultsPositions#6e9583a3 peer:InputPeer filter:MessagesFilter offset_id:int limit:int = messages.SearchResultsPositions; +messages.getSearchResultsPositions#9c7f2f10 flags:# peer:InputPeer saved_peer_id:flags.2?InputPeer filter:MessagesFilter offset_id:int limit:int = messages.SearchResultsPositions; messages.hideChatJoinRequest#7fe7e815 flags:# approved:flags.0?true peer:InputPeer user_id:InputUser = Updates; @@ -3081,6 +3093,18 @@ messages.setChatWallPaper#8ffacae1 flags:# for_both:flags.3?true revert:flags.4? messages.searchEmojiStickerSets#92b4494c flags:# exclude_featured:flags.0?true q:string hash:long = messages.FoundStickerSets; +messages.getSavedDialogs#5381d21a flags:# exclude_pinned:flags.0?true offset_date:int offset_id:int offset_peer:InputPeer limit:int hash:long = messages.SavedDialogs; + +messages.getSavedHistory#3d9a414d peer:InputPeer offset_id:int offset_date:int add_offset:int limit:int max_id:int min_id:int hash:long = messages.Messages; + +messages.deleteSavedHistory#6e98102b flags:# peer:InputPeer max_id:int min_date:flags.2?int max_date:flags.3?int = messages.AffectedHistory; + +messages.getPinnedSavedDialogs#d63d94e0 = messages.SavedDialogs; + +messages.toggleSavedDialogPin#ac81bbde flags:# pinned:flags.0?true peer:InputDialogPeer = Bool; + +messages.reorderPinnedSavedDialogs#8b716587 flags:# force:flags.0?true order:Vector = Bool; + updates.getState#edd4882a = updates.State; updates.getDifference#19c2f763 flags:# pts:int pts_limit:flags.1?int pts_total_limit:flags.0?int date:int qts:int qts_limit:flags.2?int = updates.Difference; @@ -3533,4 +3557,4 @@ premium.getBoostsStatus#42f1f61 peer:InputPeer = premium.BoostsStatus; premium.getUserBoosts#39854d1f peer:InputPeer user_id:InputUser = premium.BoostsList; -// LAYER 169 +// LAYER 170 diff --git a/_schema/telegram.tl b/_schema/telegram.tl index 3488fdb76c..baaa75c602 100644 --- a/_schema/telegram.tl +++ b/_schema/telegram.tl @@ -2,8 +2,8 @@ // // Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/SourceFiles/mtproto/scheme/api.tl // Merge: _schema/legacy.tl -// Layer: 169 -// SHA256: af77ecca722a36320c78d681dac9a9ccdfa2ba5282c0d7426619c6d866a4865e +// Layer: 170 +// SHA256: 8b65a10c0b08104a5e6db51a611e61bc23c6d57d13888de4c941bd251a180e3c boolFalse#bc799737 = Bool; @@ -187,7 +187,7 @@ chatPhoto#1c6e1c11 flags:# has_video:flags.0?true photo_id:long stripped_thumb:f messageEmpty#90a6ca84 flags:# id:int peer_id:flags.0?Peer = Message; -message#38116ee0 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true pinned:flags.24?true noforwards:flags.26?true invert_media:flags.27?true id:int from_id:flags.8?Peer peer_id:Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?long reply_to:flags.3?MessageReplyHeader date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector views:flags.10?int forwards:flags.10?int replies:flags.23?MessageReplies edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long reactions:flags.20?MessageReactions restriction_reason:flags.22?Vector ttl_period:flags.25?int = Message; +message#76bec211 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true pinned:flags.24?true noforwards:flags.26?true invert_media:flags.27?true id:int from_id:flags.8?Peer peer_id:Peer saved_peer_id:flags.28?Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?long reply_to:flags.3?MessageReplyHeader date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector views:flags.10?int forwards:flags.10?int replies:flags.23?MessageReplies edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long reactions:flags.20?MessageReactions restriction_reason:flags.22?Vector ttl_period:flags.25?int = Message; messageService#2b085862 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true legacy:flags.19?true id:int from_id:flags.8?Peer peer_id:Peer reply_to:flags.3?MessageReplyHeader date:int action:MessageAction ttl_period:flags.25?int = Message; @@ -201,7 +201,7 @@ messageMediaContact#70322949 phone_number:string first_name:string last_name:str messageMediaUnsupported#9f84f49e = MessageMedia; -messageMediaDocument#4cf4d72d flags:# nopremium:flags.3?true spoiler:flags.4?true document:flags.0?Document alt_document:flags.5?Document ttl_seconds:flags.2?int = MessageMedia; +messageMediaDocument#4cf4d72d flags:# nopremium:flags.3?true spoiler:flags.4?true video:flags.6?true round:flags.7?true voice:flags.8?true document:flags.0?Document alt_document:flags.5?Document ttl_seconds:flags.2?int = MessageMedia; messageMediaWebPage#ddf10c3b flags:# force_large_media:flags.0?true force_small_media:flags.1?true manual:flags.3?true safe:flags.4?true webpage:WebPage = MessageMedia; @@ -697,6 +697,10 @@ updateBotMessageReaction#ac21d3ce peer:Peer msg_id:int date:int actor:Peer old_r updateBotMessageReactions#9cb7759 peer:Peer msg_id:int date:int reactions:Vector qts:int = Update; +updateSavedDialogPinned#aeaf9e74 flags:# pinned:flags.0?true peer:DialogPeer = Update; + +updatePinnedSavedDialogs#686c85a6 flags:# order:flags.0?Vector = 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; @@ -1199,7 +1203,7 @@ messages.botResults#e021f2f6 flags:# gallery:flags.0?true query_id:long next_off exportedMessageLink#5dab1af4 link:string html:string = ExportedMessageLink; -messageFwdHeader#5f777dce flags:# imported:flags.7?true from_id:flags.0?Peer from_name:flags.5?string date:int channel_post:flags.2?int post_author:flags.3?string saved_from_peer:flags.4?Peer saved_from_msg_id:flags.4?int psa_type:flags.6?string = MessageFwdHeader; +messageFwdHeader#4e4df4bb flags:# imported:flags.7?true saved_out:flags.11?true from_id:flags.0?Peer from_name:flags.5?string date:int channel_post:flags.2?int post_author:flags.3?string saved_from_peer:flags.4?Peer saved_from_msg_id:flags.4?int saved_from_id:flags.8?Peer saved_from_name:flags.9?string saved_date:flags.10?int psa_type:flags.6?string = MessageFwdHeader; auth.codeTypeSms#72a3158c = auth.CodeType; @@ -2405,6 +2409,14 @@ storyReactionPublicRepost#cfcd0f13 peer_id:Peer story:StoryItem = StoryReaction; stories.storyReactionsList#aa5f789c flags:# count:int reactions:Vector chats:Vector users:Vector next_offset:flags.0?string = stories.StoryReactionsList; +savedDialog#bd87cb6c flags:# pinned:flags.2?true peer:Peer top_message:int = SavedDialog; + +messages.savedDialogs#f83ae221 dialogs:Vector messages:Vector chats:Vector users:Vector = messages.SavedDialogs; + +messages.savedDialogsSlice#44ba9dd9 count:int dialogs:Vector messages:Vector chats:Vector users:Vector = messages.SavedDialogs; + +messages.savedDialogsNotModified#c01f6fe8 count:int = messages.SavedDialogs; + ---functions--- @@ -2712,7 +2724,7 @@ messages.getDialogs#a0f4cb4f flags:# exclude_pinned:flags.0?true folder_id:flags messages.getHistory#4423e6c5 peer:InputPeer offset_id:int offset_date:int add_offset:int limit:int max_id:int min_id:int hash:long = messages.Messages; -messages.search#a0fda762 flags:# peer:InputPeer q:string from_id:flags.0?InputPeer top_msg_id:flags.1?int filter:MessagesFilter min_date:int max_date:int offset_id:int add_offset:int limit:int max_id:int min_id:int hash:long = messages.Messages; +messages.search#a7b4e929 flags:# peer:InputPeer q:string from_id:flags.0?InputPeer saved_peer_id:flags.2?InputPeer top_msg_id:flags.1?int filter:MessagesFilter min_date:int max_date:int offset_id:int add_offset:int limit:int max_id:int min_id:int hash:long = messages.Messages; messages.readHistory#e306d3a peer:InputPeer max_id:int = messages.AffectedMessages; @@ -2918,7 +2930,7 @@ messages.getEmojiKeywordsLanguages#4e9963b2 lang_codes:Vector = Vector = Vector; +messages.getSearchCounters#1bbcf300 flags:# peer:InputPeer saved_peer_id:flags.2?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; @@ -2990,9 +3002,9 @@ messages.setChatTheme#e63be13f peer:InputPeer emoticon:string = Updates; messages.getMessageReadParticipants#31c1c44f peer:InputPeer msg_id:int = Vector; -messages.getSearchResultsCalendar#49f0bde9 peer:InputPeer filter:MessagesFilter offset_id:int offset_date:int = messages.SearchResultsCalendar; +messages.getSearchResultsCalendar#6aa3f6bd flags:# peer:InputPeer saved_peer_id:flags.2?InputPeer filter:MessagesFilter offset_id:int offset_date:int = messages.SearchResultsCalendar; -messages.getSearchResultsPositions#6e9583a3 peer:InputPeer filter:MessagesFilter offset_id:int limit:int = messages.SearchResultsPositions; +messages.getSearchResultsPositions#9c7f2f10 flags:# peer:InputPeer saved_peer_id:flags.2?InputPeer filter:MessagesFilter offset_id:int limit:int = messages.SearchResultsPositions; messages.hideChatJoinRequest#7fe7e815 flags:# approved:flags.0?true peer:InputPeer user_id:InputUser = Updates; @@ -3082,6 +3094,18 @@ messages.setChatWallPaper#8ffacae1 flags:# for_both:flags.3?true revert:flags.4? messages.searchEmojiStickerSets#92b4494c flags:# exclude_featured:flags.0?true q:string hash:long = messages.FoundStickerSets; +messages.getSavedDialogs#5381d21a flags:# exclude_pinned:flags.0?true offset_date:int offset_id:int offset_peer:InputPeer limit:int hash:long = messages.SavedDialogs; + +messages.getSavedHistory#3d9a414d peer:InputPeer offset_id:int offset_date:int add_offset:int limit:int max_id:int min_id:int hash:long = messages.Messages; + +messages.deleteSavedHistory#6e98102b flags:# peer:InputPeer max_id:int min_date:flags.2?int max_date:flags.3?int = messages.AffectedHistory; + +messages.getPinnedSavedDialogs#d63d94e0 = messages.SavedDialogs; + +messages.toggleSavedDialogPin#ac81bbde flags:# pinned:flags.0?true peer:InputDialogPeer = Bool; + +messages.reorderPinnedSavedDialogs#8b716587 flags:# force:flags.0?true order:Vector = Bool; + updates.getState#edd4882a = updates.State; updates.getDifference#19c2f763 flags:# pts:int pts_limit:flags.1?int pts_total_limit:flags.0?int date:int qts:int qts_limit:flags.2?int = updates.Difference; @@ -3566,4 +3590,4 @@ test.useError#ee75af01 = Error; test.useConfigSimple#f9b7b23d = help.ConfigSimple; -// LAYER 169 +// LAYER 170 diff --git a/telegram/query/messages/queries.gen.go b/telegram/query/messages/queries.gen.go index ac0854c94b..65dc714fa9 100644 --- a/telegram/query/messages/queries.gen.go +++ b/telegram/query/messages/queries.gen.go @@ -358,6 +358,114 @@ func (b *GetRepliesQueryBuilder) Collect(ctx context.Context) ([]Elem, error) { return r, iter.Err() } +// GetSavedHistoryQueryBuilder is query builder of MessagesGetSavedHistory. +type GetSavedHistoryQueryBuilder struct { + raw *tg.Client + req tg.MessagesGetSavedHistoryRequest + batchSize int + addOffset int + offsetDate int + offsetID int +} + +// GetSavedHistory creates query builder of MessagesGetSavedHistory. +func (q *QueryBuilder) GetSavedHistory(paramPeer tg.InputPeerClass) *GetSavedHistoryQueryBuilder { + b := &GetSavedHistoryQueryBuilder{ + raw: q.raw, + batchSize: 1, + req: tg.MessagesGetSavedHistoryRequest{ + Peer: &tg.InputPeerEmpty{}, + }, + } + + b.req.Peer = paramPeer + return b +} + +// BatchSize sets buffer of message loaded from one request. +// Be carefully, when set this limit, because Telegram does not return error if limit is too big, +// so results can be incorrect. +func (b *GetSavedHistoryQueryBuilder) BatchSize(batchSize int) *GetSavedHistoryQueryBuilder { + b.batchSize = batchSize + return b +} + +// OffsetDate sets offsetDate from which iterate start. +func (b *GetSavedHistoryQueryBuilder) OffsetDate(offsetDate int) *GetSavedHistoryQueryBuilder { + b.offsetDate = offsetDate + return b +} + +// OffsetID sets offsetID from which iterate start. +func (b *GetSavedHistoryQueryBuilder) OffsetID(offsetID int) *GetSavedHistoryQueryBuilder { + b.offsetID = offsetID + return b +} + +// Peer sets Peer field of GetSavedHistory query. +func (b *GetSavedHistoryQueryBuilder) Peer(paramPeer tg.InputPeerClass) *GetSavedHistoryQueryBuilder { + b.req.Peer = paramPeer + return b +} + +// Query implements Query interface. +func (b *GetSavedHistoryQueryBuilder) Query(ctx context.Context, req Request) (tg.MessagesMessagesClass, error) { + r := &tg.MessagesGetSavedHistoryRequest{ + Limit: req.Limit, + } + + r.Peer = b.req.Peer + r.AddOffset = req.AddOffset + r.OffsetDate = req.OffsetDate + r.OffsetID = req.OffsetID + return b.raw.MessagesGetSavedHistory(ctx, r) +} + +// Iter returns iterator using built query. +func (b *GetSavedHistoryQueryBuilder) Iter() *Iterator { + iter := NewIterator(b, b.batchSize) + iter = iter.OffsetDate(b.offsetDate) + iter = iter.OffsetID(b.offsetID) + return iter +} + +// ForEach calls given callback on each iterator element. +func (b *GetSavedHistoryQueryBuilder) ForEach(ctx context.Context, cb func(context.Context, Elem) error) error { + iter := b.Iter() + for iter.Next(ctx) { + if err := cb(ctx, iter.Value()); err != nil { + return err + } + } + return iter.Err() +} + +// Count fetches remote state to get number of elements. +func (b *GetSavedHistoryQueryBuilder) Count(ctx context.Context) (int, error) { + iter := b.Iter() + c, err := iter.Total(ctx) + if err != nil { + return 0, errors.Wrap(err, "get total") + } + return c, nil +} + +// Collect creates iterator and collects all elements to slice. +func (b *GetSavedHistoryQueryBuilder) Collect(ctx context.Context) ([]Elem, error) { + iter := b.Iter() + c, err := iter.Total(ctx) + if err != nil { + return nil, errors.Wrap(err, "get total") + } + + r := make([]Elem, 0, c) + for iter.Next(ctx) { + r = append(r, iter.Value()) + } + + return r, iter.Err() +} + // GetUnreadMentionsQueryBuilder is query builder of MessagesGetUnreadMentions. type GetUnreadMentionsQueryBuilder struct { raw *tg.Client @@ -585,9 +693,10 @@ func (q *QueryBuilder) Search(paramPeer tg.InputPeerClass) *SearchQueryBuilder { raw: q.raw, batchSize: 1, req: tg.MessagesSearchRequest{ - Filter: &tg.InputMessagesFilterEmpty{}, - FromID: &tg.InputPeerEmpty{}, - Peer: &tg.InputPeerEmpty{}, + Filter: &tg.InputMessagesFilterEmpty{}, + FromID: &tg.InputPeerEmpty{}, + Peer: &tg.InputPeerEmpty{}, + SavedPeerID: &tg.InputPeerEmpty{}, }, } @@ -645,6 +754,12 @@ func (b *SearchQueryBuilder) Q(paramQ string) *SearchQueryBuilder { return b } +// SavedPeerID sets SavedPeerID field of Search query. +func (b *SearchQueryBuilder) SavedPeerID(paramSavedPeerID tg.InputPeerClass) *SearchQueryBuilder { + b.req.SavedPeerID = paramSavedPeerID + return b +} + // TopMsgID sets TopMsgID field of Search query. func (b *SearchQueryBuilder) TopMsgID(paramTopMsgID int) *SearchQueryBuilder { b.req.TopMsgID = paramTopMsgID @@ -761,6 +876,7 @@ func (b *SearchQueryBuilder) Query(ctx context.Context, req Request) (tg.Message r.MinDate = b.req.MinDate r.Peer = b.req.Peer r.Q = b.req.Q + r.SavedPeerID = b.req.SavedPeerID r.TopMsgID = b.req.TopMsgID r.AddOffset = req.AddOffset r.OffsetID = req.OffsetID diff --git a/tg/tl_handlers_gen.go b/tg/tl_handlers_gen.go index fd1d08edc2..4f4e939977 100644 --- a/tg/tl_handlers_gen.go +++ b/tg/tl_handlers_gen.go @@ -1325,3 +1325,23 @@ func (u UpdateDispatcher) OnBotMessageReactions(handler BotMessageReactionsHandl return handler(ctx, e, update.(*UpdateBotMessageReactions)) } } + +// SavedDialogPinnedHandler is a SavedDialogPinned event handler. +type SavedDialogPinnedHandler func(ctx context.Context, e Entities, update *UpdateSavedDialogPinned) error + +// OnSavedDialogPinned sets SavedDialogPinned handler. +func (u UpdateDispatcher) OnSavedDialogPinned(handler SavedDialogPinnedHandler) { + u.handlers[UpdateSavedDialogPinnedTypeID] = func(ctx context.Context, e Entities, update UpdateClass) error { + return handler(ctx, e, update.(*UpdateSavedDialogPinned)) + } +} + +// PinnedSavedDialogsHandler is a PinnedSavedDialogs event handler. +type PinnedSavedDialogsHandler func(ctx context.Context, e Entities, update *UpdatePinnedSavedDialogs) error + +// OnPinnedSavedDialogs sets PinnedSavedDialogs handler. +func (u UpdateDispatcher) OnPinnedSavedDialogs(handler PinnedSavedDialogsHandler) { + u.handlers[UpdatePinnedSavedDialogsTypeID] = func(ctx context.Context, e Entities, update UpdateClass) error { + return handler(ctx, e, update.(*UpdatePinnedSavedDialogs)) + } +} diff --git a/tg/tl_message_fwd_header_gen.go b/tg/tl_message_fwd_header_gen.go index d2d81b40f2..268fcd53e6 100644 --- a/tg/tl_message_fwd_header_gen.go +++ b/tg/tl_message_fwd_header_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessageFwdHeader represents TL type `messageFwdHeader#5f777dce`. +// MessageFwdHeader represents TL type `messageFwdHeader#4e4df4bb`. // Info about a forwarded message // // See https://core.telegram.org/constructor/messageFwdHeader for reference. @@ -47,6 +47,8 @@ type MessageFwdHeader struct { // Links: // 1) https://core.telegram.org/api/import Imported bool + // SavedOut field of MessageFwdHeader. + SavedOut bool // The ID of the user that originally sent the message // // Use SetFromID and GetFromID helpers. @@ -75,6 +77,18 @@ type MessageFwdHeader struct { // // Use SetSavedFromMsgID and GetSavedFromMsgID helpers. SavedFromMsgID int + // SavedFromID field of MessageFwdHeader. + // + // Use SetSavedFromID and GetSavedFromID helpers. + SavedFromID PeerClass + // SavedFromName field of MessageFwdHeader. + // + // Use SetSavedFromName and GetSavedFromName helpers. + SavedFromName string + // SavedDate field of MessageFwdHeader. + // + // Use SetSavedDate and GetSavedDate helpers. + SavedDate int // PSA type // // Use SetPsaType and GetPsaType helpers. @@ -82,7 +96,7 @@ type MessageFwdHeader struct { } // MessageFwdHeaderTypeID is TL type id of MessageFwdHeader. -const MessageFwdHeaderTypeID = 0x5f777dce +const MessageFwdHeaderTypeID = 0x4e4df4bb // Ensuring interfaces in compile-time for MessageFwdHeader. var ( @@ -102,6 +116,9 @@ func (m *MessageFwdHeader) Zero() bool { if !(m.Imported == false) { return false } + if !(m.SavedOut == false) { + return false + } if !(m.FromID == nil) { return false } @@ -123,6 +140,15 @@ func (m *MessageFwdHeader) Zero() bool { if !(m.SavedFromMsgID == 0) { return false } + if !(m.SavedFromID == nil) { + return false + } + if !(m.SavedFromName == "") { + return false + } + if !(m.SavedDate == 0) { + return false + } if !(m.PsaType == "") { return false } @@ -142,6 +168,7 @@ func (m *MessageFwdHeader) String() string { // FillFrom fills MessageFwdHeader from given interface. func (m *MessageFwdHeader) FillFrom(from interface { GetImported() (value bool) + GetSavedOut() (value bool) GetFromID() (value PeerClass, ok bool) GetFromName() (value string, ok bool) GetDate() (value int) @@ -149,9 +176,13 @@ func (m *MessageFwdHeader) FillFrom(from interface { GetPostAuthor() (value string, ok bool) GetSavedFromPeer() (value PeerClass, ok bool) GetSavedFromMsgID() (value int, ok bool) + GetSavedFromID() (value PeerClass, ok bool) + GetSavedFromName() (value string, ok bool) + GetSavedDate() (value int, ok bool) GetPsaType() (value string, ok bool) }) { m.Imported = from.GetImported() + m.SavedOut = from.GetSavedOut() if val, ok := from.GetFromID(); ok { m.FromID = val } @@ -177,6 +208,18 @@ func (m *MessageFwdHeader) FillFrom(from interface { m.SavedFromMsgID = val } + if val, ok := from.GetSavedFromID(); ok { + m.SavedFromID = val + } + + if val, ok := from.GetSavedFromName(); ok { + m.SavedFromName = val + } + + if val, ok := from.GetSavedDate(); ok { + m.SavedDate = val + } + if val, ok := from.GetPsaType(); ok { m.PsaType = val } @@ -211,6 +254,11 @@ func (m *MessageFwdHeader) TypeInfo() tdp.Type { SchemaName: "imported", Null: !m.Flags.Has(7), }, + { + Name: "SavedOut", + SchemaName: "saved_out", + Null: !m.Flags.Has(11), + }, { Name: "FromID", SchemaName: "from_id", @@ -245,6 +293,21 @@ func (m *MessageFwdHeader) TypeInfo() tdp.Type { SchemaName: "saved_from_msg_id", Null: !m.Flags.Has(4), }, + { + Name: "SavedFromID", + SchemaName: "saved_from_id", + Null: !m.Flags.Has(8), + }, + { + Name: "SavedFromName", + SchemaName: "saved_from_name", + Null: !m.Flags.Has(9), + }, + { + Name: "SavedDate", + SchemaName: "saved_date", + Null: !m.Flags.Has(10), + }, { Name: "PsaType", SchemaName: "psa_type", @@ -259,6 +322,9 @@ func (m *MessageFwdHeader) SetFlags() { if !(m.Imported == false) { m.Flags.Set(7) } + if !(m.SavedOut == false) { + m.Flags.Set(11) + } if !(m.FromID == nil) { m.Flags.Set(0) } @@ -277,6 +343,15 @@ func (m *MessageFwdHeader) SetFlags() { if !(m.SavedFromMsgID == 0) { m.Flags.Set(4) } + if !(m.SavedFromID == nil) { + m.Flags.Set(8) + } + if !(m.SavedFromName == "") { + m.Flags.Set(9) + } + if !(m.SavedDate == 0) { + m.Flags.Set(10) + } if !(m.PsaType == "") { m.Flags.Set(6) } @@ -285,7 +360,7 @@ func (m *MessageFwdHeader) SetFlags() { // Encode implements bin.Encoder. func (m *MessageFwdHeader) Encode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageFwdHeader#5f777dce as nil") + return fmt.Errorf("can't encode messageFwdHeader#4e4df4bb as nil") } b.PutID(MessageFwdHeaderTypeID) return m.EncodeBare(b) @@ -294,18 +369,18 @@ func (m *MessageFwdHeader) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (m *MessageFwdHeader) EncodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageFwdHeader#5f777dce as nil") + return fmt.Errorf("can't encode messageFwdHeader#4e4df4bb as nil") } m.SetFlags() if err := m.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messageFwdHeader#5f777dce: field flags: %w", err) + return fmt.Errorf("unable to encode messageFwdHeader#4e4df4bb: field flags: %w", err) } if m.Flags.Has(0) { if m.FromID == nil { - return fmt.Errorf("unable to encode messageFwdHeader#5f777dce: field from_id is nil") + return fmt.Errorf("unable to encode messageFwdHeader#4e4df4bb: field from_id is nil") } if err := m.FromID.Encode(b); err != nil { - return fmt.Errorf("unable to encode messageFwdHeader#5f777dce: field from_id: %w", err) + return fmt.Errorf("unable to encode messageFwdHeader#4e4df4bb: field from_id: %w", err) } } if m.Flags.Has(5) { @@ -320,15 +395,29 @@ func (m *MessageFwdHeader) EncodeBare(b *bin.Buffer) error { } if m.Flags.Has(4) { if m.SavedFromPeer == nil { - return fmt.Errorf("unable to encode messageFwdHeader#5f777dce: field saved_from_peer is nil") + return fmt.Errorf("unable to encode messageFwdHeader#4e4df4bb: field saved_from_peer is nil") } if err := m.SavedFromPeer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messageFwdHeader#5f777dce: field saved_from_peer: %w", err) + return fmt.Errorf("unable to encode messageFwdHeader#4e4df4bb: field saved_from_peer: %w", err) } } if m.Flags.Has(4) { b.PutInt(m.SavedFromMsgID) } + if m.Flags.Has(8) { + if m.SavedFromID == nil { + return fmt.Errorf("unable to encode messageFwdHeader#4e4df4bb: field saved_from_id is nil") + } + if err := m.SavedFromID.Encode(b); err != nil { + return fmt.Errorf("unable to encode messageFwdHeader#4e4df4bb: field saved_from_id: %w", err) + } + } + if m.Flags.Has(9) { + b.PutString(m.SavedFromName) + } + if m.Flags.Has(10) { + b.PutInt(m.SavedDate) + } if m.Flags.Has(6) { b.PutString(m.PsaType) } @@ -338,10 +427,10 @@ func (m *MessageFwdHeader) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (m *MessageFwdHeader) Decode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageFwdHeader#5f777dce to nil") + return fmt.Errorf("can't decode messageFwdHeader#4e4df4bb to nil") } if err := b.ConsumeID(MessageFwdHeaderTypeID); err != nil { - return fmt.Errorf("unable to decode messageFwdHeader#5f777dce: %w", err) + return fmt.Errorf("unable to decode messageFwdHeader#4e4df4bb: %w", err) } return m.DecodeBare(b) } @@ -349,67 +438,89 @@ func (m *MessageFwdHeader) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (m *MessageFwdHeader) DecodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageFwdHeader#5f777dce to nil") + return fmt.Errorf("can't decode messageFwdHeader#4e4df4bb to nil") } { if err := m.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messageFwdHeader#5f777dce: field flags: %w", err) + return fmt.Errorf("unable to decode messageFwdHeader#4e4df4bb: field flags: %w", err) } } m.Imported = m.Flags.Has(7) + m.SavedOut = m.Flags.Has(11) if m.Flags.Has(0) { value, err := DecodePeer(b) if err != nil { - return fmt.Errorf("unable to decode messageFwdHeader#5f777dce: field from_id: %w", err) + return fmt.Errorf("unable to decode messageFwdHeader#4e4df4bb: field from_id: %w", err) } m.FromID = value } if m.Flags.Has(5) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messageFwdHeader#5f777dce: field from_name: %w", err) + return fmt.Errorf("unable to decode messageFwdHeader#4e4df4bb: field from_name: %w", err) } m.FromName = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messageFwdHeader#5f777dce: field date: %w", err) + return fmt.Errorf("unable to decode messageFwdHeader#4e4df4bb: field date: %w", err) } m.Date = value } if m.Flags.Has(2) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messageFwdHeader#5f777dce: field channel_post: %w", err) + return fmt.Errorf("unable to decode messageFwdHeader#4e4df4bb: field channel_post: %w", err) } m.ChannelPost = value } if m.Flags.Has(3) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messageFwdHeader#5f777dce: field post_author: %w", err) + return fmt.Errorf("unable to decode messageFwdHeader#4e4df4bb: field post_author: %w", err) } m.PostAuthor = value } if m.Flags.Has(4) { value, err := DecodePeer(b) if err != nil { - return fmt.Errorf("unable to decode messageFwdHeader#5f777dce: field saved_from_peer: %w", err) + return fmt.Errorf("unable to decode messageFwdHeader#4e4df4bb: field saved_from_peer: %w", err) } m.SavedFromPeer = value } if m.Flags.Has(4) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messageFwdHeader#5f777dce: field saved_from_msg_id: %w", err) + return fmt.Errorf("unable to decode messageFwdHeader#4e4df4bb: field saved_from_msg_id: %w", err) } m.SavedFromMsgID = value } + if m.Flags.Has(8) { + value, err := DecodePeer(b) + if err != nil { + return fmt.Errorf("unable to decode messageFwdHeader#4e4df4bb: field saved_from_id: %w", err) + } + m.SavedFromID = value + } + if m.Flags.Has(9) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messageFwdHeader#4e4df4bb: field saved_from_name: %w", err) + } + m.SavedFromName = value + } + if m.Flags.Has(10) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messageFwdHeader#4e4df4bb: field saved_date: %w", err) + } + m.SavedDate = value + } if m.Flags.Has(6) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messageFwdHeader#5f777dce: field psa_type: %w", err) + return fmt.Errorf("unable to decode messageFwdHeader#4e4df4bb: field psa_type: %w", err) } m.PsaType = value } @@ -435,6 +546,25 @@ func (m *MessageFwdHeader) GetImported() (value bool) { return m.Flags.Has(7) } +// SetSavedOut sets value of SavedOut conditional field. +func (m *MessageFwdHeader) SetSavedOut(value bool) { + if value { + m.Flags.Set(11) + m.SavedOut = true + } else { + m.Flags.Unset(11) + m.SavedOut = false + } +} + +// GetSavedOut returns value of SavedOut conditional field. +func (m *MessageFwdHeader) GetSavedOut() (value bool) { + if m == nil { + return + } + return m.Flags.Has(11) +} + // SetFromID sets value of FromID conditional field. func (m *MessageFwdHeader) SetFromID(value PeerClass) { m.Flags.Set(0) @@ -551,6 +681,60 @@ func (m *MessageFwdHeader) GetSavedFromMsgID() (value int, ok bool) { return m.SavedFromMsgID, true } +// SetSavedFromID sets value of SavedFromID conditional field. +func (m *MessageFwdHeader) SetSavedFromID(value PeerClass) { + m.Flags.Set(8) + m.SavedFromID = value +} + +// GetSavedFromID returns value of SavedFromID conditional field and +// boolean which is true if field was set. +func (m *MessageFwdHeader) GetSavedFromID() (value PeerClass, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(8) { + return value, false + } + return m.SavedFromID, true +} + +// SetSavedFromName sets value of SavedFromName conditional field. +func (m *MessageFwdHeader) SetSavedFromName(value string) { + m.Flags.Set(9) + m.SavedFromName = value +} + +// GetSavedFromName returns value of SavedFromName conditional field and +// boolean which is true if field was set. +func (m *MessageFwdHeader) GetSavedFromName() (value string, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(9) { + return value, false + } + return m.SavedFromName, true +} + +// SetSavedDate sets value of SavedDate conditional field. +func (m *MessageFwdHeader) SetSavedDate(value int) { + m.Flags.Set(10) + m.SavedDate = value +} + +// GetSavedDate returns value of SavedDate conditional field and +// boolean which is true if field was set. +func (m *MessageFwdHeader) GetSavedDate() (value int, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(10) { + return value, false + } + return m.SavedDate, true +} + // SetPsaType sets value of PsaType conditional field. func (m *MessageFwdHeader) SetPsaType(value string) { m.Flags.Set(6) diff --git a/tg/tl_message_gen.go b/tg/tl_message_gen.go index eb30914c6d..bde3bec6e8 100644 --- a/tg/tl_message_gen.go +++ b/tg/tl_message_gen.go @@ -240,7 +240,7 @@ func (m *MessageEmpty) GetPeerID() (value PeerClass, ok bool) { return m.PeerID, true } -// Message represents TL type `message#38116ee0`. +// Message represents TL type `message#76bec211`. // A message // // See https://core.telegram.org/constructor/message for reference. @@ -296,6 +296,10 @@ type Message struct { FromID PeerClass // Peer ID, the chat where this message was sent PeerID PeerClass + // SavedPeerID field of Message. + // + // Use SetSavedPeerID and GetSavedPeerID helpers. + SavedPeerID PeerClass // Info about forwarded messages // // Use SetFwdFrom and GetFwdFrom helpers. @@ -375,7 +379,7 @@ type Message struct { } // MessageTypeID is TL type id of Message. -const MessageTypeID = 0x38116ee0 +const MessageTypeID = 0x76bec211 // construct implements constructor of MessageClass. func (m Message) construct() MessageClass { return &m } @@ -439,6 +443,9 @@ func (m *Message) Zero() bool { if !(m.PeerID == nil) { return false } + if !(m.SavedPeerID == nil) { + return false + } if !(m.FwdFrom.Zero()) { return false } @@ -519,6 +526,7 @@ func (m *Message) FillFrom(from interface { GetID() (value int) GetFromID() (value PeerClass, ok bool) GetPeerID() (value PeerClass) + GetSavedPeerID() (value PeerClass, ok bool) GetFwdFrom() (value MessageFwdHeader, ok bool) GetViaBotID() (value int64, ok bool) GetReplyTo() (value MessageReplyHeaderClass, ok bool) @@ -554,6 +562,10 @@ func (m *Message) FillFrom(from interface { } m.PeerID = from.GetPeerID() + if val, ok := from.GetSavedPeerID(); ok { + m.SavedPeerID = val + } + if val, ok := from.GetFwdFrom(); ok { m.FwdFrom = val } @@ -709,6 +721,11 @@ func (m *Message) TypeInfo() tdp.Type { Name: "PeerID", SchemaName: "peer_id", }, + { + Name: "SavedPeerID", + SchemaName: "saved_peer_id", + Null: !m.Flags.Has(28), + }, { Name: "FwdFrom", SchemaName: "fwd_from", @@ -834,6 +851,9 @@ func (m *Message) SetFlags() { if !(m.FromID == nil) { m.Flags.Set(8) } + if !(m.SavedPeerID == nil) { + m.Flags.Set(28) + } if !(m.FwdFrom.Zero()) { m.Flags.Set(2) } @@ -884,7 +904,7 @@ func (m *Message) SetFlags() { // Encode implements bin.Encoder. func (m *Message) Encode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode message#38116ee0 as nil") + return fmt.Errorf("can't encode message#76bec211 as nil") } b.PutID(MessageTypeID) return m.EncodeBare(b) @@ -893,30 +913,38 @@ func (m *Message) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (m *Message) EncodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode message#38116ee0 as nil") + return fmt.Errorf("can't encode message#76bec211 as nil") } m.SetFlags() if err := m.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#38116ee0: field flags: %w", err) + return fmt.Errorf("unable to encode message#76bec211: field flags: %w", err) } b.PutInt(m.ID) if m.Flags.Has(8) { if m.FromID == nil { - return fmt.Errorf("unable to encode message#38116ee0: field from_id is nil") + return fmt.Errorf("unable to encode message#76bec211: field from_id is nil") } if err := m.FromID.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#38116ee0: field from_id: %w", err) + return fmt.Errorf("unable to encode message#76bec211: field from_id: %w", err) } } if m.PeerID == nil { - return fmt.Errorf("unable to encode message#38116ee0: field peer_id is nil") + return fmt.Errorf("unable to encode message#76bec211: field peer_id is nil") } if err := m.PeerID.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#38116ee0: field peer_id: %w", err) + return fmt.Errorf("unable to encode message#76bec211: field peer_id: %w", err) + } + if m.Flags.Has(28) { + if m.SavedPeerID == nil { + return fmt.Errorf("unable to encode message#76bec211: field saved_peer_id is nil") + } + if err := m.SavedPeerID.Encode(b); err != nil { + return fmt.Errorf("unable to encode message#76bec211: field saved_peer_id: %w", err) + } } if m.Flags.Has(2) { if err := m.FwdFrom.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#38116ee0: field fwd_from: %w", err) + return fmt.Errorf("unable to encode message#76bec211: field fwd_from: %w", err) } } if m.Flags.Has(11) { @@ -924,38 +952,38 @@ func (m *Message) EncodeBare(b *bin.Buffer) error { } if m.Flags.Has(3) { if m.ReplyTo == nil { - return fmt.Errorf("unable to encode message#38116ee0: field reply_to is nil") + return fmt.Errorf("unable to encode message#76bec211: field reply_to is nil") } if err := m.ReplyTo.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#38116ee0: field reply_to: %w", err) + return fmt.Errorf("unable to encode message#76bec211: field reply_to: %w", err) } } b.PutInt(m.Date) b.PutString(m.Message) if m.Flags.Has(9) { if m.Media == nil { - return fmt.Errorf("unable to encode message#38116ee0: field media is nil") + return fmt.Errorf("unable to encode message#76bec211: field media is nil") } if err := m.Media.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#38116ee0: field media: %w", err) + return fmt.Errorf("unable to encode message#76bec211: field media: %w", err) } } if m.Flags.Has(6) { if m.ReplyMarkup == nil { - return fmt.Errorf("unable to encode message#38116ee0: field reply_markup is nil") + return fmt.Errorf("unable to encode message#76bec211: field reply_markup is nil") } if err := m.ReplyMarkup.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#38116ee0: field reply_markup: %w", err) + return fmt.Errorf("unable to encode message#76bec211: field reply_markup: %w", err) } } if m.Flags.Has(7) { b.PutVectorHeader(len(m.Entities)) for idx, v := range m.Entities { if v == nil { - return fmt.Errorf("unable to encode message#38116ee0: field entities element with index %d is nil", idx) + return fmt.Errorf("unable to encode message#76bec211: field entities element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#38116ee0: field entities element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode message#76bec211: field entities element with index %d: %w", idx, err) } } } @@ -967,7 +995,7 @@ func (m *Message) EncodeBare(b *bin.Buffer) error { } if m.Flags.Has(23) { if err := m.Replies.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#38116ee0: field replies: %w", err) + return fmt.Errorf("unable to encode message#76bec211: field replies: %w", err) } } if m.Flags.Has(15) { @@ -981,14 +1009,14 @@ func (m *Message) EncodeBare(b *bin.Buffer) error { } if m.Flags.Has(20) { if err := m.Reactions.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#38116ee0: field reactions: %w", err) + return fmt.Errorf("unable to encode message#76bec211: field reactions: %w", err) } } if m.Flags.Has(22) { b.PutVectorHeader(len(m.RestrictionReason)) for idx, v := range m.RestrictionReason { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode message#38116ee0: field restriction_reason element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode message#76bec211: field restriction_reason element with index %d: %w", idx, err) } } } @@ -1001,10 +1029,10 @@ func (m *Message) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (m *Message) Decode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode message#38116ee0 to nil") + return fmt.Errorf("can't decode message#76bec211 to nil") } if err := b.ConsumeID(MessageTypeID); err != nil { - return fmt.Errorf("unable to decode message#38116ee0: %w", err) + return fmt.Errorf("unable to decode message#76bec211: %w", err) } return m.DecodeBare(b) } @@ -1012,11 +1040,11 @@ func (m *Message) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (m *Message) DecodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode message#38116ee0 to nil") + return fmt.Errorf("can't decode message#76bec211 to nil") } { if err := m.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode message#38116ee0: field flags: %w", err) + return fmt.Errorf("unable to decode message#76bec211: field flags: %w", err) } } m.Out = m.Flags.Has(1) @@ -1033,75 +1061,82 @@ func (m *Message) DecodeBare(b *bin.Buffer) error { { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode message#38116ee0: field id: %w", err) + return fmt.Errorf("unable to decode message#76bec211: field id: %w", err) } m.ID = value } if m.Flags.Has(8) { value, err := DecodePeer(b) if err != nil { - return fmt.Errorf("unable to decode message#38116ee0: field from_id: %w", err) + return fmt.Errorf("unable to decode message#76bec211: field from_id: %w", err) } m.FromID = value } { value, err := DecodePeer(b) if err != nil { - return fmt.Errorf("unable to decode message#38116ee0: field peer_id: %w", err) + return fmt.Errorf("unable to decode message#76bec211: field peer_id: %w", err) } m.PeerID = value } + if m.Flags.Has(28) { + value, err := DecodePeer(b) + if err != nil { + return fmt.Errorf("unable to decode message#76bec211: field saved_peer_id: %w", err) + } + m.SavedPeerID = value + } if m.Flags.Has(2) { if err := m.FwdFrom.Decode(b); err != nil { - return fmt.Errorf("unable to decode message#38116ee0: field fwd_from: %w", err) + return fmt.Errorf("unable to decode message#76bec211: field fwd_from: %w", err) } } if m.Flags.Has(11) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode message#38116ee0: field via_bot_id: %w", err) + return fmt.Errorf("unable to decode message#76bec211: field via_bot_id: %w", err) } m.ViaBotID = value } if m.Flags.Has(3) { value, err := DecodeMessageReplyHeader(b) if err != nil { - return fmt.Errorf("unable to decode message#38116ee0: field reply_to: %w", err) + return fmt.Errorf("unable to decode message#76bec211: field reply_to: %w", err) } m.ReplyTo = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode message#38116ee0: field date: %w", err) + return fmt.Errorf("unable to decode message#76bec211: field date: %w", err) } m.Date = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode message#38116ee0: field message: %w", err) + return fmt.Errorf("unable to decode message#76bec211: field message: %w", err) } m.Message = value } if m.Flags.Has(9) { value, err := DecodeMessageMedia(b) if err != nil { - return fmt.Errorf("unable to decode message#38116ee0: field media: %w", err) + return fmt.Errorf("unable to decode message#76bec211: field media: %w", err) } m.Media = value } if m.Flags.Has(6) { value, err := DecodeReplyMarkup(b) if err != nil { - return fmt.Errorf("unable to decode message#38116ee0: field reply_markup: %w", err) + return fmt.Errorf("unable to decode message#76bec211: field reply_markup: %w", err) } m.ReplyMarkup = value } if m.Flags.Has(7) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode message#38116ee0: field entities: %w", err) + return fmt.Errorf("unable to decode message#76bec211: field entities: %w", err) } if headerLen > 0 { @@ -1110,7 +1145,7 @@ func (m *Message) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeMessageEntity(b) if err != nil { - return fmt.Errorf("unable to decode message#38116ee0: field entities: %w", err) + return fmt.Errorf("unable to decode message#76bec211: field entities: %w", err) } m.Entities = append(m.Entities, value) } @@ -1118,52 +1153,52 @@ func (m *Message) DecodeBare(b *bin.Buffer) error { if m.Flags.Has(10) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode message#38116ee0: field views: %w", err) + return fmt.Errorf("unable to decode message#76bec211: field views: %w", err) } m.Views = value } if m.Flags.Has(10) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode message#38116ee0: field forwards: %w", err) + return fmt.Errorf("unable to decode message#76bec211: field forwards: %w", err) } m.Forwards = value } if m.Flags.Has(23) { if err := m.Replies.Decode(b); err != nil { - return fmt.Errorf("unable to decode message#38116ee0: field replies: %w", err) + return fmt.Errorf("unable to decode message#76bec211: field replies: %w", err) } } if m.Flags.Has(15) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode message#38116ee0: field edit_date: %w", err) + return fmt.Errorf("unable to decode message#76bec211: field edit_date: %w", err) } m.EditDate = value } if m.Flags.Has(16) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode message#38116ee0: field post_author: %w", err) + return fmt.Errorf("unable to decode message#76bec211: field post_author: %w", err) } m.PostAuthor = value } if m.Flags.Has(17) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode message#38116ee0: field grouped_id: %w", err) + return fmt.Errorf("unable to decode message#76bec211: field grouped_id: %w", err) } m.GroupedID = value } if m.Flags.Has(20) { if err := m.Reactions.Decode(b); err != nil { - return fmt.Errorf("unable to decode message#38116ee0: field reactions: %w", err) + return fmt.Errorf("unable to decode message#76bec211: field reactions: %w", err) } } if m.Flags.Has(22) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode message#38116ee0: field restriction_reason: %w", err) + return fmt.Errorf("unable to decode message#76bec211: field restriction_reason: %w", err) } if headerLen > 0 { @@ -1172,7 +1207,7 @@ func (m *Message) 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 message#38116ee0: field restriction_reason: %w", err) + return fmt.Errorf("unable to decode message#76bec211: field restriction_reason: %w", err) } m.RestrictionReason = append(m.RestrictionReason, value) } @@ -1180,7 +1215,7 @@ func (m *Message) DecodeBare(b *bin.Buffer) error { if m.Flags.Has(25) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode message#38116ee0: field ttl_period: %w", err) + return fmt.Errorf("unable to decode message#76bec211: field ttl_period: %w", err) } m.TTLPeriod = value } @@ -1430,6 +1465,24 @@ func (m *Message) GetPeerID() (value PeerClass) { return m.PeerID } +// SetSavedPeerID sets value of SavedPeerID conditional field. +func (m *Message) SetSavedPeerID(value PeerClass) { + m.Flags.Set(28) + m.SavedPeerID = value +} + +// GetSavedPeerID returns value of SavedPeerID conditional field and +// boolean which is true if field was set. +func (m *Message) GetSavedPeerID() (value PeerClass, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(28) { + return value, false + } + return m.SavedPeerID, true +} + // SetFwdFrom sets value of FwdFrom conditional field. func (m *Message) SetFwdFrom(value MessageFwdHeader) { m.Flags.Set(2) @@ -2351,7 +2404,7 @@ const MessageClassName = "Message" // } // switch v := g.(type) { // case *tg.MessageEmpty: // messageEmpty#90a6ca84 -// case *tg.Message: // message#38116ee0 +// case *tg.Message: // message#76bec211 // case *tg.MessageService: // messageService#2b085862 // default: panic(v) // } @@ -2489,7 +2542,7 @@ func DecodeMessage(buf *bin.Buffer) (MessageClass, error) { } return &v, nil case MessageTypeID: - // Decoding message#38116ee0. + // Decoding message#76bec211. v := Message{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode MessageClass: %w", err) diff --git a/tg/tl_message_media_gen.go b/tg/tl_message_media_gen.go index dc104e0ffb..c64a8570bf 100644 --- a/tg/tl_message_media_gen.go +++ b/tg/tl_message_media_gen.go @@ -898,6 +898,12 @@ type MessageMediaDocument struct { Nopremium bool // Whether this media should be hidden behind a spoiler warning Spoiler bool + // Video field of MessageMediaDocument. + Video bool + // Round field of MessageMediaDocument. + Round bool + // Voice field of MessageMediaDocument. + Voice bool // Attached document // // Use SetDocument and GetDocument helpers. @@ -943,6 +949,15 @@ func (m *MessageMediaDocument) Zero() bool { if !(m.Spoiler == false) { return false } + if !(m.Video == false) { + return false + } + if !(m.Round == false) { + return false + } + if !(m.Voice == false) { + return false + } if !(m.Document == nil) { return false } @@ -969,12 +984,18 @@ func (m *MessageMediaDocument) String() string { func (m *MessageMediaDocument) FillFrom(from interface { GetNopremium() (value bool) GetSpoiler() (value bool) + GetVideo() (value bool) + GetRound() (value bool) + GetVoice() (value bool) GetDocument() (value DocumentClass, ok bool) GetAltDocument() (value DocumentClass, ok bool) GetTTLSeconds() (value int, ok bool) }) { m.Nopremium = from.GetNopremium() m.Spoiler = from.GetSpoiler() + m.Video = from.GetVideo() + m.Round = from.GetRound() + m.Voice = from.GetVoice() if val, ok := from.GetDocument(); ok { m.Document = val } @@ -1022,6 +1043,21 @@ func (m *MessageMediaDocument) TypeInfo() tdp.Type { SchemaName: "spoiler", Null: !m.Flags.Has(4), }, + { + Name: "Video", + SchemaName: "video", + Null: !m.Flags.Has(6), + }, + { + Name: "Round", + SchemaName: "round", + Null: !m.Flags.Has(7), + }, + { + Name: "Voice", + SchemaName: "voice", + Null: !m.Flags.Has(8), + }, { Name: "Document", SchemaName: "document", @@ -1049,6 +1085,15 @@ func (m *MessageMediaDocument) SetFlags() { if !(m.Spoiler == false) { m.Flags.Set(4) } + if !(m.Video == false) { + m.Flags.Set(6) + } + if !(m.Round == false) { + m.Flags.Set(7) + } + if !(m.Voice == false) { + m.Flags.Set(8) + } if !(m.Document == nil) { m.Flags.Set(0) } @@ -1123,6 +1168,9 @@ func (m *MessageMediaDocument) DecodeBare(b *bin.Buffer) error { } m.Nopremium = m.Flags.Has(3) m.Spoiler = m.Flags.Has(4) + m.Video = m.Flags.Has(6) + m.Round = m.Flags.Has(7) + m.Voice = m.Flags.Has(8) if m.Flags.Has(0) { value, err := DecodeDocument(b) if err != nil { @@ -1185,6 +1233,63 @@ func (m *MessageMediaDocument) GetSpoiler() (value bool) { return m.Flags.Has(4) } +// SetVideo sets value of Video conditional field. +func (m *MessageMediaDocument) SetVideo(value bool) { + if value { + m.Flags.Set(6) + m.Video = true + } else { + m.Flags.Unset(6) + m.Video = false + } +} + +// GetVideo returns value of Video conditional field. +func (m *MessageMediaDocument) GetVideo() (value bool) { + if m == nil { + return + } + return m.Flags.Has(6) +} + +// SetRound sets value of Round conditional field. +func (m *MessageMediaDocument) SetRound(value bool) { + if value { + m.Flags.Set(7) + m.Round = true + } else { + m.Flags.Unset(7) + m.Round = false + } +} + +// GetRound returns value of Round conditional field. +func (m *MessageMediaDocument) GetRound() (value bool) { + if m == nil { + return + } + return m.Flags.Has(7) +} + +// SetVoice sets value of Voice conditional field. +func (m *MessageMediaDocument) SetVoice(value bool) { + if value { + m.Flags.Set(8) + m.Voice = true + } else { + m.Flags.Unset(8) + m.Voice = false + } +} + +// GetVoice returns value of Voice conditional field. +func (m *MessageMediaDocument) GetVoice() (value bool) { + if m == nil { + return + } + return m.Flags.Has(8) +} + // SetDocument sets value of Document conditional field. func (m *MessageMediaDocument) SetDocument(value DocumentClass) { m.Flags.Set(0) diff --git a/tg/tl_messages_delete_saved_history_gen.go b/tg/tl_messages_delete_saved_history_gen.go new file mode 100644 index 0000000000..edf7e6e048 --- /dev/null +++ b/tg/tl_messages_delete_saved_history_gen.go @@ -0,0 +1,319 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// MessagesDeleteSavedHistoryRequest represents TL type `messages.deleteSavedHistory#6e98102b`. +// +// See https://core.telegram.org/method/messages.deleteSavedHistory for reference. +type MessagesDeleteSavedHistoryRequest struct { + // Flags field of MessagesDeleteSavedHistoryRequest. + Flags bin.Fields + // Peer field of MessagesDeleteSavedHistoryRequest. + Peer InputPeerClass + // MaxID field of MessagesDeleteSavedHistoryRequest. + MaxID int + // MinDate field of MessagesDeleteSavedHistoryRequest. + // + // Use SetMinDate and GetMinDate helpers. + MinDate int + // MaxDate field of MessagesDeleteSavedHistoryRequest. + // + // Use SetMaxDate and GetMaxDate helpers. + MaxDate int +} + +// MessagesDeleteSavedHistoryRequestTypeID is TL type id of MessagesDeleteSavedHistoryRequest. +const MessagesDeleteSavedHistoryRequestTypeID = 0x6e98102b + +// Ensuring interfaces in compile-time for MessagesDeleteSavedHistoryRequest. +var ( + _ bin.Encoder = &MessagesDeleteSavedHistoryRequest{} + _ bin.Decoder = &MessagesDeleteSavedHistoryRequest{} + _ bin.BareEncoder = &MessagesDeleteSavedHistoryRequest{} + _ bin.BareDecoder = &MessagesDeleteSavedHistoryRequest{} +) + +func (d *MessagesDeleteSavedHistoryRequest) Zero() bool { + if d == nil { + return true + } + if !(d.Flags.Zero()) { + return false + } + if !(d.Peer == nil) { + return false + } + if !(d.MaxID == 0) { + return false + } + if !(d.MinDate == 0) { + return false + } + if !(d.MaxDate == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (d *MessagesDeleteSavedHistoryRequest) String() string { + if d == nil { + return "MessagesDeleteSavedHistoryRequest(nil)" + } + type Alias MessagesDeleteSavedHistoryRequest + return fmt.Sprintf("MessagesDeleteSavedHistoryRequest%+v", Alias(*d)) +} + +// FillFrom fills MessagesDeleteSavedHistoryRequest from given interface. +func (d *MessagesDeleteSavedHistoryRequest) FillFrom(from interface { + GetPeer() (value InputPeerClass) + GetMaxID() (value int) + GetMinDate() (value int, ok bool) + GetMaxDate() (value int, ok bool) +}) { + d.Peer = from.GetPeer() + d.MaxID = from.GetMaxID() + if val, ok := from.GetMinDate(); ok { + d.MinDate = val + } + + if val, ok := from.GetMaxDate(); ok { + d.MaxDate = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesDeleteSavedHistoryRequest) TypeID() uint32 { + return MessagesDeleteSavedHistoryRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesDeleteSavedHistoryRequest) TypeName() string { + return "messages.deleteSavedHistory" +} + +// TypeInfo returns info about TL type. +func (d *MessagesDeleteSavedHistoryRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.deleteSavedHistory", + ID: MessagesDeleteSavedHistoryRequestTypeID, + } + if d == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "MaxID", + SchemaName: "max_id", + }, + { + Name: "MinDate", + SchemaName: "min_date", + Null: !d.Flags.Has(2), + }, + { + Name: "MaxDate", + SchemaName: "max_date", + Null: !d.Flags.Has(3), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (d *MessagesDeleteSavedHistoryRequest) SetFlags() { + if !(d.MinDate == 0) { + d.Flags.Set(2) + } + if !(d.MaxDate == 0) { + d.Flags.Set(3) + } +} + +// Encode implements bin.Encoder. +func (d *MessagesDeleteSavedHistoryRequest) Encode(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't encode messages.deleteSavedHistory#6e98102b as nil") + } + b.PutID(MessagesDeleteSavedHistoryRequestTypeID) + return d.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (d *MessagesDeleteSavedHistoryRequest) EncodeBare(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't encode messages.deleteSavedHistory#6e98102b as nil") + } + d.SetFlags() + if err := d.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.deleteSavedHistory#6e98102b: field flags: %w", err) + } + if d.Peer == nil { + return fmt.Errorf("unable to encode messages.deleteSavedHistory#6e98102b: field peer is nil") + } + if err := d.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.deleteSavedHistory#6e98102b: field peer: %w", err) + } + b.PutInt(d.MaxID) + if d.Flags.Has(2) { + b.PutInt(d.MinDate) + } + if d.Flags.Has(3) { + b.PutInt(d.MaxDate) + } + return nil +} + +// Decode implements bin.Decoder. +func (d *MessagesDeleteSavedHistoryRequest) Decode(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't decode messages.deleteSavedHistory#6e98102b to nil") + } + if err := b.ConsumeID(MessagesDeleteSavedHistoryRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.deleteSavedHistory#6e98102b: %w", err) + } + return d.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (d *MessagesDeleteSavedHistoryRequest) DecodeBare(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't decode messages.deleteSavedHistory#6e98102b to nil") + } + { + if err := d.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.deleteSavedHistory#6e98102b: field flags: %w", err) + } + } + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode messages.deleteSavedHistory#6e98102b: field peer: %w", err) + } + d.Peer = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.deleteSavedHistory#6e98102b: field max_id: %w", err) + } + d.MaxID = value + } + if d.Flags.Has(2) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.deleteSavedHistory#6e98102b: field min_date: %w", err) + } + d.MinDate = value + } + if d.Flags.Has(3) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.deleteSavedHistory#6e98102b: field max_date: %w", err) + } + d.MaxDate = value + } + return nil +} + +// GetPeer returns value of Peer field. +func (d *MessagesDeleteSavedHistoryRequest) GetPeer() (value InputPeerClass) { + if d == nil { + return + } + return d.Peer +} + +// GetMaxID returns value of MaxID field. +func (d *MessagesDeleteSavedHistoryRequest) GetMaxID() (value int) { + if d == nil { + return + } + return d.MaxID +} + +// SetMinDate sets value of MinDate conditional field. +func (d *MessagesDeleteSavedHistoryRequest) SetMinDate(value int) { + d.Flags.Set(2) + d.MinDate = value +} + +// GetMinDate returns value of MinDate conditional field and +// boolean which is true if field was set. +func (d *MessagesDeleteSavedHistoryRequest) GetMinDate() (value int, ok bool) { + if d == nil { + return + } + if !d.Flags.Has(2) { + return value, false + } + return d.MinDate, true +} + +// SetMaxDate sets value of MaxDate conditional field. +func (d *MessagesDeleteSavedHistoryRequest) SetMaxDate(value int) { + d.Flags.Set(3) + d.MaxDate = value +} + +// GetMaxDate returns value of MaxDate conditional field and +// boolean which is true if field was set. +func (d *MessagesDeleteSavedHistoryRequest) GetMaxDate() (value int, ok bool) { + if d == nil { + return + } + if !d.Flags.Has(3) { + return value, false + } + return d.MaxDate, true +} + +// MessagesDeleteSavedHistory invokes method messages.deleteSavedHistory#6e98102b returning error if any. +// +// See https://core.telegram.org/method/messages.deleteSavedHistory for reference. +func (c *Client) MessagesDeleteSavedHistory(ctx context.Context, request *MessagesDeleteSavedHistoryRequest) (*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_messages_delete_saved_history_slices_gen.go b/tg/tl_messages_delete_saved_history_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_delete_saved_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_messages_get_pinned_saved_dialogs_gen.go b/tg/tl_messages_get_pinned_saved_dialogs_gen.go new file mode 100644 index 0000000000..4aa420db37 --- /dev/null +++ b/tg/tl_messages_get_pinned_saved_dialogs_gen.go @@ -0,0 +1,141 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// MessagesGetPinnedSavedDialogsRequest represents TL type `messages.getPinnedSavedDialogs#d63d94e0`. +// +// See https://core.telegram.org/method/messages.getPinnedSavedDialogs for reference. +type MessagesGetPinnedSavedDialogsRequest struct { +} + +// MessagesGetPinnedSavedDialogsRequestTypeID is TL type id of MessagesGetPinnedSavedDialogsRequest. +const MessagesGetPinnedSavedDialogsRequestTypeID = 0xd63d94e0 + +// Ensuring interfaces in compile-time for MessagesGetPinnedSavedDialogsRequest. +var ( + _ bin.Encoder = &MessagesGetPinnedSavedDialogsRequest{} + _ bin.Decoder = &MessagesGetPinnedSavedDialogsRequest{} + _ bin.BareEncoder = &MessagesGetPinnedSavedDialogsRequest{} + _ bin.BareDecoder = &MessagesGetPinnedSavedDialogsRequest{} +) + +func (g *MessagesGetPinnedSavedDialogsRequest) Zero() bool { + if g == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (g *MessagesGetPinnedSavedDialogsRequest) String() string { + if g == nil { + return "MessagesGetPinnedSavedDialogsRequest(nil)" + } + type Alias MessagesGetPinnedSavedDialogsRequest + return fmt.Sprintf("MessagesGetPinnedSavedDialogsRequest%+v", Alias(*g)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesGetPinnedSavedDialogsRequest) TypeID() uint32 { + return MessagesGetPinnedSavedDialogsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesGetPinnedSavedDialogsRequest) TypeName() string { + return "messages.getPinnedSavedDialogs" +} + +// TypeInfo returns info about TL type. +func (g *MessagesGetPinnedSavedDialogsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.getPinnedSavedDialogs", + ID: MessagesGetPinnedSavedDialogsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (g *MessagesGetPinnedSavedDialogsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode messages.getPinnedSavedDialogs#d63d94e0 as nil") + } + b.PutID(MessagesGetPinnedSavedDialogsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *MessagesGetPinnedSavedDialogsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode messages.getPinnedSavedDialogs#d63d94e0 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (g *MessagesGetPinnedSavedDialogsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode messages.getPinnedSavedDialogs#d63d94e0 to nil") + } + if err := b.ConsumeID(MessagesGetPinnedSavedDialogsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.getPinnedSavedDialogs#d63d94e0: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *MessagesGetPinnedSavedDialogsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode messages.getPinnedSavedDialogs#d63d94e0 to nil") + } + return nil +} + +// MessagesGetPinnedSavedDialogs invokes method messages.getPinnedSavedDialogs#d63d94e0 returning error if any. +// +// See https://core.telegram.org/method/messages.getPinnedSavedDialogs for reference. +func (c *Client) MessagesGetPinnedSavedDialogs(ctx context.Context) (MessagesSavedDialogsClass, error) { + var result MessagesSavedDialogsBox + + request := &MessagesGetPinnedSavedDialogsRequest{} + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.SavedDialogs, nil +} diff --git a/tg/tl_messages_get_pinned_saved_dialogs_slices_gen.go b/tg/tl_messages_get_pinned_saved_dialogs_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_get_pinned_saved_dialogs_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_get_saved_dialogs_gen.go b/tg/tl_messages_get_saved_dialogs_gen.go new file mode 100644 index 0000000000..80d0e127b5 --- /dev/null +++ b/tg/tl_messages_get_saved_dialogs_gen.go @@ -0,0 +1,339 @@ +// 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{} +) + +// MessagesGetSavedDialogsRequest represents TL type `messages.getSavedDialogs#5381d21a`. +// +// See https://core.telegram.org/method/messages.getSavedDialogs for reference. +type MessagesGetSavedDialogsRequest struct { + // Flags field of MessagesGetSavedDialogsRequest. + Flags bin.Fields + // ExcludePinned field of MessagesGetSavedDialogsRequest. + ExcludePinned bool + // OffsetDate field of MessagesGetSavedDialogsRequest. + OffsetDate int + // OffsetID field of MessagesGetSavedDialogsRequest. + OffsetID int + // OffsetPeer field of MessagesGetSavedDialogsRequest. + OffsetPeer InputPeerClass + // Limit field of MessagesGetSavedDialogsRequest. + Limit int + // Hash field of MessagesGetSavedDialogsRequest. + Hash int64 +} + +// MessagesGetSavedDialogsRequestTypeID is TL type id of MessagesGetSavedDialogsRequest. +const MessagesGetSavedDialogsRequestTypeID = 0x5381d21a + +// Ensuring interfaces in compile-time for MessagesGetSavedDialogsRequest. +var ( + _ bin.Encoder = &MessagesGetSavedDialogsRequest{} + _ bin.Decoder = &MessagesGetSavedDialogsRequest{} + _ bin.BareEncoder = &MessagesGetSavedDialogsRequest{} + _ bin.BareDecoder = &MessagesGetSavedDialogsRequest{} +) + +func (g *MessagesGetSavedDialogsRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Flags.Zero()) { + return false + } + if !(g.ExcludePinned == false) { + return false + } + if !(g.OffsetDate == 0) { + return false + } + if !(g.OffsetID == 0) { + return false + } + if !(g.OffsetPeer == nil) { + return false + } + if !(g.Limit == 0) { + return false + } + if !(g.Hash == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *MessagesGetSavedDialogsRequest) String() string { + if g == nil { + return "MessagesGetSavedDialogsRequest(nil)" + } + type Alias MessagesGetSavedDialogsRequest + return fmt.Sprintf("MessagesGetSavedDialogsRequest%+v", Alias(*g)) +} + +// FillFrom fills MessagesGetSavedDialogsRequest from given interface. +func (g *MessagesGetSavedDialogsRequest) FillFrom(from interface { + GetExcludePinned() (value bool) + GetOffsetDate() (value int) + GetOffsetID() (value int) + GetOffsetPeer() (value InputPeerClass) + GetLimit() (value int) + GetHash() (value int64) +}) { + g.ExcludePinned = from.GetExcludePinned() + g.OffsetDate = from.GetOffsetDate() + g.OffsetID = from.GetOffsetID() + g.OffsetPeer = from.GetOffsetPeer() + g.Limit = from.GetLimit() + g.Hash = from.GetHash() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesGetSavedDialogsRequest) TypeID() uint32 { + return MessagesGetSavedDialogsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesGetSavedDialogsRequest) TypeName() string { + return "messages.getSavedDialogs" +} + +// TypeInfo returns info about TL type. +func (g *MessagesGetSavedDialogsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.getSavedDialogs", + ID: MessagesGetSavedDialogsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ExcludePinned", + SchemaName: "exclude_pinned", + Null: !g.Flags.Has(0), + }, + { + Name: "OffsetDate", + SchemaName: "offset_date", + }, + { + Name: "OffsetID", + SchemaName: "offset_id", + }, + { + Name: "OffsetPeer", + SchemaName: "offset_peer", + }, + { + Name: "Limit", + SchemaName: "limit", + }, + { + Name: "Hash", + SchemaName: "hash", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (g *MessagesGetSavedDialogsRequest) SetFlags() { + if !(g.ExcludePinned == false) { + g.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (g *MessagesGetSavedDialogsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode messages.getSavedDialogs#5381d21a as nil") + } + b.PutID(MessagesGetSavedDialogsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *MessagesGetSavedDialogsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode messages.getSavedDialogs#5381d21a as nil") + } + g.SetFlags() + if err := g.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.getSavedDialogs#5381d21a: field flags: %w", err) + } + b.PutInt(g.OffsetDate) + b.PutInt(g.OffsetID) + if g.OffsetPeer == nil { + return fmt.Errorf("unable to encode messages.getSavedDialogs#5381d21a: field offset_peer is nil") + } + if err := g.OffsetPeer.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.getSavedDialogs#5381d21a: field offset_peer: %w", err) + } + b.PutInt(g.Limit) + b.PutLong(g.Hash) + return nil +} + +// Decode implements bin.Decoder. +func (g *MessagesGetSavedDialogsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode messages.getSavedDialogs#5381d21a to nil") + } + if err := b.ConsumeID(MessagesGetSavedDialogsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.getSavedDialogs#5381d21a: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *MessagesGetSavedDialogsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode messages.getSavedDialogs#5381d21a to nil") + } + { + if err := g.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.getSavedDialogs#5381d21a: field flags: %w", err) + } + } + g.ExcludePinned = g.Flags.Has(0) + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.getSavedDialogs#5381d21a: field offset_date: %w", err) + } + g.OffsetDate = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.getSavedDialogs#5381d21a: field offset_id: %w", err) + } + g.OffsetID = value + } + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode messages.getSavedDialogs#5381d21a: field offset_peer: %w", err) + } + g.OffsetPeer = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.getSavedDialogs#5381d21a: field limit: %w", err) + } + g.Limit = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messages.getSavedDialogs#5381d21a: field hash: %w", err) + } + g.Hash = value + } + return nil +} + +// SetExcludePinned sets value of ExcludePinned conditional field. +func (g *MessagesGetSavedDialogsRequest) SetExcludePinned(value bool) { + if value { + g.Flags.Set(0) + g.ExcludePinned = true + } else { + g.Flags.Unset(0) + g.ExcludePinned = false + } +} + +// GetExcludePinned returns value of ExcludePinned conditional field. +func (g *MessagesGetSavedDialogsRequest) GetExcludePinned() (value bool) { + if g == nil { + return + } + return g.Flags.Has(0) +} + +// GetOffsetDate returns value of OffsetDate field. +func (g *MessagesGetSavedDialogsRequest) GetOffsetDate() (value int) { + if g == nil { + return + } + return g.OffsetDate +} + +// GetOffsetID returns value of OffsetID field. +func (g *MessagesGetSavedDialogsRequest) GetOffsetID() (value int) { + if g == nil { + return + } + return g.OffsetID +} + +// GetOffsetPeer returns value of OffsetPeer field. +func (g *MessagesGetSavedDialogsRequest) GetOffsetPeer() (value InputPeerClass) { + if g == nil { + return + } + return g.OffsetPeer +} + +// GetLimit returns value of Limit field. +func (g *MessagesGetSavedDialogsRequest) GetLimit() (value int) { + if g == nil { + return + } + return g.Limit +} + +// GetHash returns value of Hash field. +func (g *MessagesGetSavedDialogsRequest) GetHash() (value int64) { + if g == nil { + return + } + return g.Hash +} + +// MessagesGetSavedDialogs invokes method messages.getSavedDialogs#5381d21a returning error if any. +// +// See https://core.telegram.org/method/messages.getSavedDialogs for reference. +func (c *Client) MessagesGetSavedDialogs(ctx context.Context, request *MessagesGetSavedDialogsRequest) (MessagesSavedDialogsClass, error) { + var result MessagesSavedDialogsBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.SavedDialogs, nil +} diff --git a/tg/tl_messages_get_saved_dialogs_slices_gen.go b/tg/tl_messages_get_saved_dialogs_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_get_saved_dialogs_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_get_saved_history_gen.go b/tg/tl_messages_get_saved_history_gen.go new file mode 100644 index 0000000000..741ea16aea --- /dev/null +++ b/tg/tl_messages_get_saved_history_gen.go @@ -0,0 +1,367 @@ +// 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{} +) + +// MessagesGetSavedHistoryRequest represents TL type `messages.getSavedHistory#3d9a414d`. +// +// See https://core.telegram.org/method/messages.getSavedHistory for reference. +type MessagesGetSavedHistoryRequest struct { + // Peer field of MessagesGetSavedHistoryRequest. + Peer InputPeerClass + // OffsetID field of MessagesGetSavedHistoryRequest. + OffsetID int + // OffsetDate field of MessagesGetSavedHistoryRequest. + OffsetDate int + // AddOffset field of MessagesGetSavedHistoryRequest. + AddOffset int + // Limit field of MessagesGetSavedHistoryRequest. + Limit int + // MaxID field of MessagesGetSavedHistoryRequest. + MaxID int + // MinID field of MessagesGetSavedHistoryRequest. + MinID int + // Hash field of MessagesGetSavedHistoryRequest. + Hash int64 +} + +// MessagesGetSavedHistoryRequestTypeID is TL type id of MessagesGetSavedHistoryRequest. +const MessagesGetSavedHistoryRequestTypeID = 0x3d9a414d + +// Ensuring interfaces in compile-time for MessagesGetSavedHistoryRequest. +var ( + _ bin.Encoder = &MessagesGetSavedHistoryRequest{} + _ bin.Decoder = &MessagesGetSavedHistoryRequest{} + _ bin.BareEncoder = &MessagesGetSavedHistoryRequest{} + _ bin.BareDecoder = &MessagesGetSavedHistoryRequest{} +) + +func (g *MessagesGetSavedHistoryRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Peer == nil) { + return false + } + if !(g.OffsetID == 0) { + return false + } + if !(g.OffsetDate == 0) { + return false + } + if !(g.AddOffset == 0) { + return false + } + if !(g.Limit == 0) { + return false + } + if !(g.MaxID == 0) { + return false + } + if !(g.MinID == 0) { + return false + } + if !(g.Hash == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *MessagesGetSavedHistoryRequest) String() string { + if g == nil { + return "MessagesGetSavedHistoryRequest(nil)" + } + type Alias MessagesGetSavedHistoryRequest + return fmt.Sprintf("MessagesGetSavedHistoryRequest%+v", Alias(*g)) +} + +// FillFrom fills MessagesGetSavedHistoryRequest from given interface. +func (g *MessagesGetSavedHistoryRequest) FillFrom(from interface { + GetPeer() (value InputPeerClass) + GetOffsetID() (value int) + GetOffsetDate() (value int) + GetAddOffset() (value int) + GetLimit() (value int) + GetMaxID() (value int) + GetMinID() (value int) + GetHash() (value int64) +}) { + g.Peer = from.GetPeer() + g.OffsetID = from.GetOffsetID() + g.OffsetDate = from.GetOffsetDate() + g.AddOffset = from.GetAddOffset() + g.Limit = from.GetLimit() + g.MaxID = from.GetMaxID() + g.MinID = from.GetMinID() + g.Hash = from.GetHash() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesGetSavedHistoryRequest) TypeID() uint32 { + return MessagesGetSavedHistoryRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesGetSavedHistoryRequest) TypeName() string { + return "messages.getSavedHistory" +} + +// TypeInfo returns info about TL type. +func (g *MessagesGetSavedHistoryRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.getSavedHistory", + ID: MessagesGetSavedHistoryRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "OffsetID", + SchemaName: "offset_id", + }, + { + Name: "OffsetDate", + SchemaName: "offset_date", + }, + { + Name: "AddOffset", + SchemaName: "add_offset", + }, + { + Name: "Limit", + SchemaName: "limit", + }, + { + Name: "MaxID", + SchemaName: "max_id", + }, + { + Name: "MinID", + SchemaName: "min_id", + }, + { + Name: "Hash", + SchemaName: "hash", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *MessagesGetSavedHistoryRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode messages.getSavedHistory#3d9a414d as nil") + } + b.PutID(MessagesGetSavedHistoryRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *MessagesGetSavedHistoryRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode messages.getSavedHistory#3d9a414d as nil") + } + if g.Peer == nil { + return fmt.Errorf("unable to encode messages.getSavedHistory#3d9a414d: field peer is nil") + } + if err := g.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.getSavedHistory#3d9a414d: field peer: %w", err) + } + b.PutInt(g.OffsetID) + b.PutInt(g.OffsetDate) + b.PutInt(g.AddOffset) + b.PutInt(g.Limit) + b.PutInt(g.MaxID) + b.PutInt(g.MinID) + b.PutLong(g.Hash) + return nil +} + +// Decode implements bin.Decoder. +func (g *MessagesGetSavedHistoryRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode messages.getSavedHistory#3d9a414d to nil") + } + if err := b.ConsumeID(MessagesGetSavedHistoryRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.getSavedHistory#3d9a414d: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *MessagesGetSavedHistoryRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode messages.getSavedHistory#3d9a414d to nil") + } + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode messages.getSavedHistory#3d9a414d: field peer: %w", err) + } + g.Peer = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.getSavedHistory#3d9a414d: field offset_id: %w", err) + } + g.OffsetID = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.getSavedHistory#3d9a414d: field offset_date: %w", err) + } + g.OffsetDate = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.getSavedHistory#3d9a414d: field add_offset: %w", err) + } + g.AddOffset = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.getSavedHistory#3d9a414d: field limit: %w", err) + } + g.Limit = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.getSavedHistory#3d9a414d: field max_id: %w", err) + } + g.MaxID = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.getSavedHistory#3d9a414d: field min_id: %w", err) + } + g.MinID = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messages.getSavedHistory#3d9a414d: field hash: %w", err) + } + g.Hash = value + } + return nil +} + +// GetPeer returns value of Peer field. +func (g *MessagesGetSavedHistoryRequest) GetPeer() (value InputPeerClass) { + if g == nil { + return + } + return g.Peer +} + +// GetOffsetID returns value of OffsetID field. +func (g *MessagesGetSavedHistoryRequest) GetOffsetID() (value int) { + if g == nil { + return + } + return g.OffsetID +} + +// GetOffsetDate returns value of OffsetDate field. +func (g *MessagesGetSavedHistoryRequest) GetOffsetDate() (value int) { + if g == nil { + return + } + return g.OffsetDate +} + +// GetAddOffset returns value of AddOffset field. +func (g *MessagesGetSavedHistoryRequest) GetAddOffset() (value int) { + if g == nil { + return + } + return g.AddOffset +} + +// GetLimit returns value of Limit field. +func (g *MessagesGetSavedHistoryRequest) GetLimit() (value int) { + if g == nil { + return + } + return g.Limit +} + +// GetMaxID returns value of MaxID field. +func (g *MessagesGetSavedHistoryRequest) GetMaxID() (value int) { + if g == nil { + return + } + return g.MaxID +} + +// GetMinID returns value of MinID field. +func (g *MessagesGetSavedHistoryRequest) GetMinID() (value int) { + if g == nil { + return + } + return g.MinID +} + +// GetHash returns value of Hash field. +func (g *MessagesGetSavedHistoryRequest) GetHash() (value int64) { + if g == nil { + return + } + return g.Hash +} + +// MessagesGetSavedHistory invokes method messages.getSavedHistory#3d9a414d returning error if any. +// +// See https://core.telegram.org/method/messages.getSavedHistory for reference. +func (c *Client) MessagesGetSavedHistory(ctx context.Context, request *MessagesGetSavedHistoryRequest) (MessagesMessagesClass, error) { + var result MessagesMessagesBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.Messages, nil +} diff --git a/tg/tl_messages_get_saved_history_slices_gen.go b/tg/tl_messages_get_saved_history_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_get_saved_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_messages_get_search_counters_gen.go b/tg/tl_messages_get_search_counters_gen.go index 80e256b821..1a56b17d32 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#ae7cc1`. +// MessagesGetSearchCountersRequest represents TL type `messages.getSearchCounters#1bbcf300`. // Get the number of results that would be found by a messages.search¹ call with the // same parameters // @@ -47,6 +47,10 @@ type MessagesGetSearchCountersRequest struct { Flags bin.Fields // Peer where to search Peer InputPeerClass + // SavedPeerID field of MessagesGetSearchCountersRequest. + // + // Use SetSavedPeerID and GetSavedPeerID helpers. + SavedPeerID InputPeerClass // If set, consider only messages within the specified forum topic¹ // // Links: @@ -59,7 +63,7 @@ type MessagesGetSearchCountersRequest struct { } // MessagesGetSearchCountersRequestTypeID is TL type id of MessagesGetSearchCountersRequest. -const MessagesGetSearchCountersRequestTypeID = 0xae7cc1 +const MessagesGetSearchCountersRequestTypeID = 0x1bbcf300 // Ensuring interfaces in compile-time for MessagesGetSearchCountersRequest. var ( @@ -79,6 +83,9 @@ func (g *MessagesGetSearchCountersRequest) Zero() bool { if !(g.Peer == nil) { return false } + if !(g.SavedPeerID == nil) { + return false + } if !(g.TopMsgID == 0) { return false } @@ -101,10 +108,15 @@ func (g *MessagesGetSearchCountersRequest) String() string { // FillFrom fills MessagesGetSearchCountersRequest from given interface. func (g *MessagesGetSearchCountersRequest) FillFrom(from interface { GetPeer() (value InputPeerClass) + GetSavedPeerID() (value InputPeerClass, ok bool) GetTopMsgID() (value int, ok bool) GetFilters() (value []MessagesFilterClass) }) { g.Peer = from.GetPeer() + if val, ok := from.GetSavedPeerID(); ok { + g.SavedPeerID = val + } + if val, ok := from.GetTopMsgID(); ok { g.TopMsgID = val } @@ -139,6 +151,11 @@ func (g *MessagesGetSearchCountersRequest) TypeInfo() tdp.Type { Name: "Peer", SchemaName: "peer", }, + { + Name: "SavedPeerID", + SchemaName: "saved_peer_id", + Null: !g.Flags.Has(2), + }, { Name: "TopMsgID", SchemaName: "top_msg_id", @@ -154,6 +171,9 @@ func (g *MessagesGetSearchCountersRequest) TypeInfo() tdp.Type { // SetFlags sets flags for non-zero fields. func (g *MessagesGetSearchCountersRequest) SetFlags() { + if !(g.SavedPeerID == nil) { + g.Flags.Set(2) + } if !(g.TopMsgID == 0) { g.Flags.Set(0) } @@ -162,7 +182,7 @@ func (g *MessagesGetSearchCountersRequest) SetFlags() { // Encode implements bin.Encoder. func (g *MessagesGetSearchCountersRequest) Encode(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't encode messages.getSearchCounters#ae7cc1 as nil") + return fmt.Errorf("can't encode messages.getSearchCounters#1bbcf300 as nil") } b.PutID(MessagesGetSearchCountersRequestTypeID) return g.EncodeBare(b) @@ -171,17 +191,25 @@ 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#ae7cc1 as nil") + return fmt.Errorf("can't encode messages.getSearchCounters#1bbcf300 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) + return fmt.Errorf("unable to encode messages.getSearchCounters#1bbcf300: field flags: %w", err) } if g.Peer == nil { - return fmt.Errorf("unable to encode messages.getSearchCounters#ae7cc1: field peer is nil") + return fmt.Errorf("unable to encode messages.getSearchCounters#1bbcf300: field peer is nil") } if err := g.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.getSearchCounters#ae7cc1: field peer: %w", err) + return fmt.Errorf("unable to encode messages.getSearchCounters#1bbcf300: field peer: %w", err) + } + if g.Flags.Has(2) { + if g.SavedPeerID == nil { + return fmt.Errorf("unable to encode messages.getSearchCounters#1bbcf300: field saved_peer_id is nil") + } + if err := g.SavedPeerID.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.getSearchCounters#1bbcf300: field saved_peer_id: %w", err) + } } if g.Flags.Has(0) { b.PutInt(g.TopMsgID) @@ -189,10 +217,10 @@ func (g *MessagesGetSearchCountersRequest) EncodeBare(b *bin.Buffer) error { b.PutVectorHeader(len(g.Filters)) for idx, v := range g.Filters { if v == nil { - return fmt.Errorf("unable to encode messages.getSearchCounters#ae7cc1: field filters element with index %d is nil", idx) + return fmt.Errorf("unable to encode messages.getSearchCounters#1bbcf300: field filters element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.getSearchCounters#ae7cc1: field filters element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode messages.getSearchCounters#1bbcf300: field filters element with index %d: %w", idx, err) } } return nil @@ -201,10 +229,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#ae7cc1 to nil") + return fmt.Errorf("can't decode messages.getSearchCounters#1bbcf300 to nil") } if err := b.ConsumeID(MessagesGetSearchCountersRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.getSearchCounters#ae7cc1: %w", err) + return fmt.Errorf("unable to decode messages.getSearchCounters#1bbcf300: %w", err) } return g.DecodeBare(b) } @@ -212,31 +240,38 @@ 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#ae7cc1 to nil") + return fmt.Errorf("can't decode messages.getSearchCounters#1bbcf300 to nil") } { if err := g.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.getSearchCounters#ae7cc1: field flags: %w", err) + return fmt.Errorf("unable to decode messages.getSearchCounters#1bbcf300: field flags: %w", err) } } { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.getSearchCounters#ae7cc1: field peer: %w", err) + return fmt.Errorf("unable to decode messages.getSearchCounters#1bbcf300: field peer: %w", err) } g.Peer = value } + if g.Flags.Has(2) { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode messages.getSearchCounters#1bbcf300: field saved_peer_id: %w", err) + } + g.SavedPeerID = 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) + return fmt.Errorf("unable to decode messages.getSearchCounters#1bbcf300: field top_msg_id: %w", err) } g.TopMsgID = value } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode messages.getSearchCounters#ae7cc1: field filters: %w", err) + return fmt.Errorf("unable to decode messages.getSearchCounters#1bbcf300: field filters: %w", err) } if headerLen > 0 { @@ -245,7 +280,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#ae7cc1: field filters: %w", err) + return fmt.Errorf("unable to decode messages.getSearchCounters#1bbcf300: field filters: %w", err) } g.Filters = append(g.Filters, value) } @@ -261,6 +296,24 @@ func (g *MessagesGetSearchCountersRequest) GetPeer() (value InputPeerClass) { return g.Peer } +// SetSavedPeerID sets value of SavedPeerID conditional field. +func (g *MessagesGetSearchCountersRequest) SetSavedPeerID(value InputPeerClass) { + g.Flags.Set(2) + g.SavedPeerID = value +} + +// GetSavedPeerID returns value of SavedPeerID conditional field and +// boolean which is true if field was set. +func (g *MessagesGetSearchCountersRequest) GetSavedPeerID() (value InputPeerClass, ok bool) { + if g == nil { + return + } + if !g.Flags.Has(2) { + return value, false + } + return g.SavedPeerID, true +} + // SetTopMsgID sets value of TopMsgID conditional field. func (g *MessagesGetSearchCountersRequest) SetTopMsgID(value int) { g.Flags.Set(0) @@ -292,7 +345,7 @@ func (g *MessagesGetSearchCountersRequest) MapFilters() (value MessagesFilterCla return MessagesFilterClassArray(g.Filters) } -// MessagesGetSearchCounters invokes method messages.getSearchCounters#ae7cc1 returning error if any. +// MessagesGetSearchCounters invokes method messages.getSearchCounters#1bbcf300 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_search_results_calendar_gen.go b/tg/tl_messages_get_search_results_calendar_gen.go index 0542dd48cd..9c57760543 100644 --- a/tg/tl_messages_get_search_results_calendar_gen.go +++ b/tg/tl_messages_get_search_results_calendar_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesGetSearchResultsCalendarRequest represents TL type `messages.getSearchResultsCalendar#49f0bde9`. +// MessagesGetSearchResultsCalendarRequest represents TL type `messages.getSearchResultsCalendar#6aa3f6bd`. // Returns information about the next messages of the specified type in the chat split by // days. // Returns the results in reverse chronological order. @@ -39,8 +39,14 @@ var ( // // See https://core.telegram.org/method/messages.getSearchResultsCalendar for reference. type MessagesGetSearchResultsCalendarRequest struct { + // Flags field of MessagesGetSearchResultsCalendarRequest. + Flags bin.Fields // Peer where to search Peer InputPeerClass + // SavedPeerID field of MessagesGetSearchResultsCalendarRequest. + // + // Use SetSavedPeerID and GetSavedPeerID helpers. + SavedPeerID InputPeerClass // Message filter, inputMessagesFilterEmpty¹, inputMessagesFilterMyMentions² filters // are not supported by this method. // @@ -61,7 +67,7 @@ type MessagesGetSearchResultsCalendarRequest struct { } // MessagesGetSearchResultsCalendarRequestTypeID is TL type id of MessagesGetSearchResultsCalendarRequest. -const MessagesGetSearchResultsCalendarRequestTypeID = 0x49f0bde9 +const MessagesGetSearchResultsCalendarRequestTypeID = 0x6aa3f6bd // Ensuring interfaces in compile-time for MessagesGetSearchResultsCalendarRequest. var ( @@ -75,9 +81,15 @@ func (g *MessagesGetSearchResultsCalendarRequest) Zero() bool { if g == nil { return true } + if !(g.Flags.Zero()) { + return false + } if !(g.Peer == nil) { return false } + if !(g.SavedPeerID == nil) { + return false + } if !(g.Filter == nil) { return false } @@ -103,11 +115,16 @@ func (g *MessagesGetSearchResultsCalendarRequest) String() string { // FillFrom fills MessagesGetSearchResultsCalendarRequest from given interface. func (g *MessagesGetSearchResultsCalendarRequest) FillFrom(from interface { GetPeer() (value InputPeerClass) + GetSavedPeerID() (value InputPeerClass, ok bool) GetFilter() (value MessagesFilterClass) GetOffsetID() (value int) GetOffsetDate() (value int) }) { g.Peer = from.GetPeer() + if val, ok := from.GetSavedPeerID(); ok { + g.SavedPeerID = val + } + g.Filter = from.GetFilter() g.OffsetID = from.GetOffsetID() g.OffsetDate = from.GetOffsetDate() @@ -140,6 +157,11 @@ func (g *MessagesGetSearchResultsCalendarRequest) TypeInfo() tdp.Type { Name: "Peer", SchemaName: "peer", }, + { + Name: "SavedPeerID", + SchemaName: "saved_peer_id", + Null: !g.Flags.Has(2), + }, { Name: "Filter", SchemaName: "filter", @@ -156,10 +178,17 @@ func (g *MessagesGetSearchResultsCalendarRequest) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (g *MessagesGetSearchResultsCalendarRequest) SetFlags() { + if !(g.SavedPeerID == nil) { + g.Flags.Set(2) + } +} + // Encode implements bin.Encoder. func (g *MessagesGetSearchResultsCalendarRequest) Encode(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't encode messages.getSearchResultsCalendar#49f0bde9 as nil") + return fmt.Errorf("can't encode messages.getSearchResultsCalendar#6aa3f6bd as nil") } b.PutID(MessagesGetSearchResultsCalendarRequestTypeID) return g.EncodeBare(b) @@ -168,19 +197,31 @@ func (g *MessagesGetSearchResultsCalendarRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (g *MessagesGetSearchResultsCalendarRequest) EncodeBare(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't encode messages.getSearchResultsCalendar#49f0bde9 as nil") + return fmt.Errorf("can't encode messages.getSearchResultsCalendar#6aa3f6bd as nil") + } + g.SetFlags() + if err := g.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.getSearchResultsCalendar#6aa3f6bd: field flags: %w", err) } if g.Peer == nil { - return fmt.Errorf("unable to encode messages.getSearchResultsCalendar#49f0bde9: field peer is nil") + return fmt.Errorf("unable to encode messages.getSearchResultsCalendar#6aa3f6bd: field peer is nil") } if err := g.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.getSearchResultsCalendar#49f0bde9: field peer: %w", err) + return fmt.Errorf("unable to encode messages.getSearchResultsCalendar#6aa3f6bd: field peer: %w", err) + } + if g.Flags.Has(2) { + if g.SavedPeerID == nil { + return fmt.Errorf("unable to encode messages.getSearchResultsCalendar#6aa3f6bd: field saved_peer_id is nil") + } + if err := g.SavedPeerID.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.getSearchResultsCalendar#6aa3f6bd: field saved_peer_id: %w", err) + } } if g.Filter == nil { - return fmt.Errorf("unable to encode messages.getSearchResultsCalendar#49f0bde9: field filter is nil") + return fmt.Errorf("unable to encode messages.getSearchResultsCalendar#6aa3f6bd: field filter is nil") } if err := g.Filter.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.getSearchResultsCalendar#49f0bde9: field filter: %w", err) + return fmt.Errorf("unable to encode messages.getSearchResultsCalendar#6aa3f6bd: field filter: %w", err) } b.PutInt(g.OffsetID) b.PutInt(g.OffsetDate) @@ -190,10 +231,10 @@ func (g *MessagesGetSearchResultsCalendarRequest) EncodeBare(b *bin.Buffer) erro // Decode implements bin.Decoder. func (g *MessagesGetSearchResultsCalendarRequest) Decode(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't decode messages.getSearchResultsCalendar#49f0bde9 to nil") + return fmt.Errorf("can't decode messages.getSearchResultsCalendar#6aa3f6bd to nil") } if err := b.ConsumeID(MessagesGetSearchResultsCalendarRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.getSearchResultsCalendar#49f0bde9: %w", err) + return fmt.Errorf("unable to decode messages.getSearchResultsCalendar#6aa3f6bd: %w", err) } return g.DecodeBare(b) } @@ -201,33 +242,45 @@ func (g *MessagesGetSearchResultsCalendarRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (g *MessagesGetSearchResultsCalendarRequest) DecodeBare(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't decode messages.getSearchResultsCalendar#49f0bde9 to nil") + return fmt.Errorf("can't decode messages.getSearchResultsCalendar#6aa3f6bd to nil") + } + { + if err := g.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.getSearchResultsCalendar#6aa3f6bd: field flags: %w", err) + } } { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.getSearchResultsCalendar#49f0bde9: field peer: %w", err) + return fmt.Errorf("unable to decode messages.getSearchResultsCalendar#6aa3f6bd: field peer: %w", err) } g.Peer = value } + if g.Flags.Has(2) { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode messages.getSearchResultsCalendar#6aa3f6bd: field saved_peer_id: %w", err) + } + g.SavedPeerID = value + } { value, err := DecodeMessagesFilter(b) if err != nil { - return fmt.Errorf("unable to decode messages.getSearchResultsCalendar#49f0bde9: field filter: %w", err) + return fmt.Errorf("unable to decode messages.getSearchResultsCalendar#6aa3f6bd: field filter: %w", err) } g.Filter = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.getSearchResultsCalendar#49f0bde9: field offset_id: %w", err) + return fmt.Errorf("unable to decode messages.getSearchResultsCalendar#6aa3f6bd: field offset_id: %w", err) } g.OffsetID = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.getSearchResultsCalendar#49f0bde9: field offset_date: %w", err) + return fmt.Errorf("unable to decode messages.getSearchResultsCalendar#6aa3f6bd: field offset_date: %w", err) } g.OffsetDate = value } @@ -242,6 +295,24 @@ func (g *MessagesGetSearchResultsCalendarRequest) GetPeer() (value InputPeerClas return g.Peer } +// SetSavedPeerID sets value of SavedPeerID conditional field. +func (g *MessagesGetSearchResultsCalendarRequest) SetSavedPeerID(value InputPeerClass) { + g.Flags.Set(2) + g.SavedPeerID = value +} + +// GetSavedPeerID returns value of SavedPeerID conditional field and +// boolean which is true if field was set. +func (g *MessagesGetSearchResultsCalendarRequest) GetSavedPeerID() (value InputPeerClass, ok bool) { + if g == nil { + return + } + if !g.Flags.Has(2) { + return value, false + } + return g.SavedPeerID, true +} + // GetFilter returns value of Filter field. func (g *MessagesGetSearchResultsCalendarRequest) GetFilter() (value MessagesFilterClass) { if g == nil { @@ -266,7 +337,7 @@ func (g *MessagesGetSearchResultsCalendarRequest) GetOffsetDate() (value int) { return g.OffsetDate } -// MessagesGetSearchResultsCalendar invokes method messages.getSearchResultsCalendar#49f0bde9 returning error if any. +// MessagesGetSearchResultsCalendar invokes method messages.getSearchResultsCalendar#6aa3f6bd returning error if any. // Returns information about the next messages of the specified type in the chat split by // days. // Returns the results in reverse chronological order. diff --git a/tg/tl_messages_get_search_results_positions_gen.go b/tg/tl_messages_get_search_results_positions_gen.go index 7373bb38ac..00a64903ee 100644 --- a/tg/tl_messages_get_search_results_positions_gen.go +++ b/tg/tl_messages_get_search_results_positions_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesGetSearchResultsPositionsRequest represents TL type `messages.getSearchResultsPositions#6e9583a3`. +// MessagesGetSearchResultsPositionsRequest represents TL type `messages.getSearchResultsPositions#9c7f2f10`. // Returns sparse positions of messages of the specified type in the chat to be used for // shared media scroll implementation. // Returns the results in reverse chronological order (i.e., in order of decreasing @@ -39,8 +39,14 @@ var ( // // See https://core.telegram.org/method/messages.getSearchResultsPositions for reference. type MessagesGetSearchResultsPositionsRequest struct { + // Flags field of MessagesGetSearchResultsPositionsRequest. + Flags bin.Fields // Peer where to search Peer InputPeerClass + // SavedPeerID field of MessagesGetSearchResultsPositionsRequest. + // + // Use SetSavedPeerID and GetSavedPeerID helpers. + SavedPeerID InputPeerClass // Message filter, inputMessagesFilterEmpty¹, inputMessagesFilterMyMentions² filters // are not supported by this method. // @@ -61,7 +67,7 @@ type MessagesGetSearchResultsPositionsRequest struct { } // MessagesGetSearchResultsPositionsRequestTypeID is TL type id of MessagesGetSearchResultsPositionsRequest. -const MessagesGetSearchResultsPositionsRequestTypeID = 0x6e9583a3 +const MessagesGetSearchResultsPositionsRequestTypeID = 0x9c7f2f10 // Ensuring interfaces in compile-time for MessagesGetSearchResultsPositionsRequest. var ( @@ -75,9 +81,15 @@ func (g *MessagesGetSearchResultsPositionsRequest) Zero() bool { if g == nil { return true } + if !(g.Flags.Zero()) { + return false + } if !(g.Peer == nil) { return false } + if !(g.SavedPeerID == nil) { + return false + } if !(g.Filter == nil) { return false } @@ -103,11 +115,16 @@ func (g *MessagesGetSearchResultsPositionsRequest) String() string { // FillFrom fills MessagesGetSearchResultsPositionsRequest from given interface. func (g *MessagesGetSearchResultsPositionsRequest) FillFrom(from interface { GetPeer() (value InputPeerClass) + GetSavedPeerID() (value InputPeerClass, ok bool) GetFilter() (value MessagesFilterClass) GetOffsetID() (value int) GetLimit() (value int) }) { g.Peer = from.GetPeer() + if val, ok := from.GetSavedPeerID(); ok { + g.SavedPeerID = val + } + g.Filter = from.GetFilter() g.OffsetID = from.GetOffsetID() g.Limit = from.GetLimit() @@ -140,6 +157,11 @@ func (g *MessagesGetSearchResultsPositionsRequest) TypeInfo() tdp.Type { Name: "Peer", SchemaName: "peer", }, + { + Name: "SavedPeerID", + SchemaName: "saved_peer_id", + Null: !g.Flags.Has(2), + }, { Name: "Filter", SchemaName: "filter", @@ -156,10 +178,17 @@ func (g *MessagesGetSearchResultsPositionsRequest) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (g *MessagesGetSearchResultsPositionsRequest) SetFlags() { + if !(g.SavedPeerID == nil) { + g.Flags.Set(2) + } +} + // Encode implements bin.Encoder. func (g *MessagesGetSearchResultsPositionsRequest) Encode(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't encode messages.getSearchResultsPositions#6e9583a3 as nil") + return fmt.Errorf("can't encode messages.getSearchResultsPositions#9c7f2f10 as nil") } b.PutID(MessagesGetSearchResultsPositionsRequestTypeID) return g.EncodeBare(b) @@ -168,19 +197,31 @@ func (g *MessagesGetSearchResultsPositionsRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (g *MessagesGetSearchResultsPositionsRequest) EncodeBare(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't encode messages.getSearchResultsPositions#6e9583a3 as nil") + return fmt.Errorf("can't encode messages.getSearchResultsPositions#9c7f2f10 as nil") + } + g.SetFlags() + if err := g.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.getSearchResultsPositions#9c7f2f10: field flags: %w", err) } if g.Peer == nil { - return fmt.Errorf("unable to encode messages.getSearchResultsPositions#6e9583a3: field peer is nil") + return fmt.Errorf("unable to encode messages.getSearchResultsPositions#9c7f2f10: field peer is nil") } if err := g.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.getSearchResultsPositions#6e9583a3: field peer: %w", err) + return fmt.Errorf("unable to encode messages.getSearchResultsPositions#9c7f2f10: field peer: %w", err) + } + if g.Flags.Has(2) { + if g.SavedPeerID == nil { + return fmt.Errorf("unable to encode messages.getSearchResultsPositions#9c7f2f10: field saved_peer_id is nil") + } + if err := g.SavedPeerID.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.getSearchResultsPositions#9c7f2f10: field saved_peer_id: %w", err) + } } if g.Filter == nil { - return fmt.Errorf("unable to encode messages.getSearchResultsPositions#6e9583a3: field filter is nil") + return fmt.Errorf("unable to encode messages.getSearchResultsPositions#9c7f2f10: field filter is nil") } if err := g.Filter.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.getSearchResultsPositions#6e9583a3: field filter: %w", err) + return fmt.Errorf("unable to encode messages.getSearchResultsPositions#9c7f2f10: field filter: %w", err) } b.PutInt(g.OffsetID) b.PutInt(g.Limit) @@ -190,10 +231,10 @@ func (g *MessagesGetSearchResultsPositionsRequest) EncodeBare(b *bin.Buffer) err // Decode implements bin.Decoder. func (g *MessagesGetSearchResultsPositionsRequest) Decode(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't decode messages.getSearchResultsPositions#6e9583a3 to nil") + return fmt.Errorf("can't decode messages.getSearchResultsPositions#9c7f2f10 to nil") } if err := b.ConsumeID(MessagesGetSearchResultsPositionsRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.getSearchResultsPositions#6e9583a3: %w", err) + return fmt.Errorf("unable to decode messages.getSearchResultsPositions#9c7f2f10: %w", err) } return g.DecodeBare(b) } @@ -201,33 +242,45 @@ func (g *MessagesGetSearchResultsPositionsRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (g *MessagesGetSearchResultsPositionsRequest) DecodeBare(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't decode messages.getSearchResultsPositions#6e9583a3 to nil") + return fmt.Errorf("can't decode messages.getSearchResultsPositions#9c7f2f10 to nil") + } + { + if err := g.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.getSearchResultsPositions#9c7f2f10: field flags: %w", err) + } } { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.getSearchResultsPositions#6e9583a3: field peer: %w", err) + return fmt.Errorf("unable to decode messages.getSearchResultsPositions#9c7f2f10: field peer: %w", err) } g.Peer = value } + if g.Flags.Has(2) { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode messages.getSearchResultsPositions#9c7f2f10: field saved_peer_id: %w", err) + } + g.SavedPeerID = value + } { value, err := DecodeMessagesFilter(b) if err != nil { - return fmt.Errorf("unable to decode messages.getSearchResultsPositions#6e9583a3: field filter: %w", err) + return fmt.Errorf("unable to decode messages.getSearchResultsPositions#9c7f2f10: field filter: %w", err) } g.Filter = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.getSearchResultsPositions#6e9583a3: field offset_id: %w", err) + return fmt.Errorf("unable to decode messages.getSearchResultsPositions#9c7f2f10: field offset_id: %w", err) } g.OffsetID = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.getSearchResultsPositions#6e9583a3: field limit: %w", err) + return fmt.Errorf("unable to decode messages.getSearchResultsPositions#9c7f2f10: field limit: %w", err) } g.Limit = value } @@ -242,6 +295,24 @@ func (g *MessagesGetSearchResultsPositionsRequest) GetPeer() (value InputPeerCla return g.Peer } +// SetSavedPeerID sets value of SavedPeerID conditional field. +func (g *MessagesGetSearchResultsPositionsRequest) SetSavedPeerID(value InputPeerClass) { + g.Flags.Set(2) + g.SavedPeerID = value +} + +// GetSavedPeerID returns value of SavedPeerID conditional field and +// boolean which is true if field was set. +func (g *MessagesGetSearchResultsPositionsRequest) GetSavedPeerID() (value InputPeerClass, ok bool) { + if g == nil { + return + } + if !g.Flags.Has(2) { + return value, false + } + return g.SavedPeerID, true +} + // GetFilter returns value of Filter field. func (g *MessagesGetSearchResultsPositionsRequest) GetFilter() (value MessagesFilterClass) { if g == nil { @@ -266,7 +337,7 @@ func (g *MessagesGetSearchResultsPositionsRequest) GetLimit() (value int) { return g.Limit } -// MessagesGetSearchResultsPositions invokes method messages.getSearchResultsPositions#6e9583a3 returning error if any. +// MessagesGetSearchResultsPositions invokes method messages.getSearchResultsPositions#9c7f2f10 returning error if any. // Returns sparse positions of messages of the specified type in the chat to be used for // shared media scroll implementation. // Returns the results in reverse chronological order (i.e., in order of decreasing diff --git a/tg/tl_messages_reorder_pinned_saved_dialogs_gen.go b/tg/tl_messages_reorder_pinned_saved_dialogs_gen.go new file mode 100644 index 0000000000..1e6d8eb7a8 --- /dev/null +++ b/tg/tl_messages_reorder_pinned_saved_dialogs_gen.go @@ -0,0 +1,250 @@ +// 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{} +) + +// MessagesReorderPinnedSavedDialogsRequest represents TL type `messages.reorderPinnedSavedDialogs#8b716587`. +// +// See https://core.telegram.org/method/messages.reorderPinnedSavedDialogs for reference. +type MessagesReorderPinnedSavedDialogsRequest struct { + // Flags field of MessagesReorderPinnedSavedDialogsRequest. + Flags bin.Fields + // Force field of MessagesReorderPinnedSavedDialogsRequest. + Force bool + // Order field of MessagesReorderPinnedSavedDialogsRequest. + Order []InputDialogPeerClass +} + +// MessagesReorderPinnedSavedDialogsRequestTypeID is TL type id of MessagesReorderPinnedSavedDialogsRequest. +const MessagesReorderPinnedSavedDialogsRequestTypeID = 0x8b716587 + +// Ensuring interfaces in compile-time for MessagesReorderPinnedSavedDialogsRequest. +var ( + _ bin.Encoder = &MessagesReorderPinnedSavedDialogsRequest{} + _ bin.Decoder = &MessagesReorderPinnedSavedDialogsRequest{} + _ bin.BareEncoder = &MessagesReorderPinnedSavedDialogsRequest{} + _ bin.BareDecoder = &MessagesReorderPinnedSavedDialogsRequest{} +) + +func (r *MessagesReorderPinnedSavedDialogsRequest) Zero() bool { + if r == nil { + return true + } + if !(r.Flags.Zero()) { + return false + } + if !(r.Force == false) { + return false + } + if !(r.Order == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (r *MessagesReorderPinnedSavedDialogsRequest) String() string { + if r == nil { + return "MessagesReorderPinnedSavedDialogsRequest(nil)" + } + type Alias MessagesReorderPinnedSavedDialogsRequest + return fmt.Sprintf("MessagesReorderPinnedSavedDialogsRequest%+v", Alias(*r)) +} + +// FillFrom fills MessagesReorderPinnedSavedDialogsRequest from given interface. +func (r *MessagesReorderPinnedSavedDialogsRequest) FillFrom(from interface { + GetForce() (value bool) + GetOrder() (value []InputDialogPeerClass) +}) { + r.Force = from.GetForce() + r.Order = from.GetOrder() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesReorderPinnedSavedDialogsRequest) TypeID() uint32 { + return MessagesReorderPinnedSavedDialogsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesReorderPinnedSavedDialogsRequest) TypeName() string { + return "messages.reorderPinnedSavedDialogs" +} + +// TypeInfo returns info about TL type. +func (r *MessagesReorderPinnedSavedDialogsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.reorderPinnedSavedDialogs", + ID: MessagesReorderPinnedSavedDialogsRequestTypeID, + } + if r == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Force", + SchemaName: "force", + Null: !r.Flags.Has(0), + }, + { + Name: "Order", + SchemaName: "order", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (r *MessagesReorderPinnedSavedDialogsRequest) SetFlags() { + if !(r.Force == false) { + r.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (r *MessagesReorderPinnedSavedDialogsRequest) Encode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode messages.reorderPinnedSavedDialogs#8b716587 as nil") + } + b.PutID(MessagesReorderPinnedSavedDialogsRequestTypeID) + return r.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (r *MessagesReorderPinnedSavedDialogsRequest) EncodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode messages.reorderPinnedSavedDialogs#8b716587 as nil") + } + r.SetFlags() + if err := r.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.reorderPinnedSavedDialogs#8b716587: field flags: %w", err) + } + b.PutVectorHeader(len(r.Order)) + for idx, v := range r.Order { + if v == nil { + return fmt.Errorf("unable to encode messages.reorderPinnedSavedDialogs#8b716587: field order element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.reorderPinnedSavedDialogs#8b716587: field order element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (r *MessagesReorderPinnedSavedDialogsRequest) Decode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode messages.reorderPinnedSavedDialogs#8b716587 to nil") + } + if err := b.ConsumeID(MessagesReorderPinnedSavedDialogsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.reorderPinnedSavedDialogs#8b716587: %w", err) + } + return r.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (r *MessagesReorderPinnedSavedDialogsRequest) DecodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode messages.reorderPinnedSavedDialogs#8b716587 to nil") + } + { + if err := r.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.reorderPinnedSavedDialogs#8b716587: field flags: %w", err) + } + } + r.Force = r.Flags.Has(0) + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode messages.reorderPinnedSavedDialogs#8b716587: field order: %w", err) + } + + if headerLen > 0 { + r.Order = make([]InputDialogPeerClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeInputDialogPeer(b) + if err != nil { + return fmt.Errorf("unable to decode messages.reorderPinnedSavedDialogs#8b716587: field order: %w", err) + } + r.Order = append(r.Order, value) + } + } + return nil +} + +// SetForce sets value of Force conditional field. +func (r *MessagesReorderPinnedSavedDialogsRequest) SetForce(value bool) { + if value { + r.Flags.Set(0) + r.Force = true + } else { + r.Flags.Unset(0) + r.Force = false + } +} + +// GetForce returns value of Force conditional field. +func (r *MessagesReorderPinnedSavedDialogsRequest) GetForce() (value bool) { + if r == nil { + return + } + return r.Flags.Has(0) +} + +// GetOrder returns value of Order field. +func (r *MessagesReorderPinnedSavedDialogsRequest) GetOrder() (value []InputDialogPeerClass) { + if r == nil { + return + } + return r.Order +} + +// MapOrder returns field Order wrapped in InputDialogPeerClassArray helper. +func (r *MessagesReorderPinnedSavedDialogsRequest) MapOrder() (value InputDialogPeerClassArray) { + return InputDialogPeerClassArray(r.Order) +} + +// MessagesReorderPinnedSavedDialogs invokes method messages.reorderPinnedSavedDialogs#8b716587 returning error if any. +// +// See https://core.telegram.org/method/messages.reorderPinnedSavedDialogs for reference. +func (c *Client) MessagesReorderPinnedSavedDialogs(ctx context.Context, request *MessagesReorderPinnedSavedDialogsRequest) (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_messages_reorder_pinned_saved_dialogs_slices_gen.go b/tg/tl_messages_reorder_pinned_saved_dialogs_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_reorder_pinned_saved_dialogs_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_saved_dialogs_gen.go b/tg/tl_messages_saved_dialogs_gen.go new file mode 100644 index 0000000000..f1d43ba155 --- /dev/null +++ b/tg/tl_messages_saved_dialogs_gen.go @@ -0,0 +1,941 @@ +// 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{} +) + +// MessagesSavedDialogs represents TL type `messages.savedDialogs#f83ae221`. +// +// See https://core.telegram.org/constructor/messages.savedDialogs for reference. +type MessagesSavedDialogs struct { + // Dialogs field of MessagesSavedDialogs. + Dialogs []SavedDialog + // Messages field of MessagesSavedDialogs. + Messages []MessageClass + // Chats field of MessagesSavedDialogs. + Chats []ChatClass + // Users field of MessagesSavedDialogs. + Users []UserClass +} + +// MessagesSavedDialogsTypeID is TL type id of MessagesSavedDialogs. +const MessagesSavedDialogsTypeID = 0xf83ae221 + +// construct implements constructor of MessagesSavedDialogsClass. +func (s MessagesSavedDialogs) construct() MessagesSavedDialogsClass { return &s } + +// Ensuring interfaces in compile-time for MessagesSavedDialogs. +var ( + _ bin.Encoder = &MessagesSavedDialogs{} + _ bin.Decoder = &MessagesSavedDialogs{} + _ bin.BareEncoder = &MessagesSavedDialogs{} + _ bin.BareDecoder = &MessagesSavedDialogs{} + + _ MessagesSavedDialogsClass = &MessagesSavedDialogs{} +) + +func (s *MessagesSavedDialogs) Zero() bool { + if s == nil { + return true + } + if !(s.Dialogs == nil) { + return false + } + if !(s.Messages == nil) { + return false + } + if !(s.Chats == nil) { + return false + } + if !(s.Users == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *MessagesSavedDialogs) String() string { + if s == nil { + return "MessagesSavedDialogs(nil)" + } + type Alias MessagesSavedDialogs + return fmt.Sprintf("MessagesSavedDialogs%+v", Alias(*s)) +} + +// FillFrom fills MessagesSavedDialogs from given interface. +func (s *MessagesSavedDialogs) FillFrom(from interface { + GetDialogs() (value []SavedDialog) + GetMessages() (value []MessageClass) + GetChats() (value []ChatClass) + GetUsers() (value []UserClass) +}) { + s.Dialogs = from.GetDialogs() + s.Messages = from.GetMessages() + s.Chats = from.GetChats() + s.Users = from.GetUsers() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesSavedDialogs) TypeID() uint32 { + return MessagesSavedDialogsTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesSavedDialogs) TypeName() string { + return "messages.savedDialogs" +} + +// TypeInfo returns info about TL type. +func (s *MessagesSavedDialogs) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.savedDialogs", + ID: MessagesSavedDialogsTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Dialogs", + SchemaName: "dialogs", + }, + { + Name: "Messages", + SchemaName: "messages", + }, + { + Name: "Chats", + SchemaName: "chats", + }, + { + Name: "Users", + SchemaName: "users", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *MessagesSavedDialogs) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode messages.savedDialogs#f83ae221 as nil") + } + b.PutID(MessagesSavedDialogsTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *MessagesSavedDialogs) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode messages.savedDialogs#f83ae221 as nil") + } + b.PutVectorHeader(len(s.Dialogs)) + for idx, v := range s.Dialogs { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.savedDialogs#f83ae221: field dialogs element with index %d: %w", idx, err) + } + } + b.PutVectorHeader(len(s.Messages)) + for idx, v := range s.Messages { + if v == nil { + return fmt.Errorf("unable to encode messages.savedDialogs#f83ae221: field messages element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.savedDialogs#f83ae221: 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.savedDialogs#f83ae221: field chats element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.savedDialogs#f83ae221: 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.savedDialogs#f83ae221: field users element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.savedDialogs#f83ae221: field users element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (s *MessagesSavedDialogs) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode messages.savedDialogs#f83ae221 to nil") + } + if err := b.ConsumeID(MessagesSavedDialogsTypeID); err != nil { + return fmt.Errorf("unable to decode messages.savedDialogs#f83ae221: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *MessagesSavedDialogs) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode messages.savedDialogs#f83ae221 to nil") + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode messages.savedDialogs#f83ae221: field dialogs: %w", err) + } + + if headerLen > 0 { + s.Dialogs = make([]SavedDialog, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value SavedDialog + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.savedDialogs#f83ae221: field dialogs: %w", err) + } + s.Dialogs = append(s.Dialogs, value) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode messages.savedDialogs#f83ae221: field messages: %w", err) + } + + if headerLen > 0 { + s.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.savedDialogs#f83ae221: field messages: %w", err) + } + s.Messages = append(s.Messages, value) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode messages.savedDialogs#f83ae221: field chats: %w", err) + } + + if headerLen > 0 { + s.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.savedDialogs#f83ae221: field chats: %w", err) + } + s.Chats = append(s.Chats, value) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode messages.savedDialogs#f83ae221: field users: %w", err) + } + + if headerLen > 0 { + s.Users = make([]UserClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeUser(b) + if err != nil { + return fmt.Errorf("unable to decode messages.savedDialogs#f83ae221: field users: %w", err) + } + s.Users = append(s.Users, value) + } + } + return nil +} + +// GetDialogs returns value of Dialogs field. +func (s *MessagesSavedDialogs) GetDialogs() (value []SavedDialog) { + if s == nil { + return + } + return s.Dialogs +} + +// GetMessages returns value of Messages field. +func (s *MessagesSavedDialogs) GetMessages() (value []MessageClass) { + if s == nil { + return + } + return s.Messages +} + +// GetChats returns value of Chats field. +func (s *MessagesSavedDialogs) GetChats() (value []ChatClass) { + if s == nil { + return + } + return s.Chats +} + +// GetUsers returns value of Users field. +func (s *MessagesSavedDialogs) GetUsers() (value []UserClass) { + if s == nil { + return + } + return s.Users +} + +// MapMessages returns field Messages wrapped in MessageClassArray helper. +func (s *MessagesSavedDialogs) MapMessages() (value MessageClassArray) { + return MessageClassArray(s.Messages) +} + +// MapChats returns field Chats wrapped in ChatClassArray helper. +func (s *MessagesSavedDialogs) MapChats() (value ChatClassArray) { + return ChatClassArray(s.Chats) +} + +// MapUsers returns field Users wrapped in UserClassArray helper. +func (s *MessagesSavedDialogs) MapUsers() (value UserClassArray) { + return UserClassArray(s.Users) +} + +// MessagesSavedDialogsSlice represents TL type `messages.savedDialogsSlice#44ba9dd9`. +// +// See https://core.telegram.org/constructor/messages.savedDialogsSlice for reference. +type MessagesSavedDialogsSlice struct { + // Count field of MessagesSavedDialogsSlice. + Count int + // Dialogs field of MessagesSavedDialogsSlice. + Dialogs []SavedDialog + // Messages field of MessagesSavedDialogsSlice. + Messages []MessageClass + // Chats field of MessagesSavedDialogsSlice. + Chats []ChatClass + // Users field of MessagesSavedDialogsSlice. + Users []UserClass +} + +// MessagesSavedDialogsSliceTypeID is TL type id of MessagesSavedDialogsSlice. +const MessagesSavedDialogsSliceTypeID = 0x44ba9dd9 + +// construct implements constructor of MessagesSavedDialogsClass. +func (s MessagesSavedDialogsSlice) construct() MessagesSavedDialogsClass { return &s } + +// Ensuring interfaces in compile-time for MessagesSavedDialogsSlice. +var ( + _ bin.Encoder = &MessagesSavedDialogsSlice{} + _ bin.Decoder = &MessagesSavedDialogsSlice{} + _ bin.BareEncoder = &MessagesSavedDialogsSlice{} + _ bin.BareDecoder = &MessagesSavedDialogsSlice{} + + _ MessagesSavedDialogsClass = &MessagesSavedDialogsSlice{} +) + +func (s *MessagesSavedDialogsSlice) Zero() bool { + if s == nil { + return true + } + if !(s.Count == 0) { + return false + } + if !(s.Dialogs == nil) { + return false + } + if !(s.Messages == nil) { + return false + } + if !(s.Chats == nil) { + return false + } + if !(s.Users == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *MessagesSavedDialogsSlice) String() string { + if s == nil { + return "MessagesSavedDialogsSlice(nil)" + } + type Alias MessagesSavedDialogsSlice + return fmt.Sprintf("MessagesSavedDialogsSlice%+v", Alias(*s)) +} + +// FillFrom fills MessagesSavedDialogsSlice from given interface. +func (s *MessagesSavedDialogsSlice) FillFrom(from interface { + GetCount() (value int) + GetDialogs() (value []SavedDialog) + GetMessages() (value []MessageClass) + GetChats() (value []ChatClass) + GetUsers() (value []UserClass) +}) { + s.Count = from.GetCount() + s.Dialogs = from.GetDialogs() + s.Messages = from.GetMessages() + s.Chats = from.GetChats() + s.Users = from.GetUsers() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesSavedDialogsSlice) TypeID() uint32 { + return MessagesSavedDialogsSliceTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesSavedDialogsSlice) TypeName() string { + return "messages.savedDialogsSlice" +} + +// TypeInfo returns info about TL type. +func (s *MessagesSavedDialogsSlice) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.savedDialogsSlice", + ID: MessagesSavedDialogsSliceTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Count", + SchemaName: "count", + }, + { + Name: "Dialogs", + SchemaName: "dialogs", + }, + { + Name: "Messages", + SchemaName: "messages", + }, + { + Name: "Chats", + SchemaName: "chats", + }, + { + Name: "Users", + SchemaName: "users", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *MessagesSavedDialogsSlice) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode messages.savedDialogsSlice#44ba9dd9 as nil") + } + b.PutID(MessagesSavedDialogsSliceTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *MessagesSavedDialogsSlice) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode messages.savedDialogsSlice#44ba9dd9 as nil") + } + b.PutInt(s.Count) + b.PutVectorHeader(len(s.Dialogs)) + for idx, v := range s.Dialogs { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.savedDialogsSlice#44ba9dd9: field dialogs element with index %d: %w", idx, err) + } + } + b.PutVectorHeader(len(s.Messages)) + for idx, v := range s.Messages { + if v == nil { + return fmt.Errorf("unable to encode messages.savedDialogsSlice#44ba9dd9: field messages element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.savedDialogsSlice#44ba9dd9: 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.savedDialogsSlice#44ba9dd9: field chats element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.savedDialogsSlice#44ba9dd9: 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.savedDialogsSlice#44ba9dd9: field users element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.savedDialogsSlice#44ba9dd9: field users element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (s *MessagesSavedDialogsSlice) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode messages.savedDialogsSlice#44ba9dd9 to nil") + } + if err := b.ConsumeID(MessagesSavedDialogsSliceTypeID); err != nil { + return fmt.Errorf("unable to decode messages.savedDialogsSlice#44ba9dd9: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *MessagesSavedDialogsSlice) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode messages.savedDialogsSlice#44ba9dd9 to nil") + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.savedDialogsSlice#44ba9dd9: field count: %w", err) + } + s.Count = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode messages.savedDialogsSlice#44ba9dd9: field dialogs: %w", err) + } + + if headerLen > 0 { + s.Dialogs = make([]SavedDialog, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value SavedDialog + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.savedDialogsSlice#44ba9dd9: field dialogs: %w", err) + } + s.Dialogs = append(s.Dialogs, value) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode messages.savedDialogsSlice#44ba9dd9: field messages: %w", err) + } + + if headerLen > 0 { + s.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.savedDialogsSlice#44ba9dd9: field messages: %w", err) + } + s.Messages = append(s.Messages, value) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode messages.savedDialogsSlice#44ba9dd9: field chats: %w", err) + } + + if headerLen > 0 { + s.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.savedDialogsSlice#44ba9dd9: field chats: %w", err) + } + s.Chats = append(s.Chats, value) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode messages.savedDialogsSlice#44ba9dd9: field users: %w", err) + } + + if headerLen > 0 { + s.Users = make([]UserClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeUser(b) + if err != nil { + return fmt.Errorf("unable to decode messages.savedDialogsSlice#44ba9dd9: field users: %w", err) + } + s.Users = append(s.Users, value) + } + } + return nil +} + +// GetCount returns value of Count field. +func (s *MessagesSavedDialogsSlice) GetCount() (value int) { + if s == nil { + return + } + return s.Count +} + +// GetDialogs returns value of Dialogs field. +func (s *MessagesSavedDialogsSlice) GetDialogs() (value []SavedDialog) { + if s == nil { + return + } + return s.Dialogs +} + +// GetMessages returns value of Messages field. +func (s *MessagesSavedDialogsSlice) GetMessages() (value []MessageClass) { + if s == nil { + return + } + return s.Messages +} + +// GetChats returns value of Chats field. +func (s *MessagesSavedDialogsSlice) GetChats() (value []ChatClass) { + if s == nil { + return + } + return s.Chats +} + +// GetUsers returns value of Users field. +func (s *MessagesSavedDialogsSlice) GetUsers() (value []UserClass) { + if s == nil { + return + } + return s.Users +} + +// MapMessages returns field Messages wrapped in MessageClassArray helper. +func (s *MessagesSavedDialogsSlice) MapMessages() (value MessageClassArray) { + return MessageClassArray(s.Messages) +} + +// MapChats returns field Chats wrapped in ChatClassArray helper. +func (s *MessagesSavedDialogsSlice) MapChats() (value ChatClassArray) { + return ChatClassArray(s.Chats) +} + +// MapUsers returns field Users wrapped in UserClassArray helper. +func (s *MessagesSavedDialogsSlice) MapUsers() (value UserClassArray) { + return UserClassArray(s.Users) +} + +// MessagesSavedDialogsNotModified represents TL type `messages.savedDialogsNotModified#c01f6fe8`. +// +// See https://core.telegram.org/constructor/messages.savedDialogsNotModified for reference. +type MessagesSavedDialogsNotModified struct { + // Count field of MessagesSavedDialogsNotModified. + Count int +} + +// MessagesSavedDialogsNotModifiedTypeID is TL type id of MessagesSavedDialogsNotModified. +const MessagesSavedDialogsNotModifiedTypeID = 0xc01f6fe8 + +// construct implements constructor of MessagesSavedDialogsClass. +func (s MessagesSavedDialogsNotModified) construct() MessagesSavedDialogsClass { return &s } + +// Ensuring interfaces in compile-time for MessagesSavedDialogsNotModified. +var ( + _ bin.Encoder = &MessagesSavedDialogsNotModified{} + _ bin.Decoder = &MessagesSavedDialogsNotModified{} + _ bin.BareEncoder = &MessagesSavedDialogsNotModified{} + _ bin.BareDecoder = &MessagesSavedDialogsNotModified{} + + _ MessagesSavedDialogsClass = &MessagesSavedDialogsNotModified{} +) + +func (s *MessagesSavedDialogsNotModified) Zero() bool { + if s == nil { + return true + } + if !(s.Count == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *MessagesSavedDialogsNotModified) String() string { + if s == nil { + return "MessagesSavedDialogsNotModified(nil)" + } + type Alias MessagesSavedDialogsNotModified + return fmt.Sprintf("MessagesSavedDialogsNotModified%+v", Alias(*s)) +} + +// FillFrom fills MessagesSavedDialogsNotModified from given interface. +func (s *MessagesSavedDialogsNotModified) FillFrom(from interface { + GetCount() (value int) +}) { + s.Count = from.GetCount() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesSavedDialogsNotModified) TypeID() uint32 { + return MessagesSavedDialogsNotModifiedTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesSavedDialogsNotModified) TypeName() string { + return "messages.savedDialogsNotModified" +} + +// TypeInfo returns info about TL type. +func (s *MessagesSavedDialogsNotModified) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.savedDialogsNotModified", + ID: MessagesSavedDialogsNotModifiedTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Count", + SchemaName: "count", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *MessagesSavedDialogsNotModified) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode messages.savedDialogsNotModified#c01f6fe8 as nil") + } + b.PutID(MessagesSavedDialogsNotModifiedTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *MessagesSavedDialogsNotModified) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode messages.savedDialogsNotModified#c01f6fe8 as nil") + } + b.PutInt(s.Count) + return nil +} + +// Decode implements bin.Decoder. +func (s *MessagesSavedDialogsNotModified) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode messages.savedDialogsNotModified#c01f6fe8 to nil") + } + if err := b.ConsumeID(MessagesSavedDialogsNotModifiedTypeID); err != nil { + return fmt.Errorf("unable to decode messages.savedDialogsNotModified#c01f6fe8: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *MessagesSavedDialogsNotModified) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode messages.savedDialogsNotModified#c01f6fe8 to nil") + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.savedDialogsNotModified#c01f6fe8: field count: %w", err) + } + s.Count = value + } + return nil +} + +// GetCount returns value of Count field. +func (s *MessagesSavedDialogsNotModified) GetCount() (value int) { + if s == nil { + return + } + return s.Count +} + +// MessagesSavedDialogsClassName is schema name of MessagesSavedDialogsClass. +const MessagesSavedDialogsClassName = "messages.SavedDialogs" + +// MessagesSavedDialogsClass represents messages.SavedDialogs generic type. +// +// See https://core.telegram.org/type/messages.SavedDialogs for reference. +// +// Example: +// +// g, err := tg.DecodeMessagesSavedDialogs(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.MessagesSavedDialogs: // messages.savedDialogs#f83ae221 +// case *tg.MessagesSavedDialogsSlice: // messages.savedDialogsSlice#44ba9dd9 +// case *tg.MessagesSavedDialogsNotModified: // messages.savedDialogsNotModified#c01f6fe8 +// default: panic(v) +// } +type MessagesSavedDialogsClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() MessagesSavedDialogsClass + + // TypeID returns type id in TL schema. + // + // See https://core.telegram.org/mtproto/TL-tl#remarks. + TypeID() uint32 + // TypeName returns name of type in TL schema. + TypeName() string + // String implements fmt.Stringer. + String() string + // Zero returns true if current object has a zero value. + Zero() bool + + // AsModified tries to map MessagesSavedDialogsClass to ModifiedMessagesSavedDialogs. + AsModified() (ModifiedMessagesSavedDialogs, bool) +} + +// ModifiedMessagesSavedDialogs represents Modified subset of MessagesSavedDialogsClass. +type ModifiedMessagesSavedDialogs interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() MessagesSavedDialogsClass + + // 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 + + // Dialogs field of MessagesSavedDialogs. + GetDialogs() (value []SavedDialog) + + // Messages field of MessagesSavedDialogs. + GetMessages() (value []MessageClass) + + // Chats field of MessagesSavedDialogs. + GetChats() (value []ChatClass) + + // Users field of MessagesSavedDialogs. + GetUsers() (value []UserClass) +} + +// AsModified tries to map MessagesSavedDialogs to ModifiedMessagesSavedDialogs. +func (s *MessagesSavedDialogs) AsModified() (ModifiedMessagesSavedDialogs, bool) { + value, ok := (MessagesSavedDialogsClass(s)).(ModifiedMessagesSavedDialogs) + return value, ok +} + +// AsModified tries to map MessagesSavedDialogsSlice to ModifiedMessagesSavedDialogs. +func (s *MessagesSavedDialogsSlice) AsModified() (ModifiedMessagesSavedDialogs, bool) { + value, ok := (MessagesSavedDialogsClass(s)).(ModifiedMessagesSavedDialogs) + return value, ok +} + +// AsModified tries to map MessagesSavedDialogsNotModified to ModifiedMessagesSavedDialogs. +func (s *MessagesSavedDialogsNotModified) AsModified() (ModifiedMessagesSavedDialogs, bool) { + value, ok := (MessagesSavedDialogsClass(s)).(ModifiedMessagesSavedDialogs) + return value, ok +} + +// DecodeMessagesSavedDialogs implements binary de-serialization for MessagesSavedDialogsClass. +func DecodeMessagesSavedDialogs(buf *bin.Buffer) (MessagesSavedDialogsClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case MessagesSavedDialogsTypeID: + // Decoding messages.savedDialogs#f83ae221. + v := MessagesSavedDialogs{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessagesSavedDialogsClass: %w", err) + } + return &v, nil + case MessagesSavedDialogsSliceTypeID: + // Decoding messages.savedDialogsSlice#44ba9dd9. + v := MessagesSavedDialogsSlice{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessagesSavedDialogsClass: %w", err) + } + return &v, nil + case MessagesSavedDialogsNotModifiedTypeID: + // Decoding messages.savedDialogsNotModified#c01f6fe8. + v := MessagesSavedDialogsNotModified{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessagesSavedDialogsClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode MessagesSavedDialogsClass: %w", bin.NewUnexpectedID(id)) + } +} + +// MessagesSavedDialogs boxes the MessagesSavedDialogsClass providing a helper. +type MessagesSavedDialogsBox struct { + SavedDialogs MessagesSavedDialogsClass +} + +// Decode implements bin.Decoder for MessagesSavedDialogsBox. +func (b *MessagesSavedDialogsBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode MessagesSavedDialogsBox to nil") + } + v, err := DecodeMessagesSavedDialogs(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.SavedDialogs = v + return nil +} + +// Encode implements bin.Encode for MessagesSavedDialogsBox. +func (b *MessagesSavedDialogsBox) Encode(buf *bin.Buffer) error { + if b == nil || b.SavedDialogs == nil { + return fmt.Errorf("unable to encode MessagesSavedDialogsClass as nil") + } + return b.SavedDialogs.Encode(buf) +} diff --git a/tg/tl_messages_saved_dialogs_slices_gen.go b/tg/tl_messages_saved_dialogs_slices_gen.go new file mode 100644 index 0000000000..df2b72e7c5 --- /dev/null +++ b/tg/tl_messages_saved_dialogs_slices_gen.go @@ -0,0 +1,457 @@ +//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{} +) + +// MessagesSavedDialogsClassArray is adapter for slice of MessagesSavedDialogsClass. +type MessagesSavedDialogsClassArray []MessagesSavedDialogsClass + +// Sort sorts slice of MessagesSavedDialogsClass. +func (s MessagesSavedDialogsClassArray) Sort(less func(a, b MessagesSavedDialogsClass) bool) MessagesSavedDialogsClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessagesSavedDialogsClass. +func (s MessagesSavedDialogsClassArray) SortStable(less func(a, b MessagesSavedDialogsClass) bool) MessagesSavedDialogsClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessagesSavedDialogsClass. +func (s MessagesSavedDialogsClassArray) Retain(keep func(x MessagesSavedDialogsClass) bool) MessagesSavedDialogsClassArray { + 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 MessagesSavedDialogsClassArray) First() (v MessagesSavedDialogsClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessagesSavedDialogsClassArray) Last() (v MessagesSavedDialogsClass, 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 *MessagesSavedDialogsClassArray) PopFirst() (v MessagesSavedDialogsClass, 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 MessagesSavedDialogsClass + 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 *MessagesSavedDialogsClassArray) Pop() (v MessagesSavedDialogsClass, 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 +} + +// AsMessagesSavedDialogs returns copy with only MessagesSavedDialogs constructors. +func (s MessagesSavedDialogsClassArray) AsMessagesSavedDialogs() (to MessagesSavedDialogsArray) { + for _, elem := range s { + value, ok := elem.(*MessagesSavedDialogs) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsMessagesSavedDialogsSlice returns copy with only MessagesSavedDialogsSlice constructors. +func (s MessagesSavedDialogsClassArray) AsMessagesSavedDialogsSlice() (to MessagesSavedDialogsSliceArray) { + for _, elem := range s { + value, ok := elem.(*MessagesSavedDialogsSlice) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsMessagesSavedDialogsNotModified returns copy with only MessagesSavedDialogsNotModified constructors. +func (s MessagesSavedDialogsClassArray) AsMessagesSavedDialogsNotModified() (to MessagesSavedDialogsNotModifiedArray) { + for _, elem := range s { + value, ok := elem.(*MessagesSavedDialogsNotModified) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AppendOnlyModified appends only Modified constructors to +// given slice. +func (s MessagesSavedDialogsClassArray) AppendOnlyModified(to []ModifiedMessagesSavedDialogs) []ModifiedMessagesSavedDialogs { + for _, elem := range s { + value, ok := elem.AsModified() + if !ok { + continue + } + to = append(to, value) + } + + return to +} + +// AsModified returns copy with only Modified constructors. +func (s MessagesSavedDialogsClassArray) AsModified() (to []ModifiedMessagesSavedDialogs) { + return s.AppendOnlyModified(to) +} + +// FirstAsModified returns first element of slice (if exists). +func (s MessagesSavedDialogsClassArray) FirstAsModified() (v ModifiedMessagesSavedDialogs, ok bool) { + value, ok := s.First() + if !ok { + return + } + return value.AsModified() +} + +// LastAsModified returns last element of slice (if exists). +func (s MessagesSavedDialogsClassArray) LastAsModified() (v ModifiedMessagesSavedDialogs, ok bool) { + value, ok := s.Last() + if !ok { + return + } + return value.AsModified() +} + +// PopFirstAsModified returns element of slice (if exists). +func (s *MessagesSavedDialogsClassArray) PopFirstAsModified() (v ModifiedMessagesSavedDialogs, ok bool) { + value, ok := s.PopFirst() + if !ok { + return + } + return value.AsModified() +} + +// PopAsModified returns element of slice (if exists). +func (s *MessagesSavedDialogsClassArray) PopAsModified() (v ModifiedMessagesSavedDialogs, ok bool) { + value, ok := s.Pop() + if !ok { + return + } + return value.AsModified() +} + +// MessagesSavedDialogsArray is adapter for slice of MessagesSavedDialogs. +type MessagesSavedDialogsArray []MessagesSavedDialogs + +// Sort sorts slice of MessagesSavedDialogs. +func (s MessagesSavedDialogsArray) Sort(less func(a, b MessagesSavedDialogs) bool) MessagesSavedDialogsArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessagesSavedDialogs. +func (s MessagesSavedDialogsArray) SortStable(less func(a, b MessagesSavedDialogs) bool) MessagesSavedDialogsArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessagesSavedDialogs. +func (s MessagesSavedDialogsArray) Retain(keep func(x MessagesSavedDialogs) bool) MessagesSavedDialogsArray { + 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 MessagesSavedDialogsArray) First() (v MessagesSavedDialogs, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessagesSavedDialogsArray) Last() (v MessagesSavedDialogs, 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 *MessagesSavedDialogsArray) PopFirst() (v MessagesSavedDialogs, 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 MessagesSavedDialogs + 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 *MessagesSavedDialogsArray) Pop() (v MessagesSavedDialogs, 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 +} + +// MessagesSavedDialogsSliceArray is adapter for slice of MessagesSavedDialogsSlice. +type MessagesSavedDialogsSliceArray []MessagesSavedDialogsSlice + +// Sort sorts slice of MessagesSavedDialogsSlice. +func (s MessagesSavedDialogsSliceArray) Sort(less func(a, b MessagesSavedDialogsSlice) bool) MessagesSavedDialogsSliceArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessagesSavedDialogsSlice. +func (s MessagesSavedDialogsSliceArray) SortStable(less func(a, b MessagesSavedDialogsSlice) bool) MessagesSavedDialogsSliceArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessagesSavedDialogsSlice. +func (s MessagesSavedDialogsSliceArray) Retain(keep func(x MessagesSavedDialogsSlice) bool) MessagesSavedDialogsSliceArray { + 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 MessagesSavedDialogsSliceArray) First() (v MessagesSavedDialogsSlice, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessagesSavedDialogsSliceArray) Last() (v MessagesSavedDialogsSlice, 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 *MessagesSavedDialogsSliceArray) PopFirst() (v MessagesSavedDialogsSlice, 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 MessagesSavedDialogsSlice + 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 *MessagesSavedDialogsSliceArray) Pop() (v MessagesSavedDialogsSlice, 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 +} + +// MessagesSavedDialogsNotModifiedArray is adapter for slice of MessagesSavedDialogsNotModified. +type MessagesSavedDialogsNotModifiedArray []MessagesSavedDialogsNotModified + +// Sort sorts slice of MessagesSavedDialogsNotModified. +func (s MessagesSavedDialogsNotModifiedArray) Sort(less func(a, b MessagesSavedDialogsNotModified) bool) MessagesSavedDialogsNotModifiedArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessagesSavedDialogsNotModified. +func (s MessagesSavedDialogsNotModifiedArray) SortStable(less func(a, b MessagesSavedDialogsNotModified) bool) MessagesSavedDialogsNotModifiedArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessagesSavedDialogsNotModified. +func (s MessagesSavedDialogsNotModifiedArray) Retain(keep func(x MessagesSavedDialogsNotModified) bool) MessagesSavedDialogsNotModifiedArray { + 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 MessagesSavedDialogsNotModifiedArray) First() (v MessagesSavedDialogsNotModified, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessagesSavedDialogsNotModifiedArray) Last() (v MessagesSavedDialogsNotModified, 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 *MessagesSavedDialogsNotModifiedArray) PopFirst() (v MessagesSavedDialogsNotModified, 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 MessagesSavedDialogsNotModified + 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 *MessagesSavedDialogsNotModifiedArray) Pop() (v MessagesSavedDialogsNotModified, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_messages_search_gen.go b/tg/tl_messages_search_gen.go index d8fb9b0c40..eeb4abca56 100644 --- a/tg/tl_messages_search_gen.go +++ b/tg/tl_messages_search_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesSearchRequest represents TL type `messages.search#a0fda762`. +// MessagesSearchRequest represents TL type `messages.search#a7b4e929`. // Search for messages. // // See https://core.telegram.org/method/messages.search for reference. @@ -56,6 +56,10 @@ type MessagesSearchRequest struct { // // Use SetFromID and GetFromID helpers. FromID InputPeerClass + // SavedPeerID field of MessagesSearchRequest. + // + // Use SetSavedPeerID and GetSavedPeerID helpers. + SavedPeerID InputPeerClass // Thread ID¹ // // Links: @@ -101,7 +105,7 @@ type MessagesSearchRequest struct { } // MessagesSearchRequestTypeID is TL type id of MessagesSearchRequest. -const MessagesSearchRequestTypeID = 0xa0fda762 +const MessagesSearchRequestTypeID = 0xa7b4e929 // Ensuring interfaces in compile-time for MessagesSearchRequest. var ( @@ -127,6 +131,9 @@ func (s *MessagesSearchRequest) Zero() bool { if !(s.FromID == nil) { return false } + if !(s.SavedPeerID == nil) { + return false + } if !(s.TopMsgID == 0) { return false } @@ -175,6 +182,7 @@ func (s *MessagesSearchRequest) FillFrom(from interface { GetPeer() (value InputPeerClass) GetQ() (value string) GetFromID() (value InputPeerClass, ok bool) + GetSavedPeerID() (value InputPeerClass, ok bool) GetTopMsgID() (value int, ok bool) GetFilter() (value MessagesFilterClass) GetMinDate() (value int) @@ -192,6 +200,10 @@ func (s *MessagesSearchRequest) FillFrom(from interface { s.FromID = val } + if val, ok := from.GetSavedPeerID(); ok { + s.SavedPeerID = val + } + if val, ok := from.GetTopMsgID(); ok { s.TopMsgID = val } @@ -243,6 +255,11 @@ func (s *MessagesSearchRequest) TypeInfo() tdp.Type { SchemaName: "from_id", Null: !s.Flags.Has(0), }, + { + Name: "SavedPeerID", + SchemaName: "saved_peer_id", + Null: !s.Flags.Has(2), + }, { Name: "TopMsgID", SchemaName: "top_msg_id", @@ -293,6 +310,9 @@ func (s *MessagesSearchRequest) SetFlags() { if !(s.FromID == nil) { s.Flags.Set(0) } + if !(s.SavedPeerID == nil) { + s.Flags.Set(2) + } if !(s.TopMsgID == 0) { s.Flags.Set(1) } @@ -301,7 +321,7 @@ func (s *MessagesSearchRequest) SetFlags() { // Encode implements bin.Encoder. func (s *MessagesSearchRequest) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.search#a0fda762 as nil") + return fmt.Errorf("can't encode messages.search#a7b4e929 as nil") } b.PutID(MessagesSearchRequestTypeID) return s.EncodeBare(b) @@ -310,35 +330,43 @@ func (s *MessagesSearchRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *MessagesSearchRequest) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode messages.search#a0fda762 as nil") + return fmt.Errorf("can't encode messages.search#a7b4e929 as nil") } s.SetFlags() if err := s.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.search#a0fda762: field flags: %w", err) + return fmt.Errorf("unable to encode messages.search#a7b4e929: field flags: %w", err) } if s.Peer == nil { - return fmt.Errorf("unable to encode messages.search#a0fda762: field peer is nil") + return fmt.Errorf("unable to encode messages.search#a7b4e929: field peer is nil") } if err := s.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.search#a0fda762: field peer: %w", err) + return fmt.Errorf("unable to encode messages.search#a7b4e929: field peer: %w", err) } b.PutString(s.Q) if s.Flags.Has(0) { if s.FromID == nil { - return fmt.Errorf("unable to encode messages.search#a0fda762: field from_id is nil") + return fmt.Errorf("unable to encode messages.search#a7b4e929: field from_id is nil") } if err := s.FromID.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.search#a0fda762: field from_id: %w", err) + return fmt.Errorf("unable to encode messages.search#a7b4e929: field from_id: %w", err) + } + } + if s.Flags.Has(2) { + if s.SavedPeerID == nil { + return fmt.Errorf("unable to encode messages.search#a7b4e929: field saved_peer_id is nil") + } + if err := s.SavedPeerID.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.search#a7b4e929: field saved_peer_id: %w", err) } } if s.Flags.Has(1) { b.PutInt(s.TopMsgID) } if s.Filter == nil { - return fmt.Errorf("unable to encode messages.search#a0fda762: field filter is nil") + return fmt.Errorf("unable to encode messages.search#a7b4e929: field filter is nil") } if err := s.Filter.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.search#a0fda762: field filter: %w", err) + return fmt.Errorf("unable to encode messages.search#a7b4e929: field filter: %w", err) } b.PutInt(s.MinDate) b.PutInt(s.MaxDate) @@ -354,10 +382,10 @@ func (s *MessagesSearchRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *MessagesSearchRequest) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.search#a0fda762 to nil") + return fmt.Errorf("can't decode messages.search#a7b4e929 to nil") } if err := b.ConsumeID(MessagesSearchRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.search#a0fda762: %w", err) + return fmt.Errorf("unable to decode messages.search#a7b4e929: %w", err) } return s.DecodeBare(b) } @@ -365,101 +393,108 @@ func (s *MessagesSearchRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *MessagesSearchRequest) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode messages.search#a0fda762 to nil") + return fmt.Errorf("can't decode messages.search#a7b4e929 to nil") } { if err := s.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messages.search#a0fda762: field flags: %w", err) + return fmt.Errorf("unable to decode messages.search#a7b4e929: field flags: %w", err) } } { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.search#a0fda762: field peer: %w", err) + return fmt.Errorf("unable to decode messages.search#a7b4e929: field peer: %w", err) } s.Peer = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode messages.search#a0fda762: field q: %w", err) + return fmt.Errorf("unable to decode messages.search#a7b4e929: field q: %w", err) } s.Q = value } if s.Flags.Has(0) { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode messages.search#a0fda762: field from_id: %w", err) + return fmt.Errorf("unable to decode messages.search#a7b4e929: field from_id: %w", err) } s.FromID = value } + if s.Flags.Has(2) { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode messages.search#a7b4e929: field saved_peer_id: %w", err) + } + s.SavedPeerID = value + } if s.Flags.Has(1) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.search#a0fda762: field top_msg_id: %w", err) + return fmt.Errorf("unable to decode messages.search#a7b4e929: field top_msg_id: %w", err) } s.TopMsgID = value } { value, err := DecodeMessagesFilter(b) if err != nil { - return fmt.Errorf("unable to decode messages.search#a0fda762: field filter: %w", err) + return fmt.Errorf("unable to decode messages.search#a7b4e929: field filter: %w", err) } s.Filter = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.search#a0fda762: field min_date: %w", err) + return fmt.Errorf("unable to decode messages.search#a7b4e929: field min_date: %w", err) } s.MinDate = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.search#a0fda762: field max_date: %w", err) + return fmt.Errorf("unable to decode messages.search#a7b4e929: field max_date: %w", err) } s.MaxDate = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.search#a0fda762: field offset_id: %w", err) + return fmt.Errorf("unable to decode messages.search#a7b4e929: field offset_id: %w", err) } s.OffsetID = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.search#a0fda762: field add_offset: %w", err) + return fmt.Errorf("unable to decode messages.search#a7b4e929: field add_offset: %w", err) } s.AddOffset = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.search#a0fda762: field limit: %w", err) + return fmt.Errorf("unable to decode messages.search#a7b4e929: field limit: %w", err) } s.Limit = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.search#a0fda762: field max_id: %w", err) + return fmt.Errorf("unable to decode messages.search#a7b4e929: field max_id: %w", err) } s.MaxID = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messages.search#a0fda762: field min_id: %w", err) + return fmt.Errorf("unable to decode messages.search#a7b4e929: field min_id: %w", err) } s.MinID = value } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode messages.search#a0fda762: field hash: %w", err) + return fmt.Errorf("unable to decode messages.search#a7b4e929: field hash: %w", err) } s.Hash = value } @@ -500,6 +535,24 @@ func (s *MessagesSearchRequest) GetFromID() (value InputPeerClass, ok bool) { return s.FromID, true } +// SetSavedPeerID sets value of SavedPeerID conditional field. +func (s *MessagesSearchRequest) SetSavedPeerID(value InputPeerClass) { + s.Flags.Set(2) + s.SavedPeerID = value +} + +// GetSavedPeerID returns value of SavedPeerID conditional field and +// boolean which is true if field was set. +func (s *MessagesSearchRequest) GetSavedPeerID() (value InputPeerClass, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(2) { + return value, false + } + return s.SavedPeerID, true +} + // SetTopMsgID sets value of TopMsgID conditional field. func (s *MessagesSearchRequest) SetTopMsgID(value int) { s.Flags.Set(1) @@ -590,7 +643,7 @@ func (s *MessagesSearchRequest) GetHash() (value int64) { return s.Hash } -// MessagesSearch invokes method messages.search#a0fda762 returning error if any. +// MessagesSearch invokes method messages.search#a7b4e929 returning error if any. // Search for messages. // // Possible errors: diff --git a/tg/tl_messages_toggle_saved_dialog_pin_gen.go b/tg/tl_messages_toggle_saved_dialog_pin_gen.go new file mode 100644 index 0000000000..4cb9fcc802 --- /dev/null +++ b/tg/tl_messages_toggle_saved_dialog_pin_gen.go @@ -0,0 +1,232 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// MessagesToggleSavedDialogPinRequest represents TL type `messages.toggleSavedDialogPin#ac81bbde`. +// +// See https://core.telegram.org/method/messages.toggleSavedDialogPin for reference. +type MessagesToggleSavedDialogPinRequest struct { + // Flags field of MessagesToggleSavedDialogPinRequest. + Flags bin.Fields + // Pinned field of MessagesToggleSavedDialogPinRequest. + Pinned bool + // Peer field of MessagesToggleSavedDialogPinRequest. + Peer InputDialogPeerClass +} + +// MessagesToggleSavedDialogPinRequestTypeID is TL type id of MessagesToggleSavedDialogPinRequest. +const MessagesToggleSavedDialogPinRequestTypeID = 0xac81bbde + +// Ensuring interfaces in compile-time for MessagesToggleSavedDialogPinRequest. +var ( + _ bin.Encoder = &MessagesToggleSavedDialogPinRequest{} + _ bin.Decoder = &MessagesToggleSavedDialogPinRequest{} + _ bin.BareEncoder = &MessagesToggleSavedDialogPinRequest{} + _ bin.BareDecoder = &MessagesToggleSavedDialogPinRequest{} +) + +func (t *MessagesToggleSavedDialogPinRequest) Zero() bool { + if t == nil { + return true + } + if !(t.Flags.Zero()) { + return false + } + if !(t.Pinned == false) { + return false + } + if !(t.Peer == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (t *MessagesToggleSavedDialogPinRequest) String() string { + if t == nil { + return "MessagesToggleSavedDialogPinRequest(nil)" + } + type Alias MessagesToggleSavedDialogPinRequest + return fmt.Sprintf("MessagesToggleSavedDialogPinRequest%+v", Alias(*t)) +} + +// FillFrom fills MessagesToggleSavedDialogPinRequest from given interface. +func (t *MessagesToggleSavedDialogPinRequest) FillFrom(from interface { + GetPinned() (value bool) + GetPeer() (value InputDialogPeerClass) +}) { + t.Pinned = from.GetPinned() + t.Peer = from.GetPeer() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesToggleSavedDialogPinRequest) TypeID() uint32 { + return MessagesToggleSavedDialogPinRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesToggleSavedDialogPinRequest) TypeName() string { + return "messages.toggleSavedDialogPin" +} + +// TypeInfo returns info about TL type. +func (t *MessagesToggleSavedDialogPinRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.toggleSavedDialogPin", + ID: MessagesToggleSavedDialogPinRequestTypeID, + } + if t == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Pinned", + SchemaName: "pinned", + Null: !t.Flags.Has(0), + }, + { + Name: "Peer", + SchemaName: "peer", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (t *MessagesToggleSavedDialogPinRequest) SetFlags() { + if !(t.Pinned == false) { + t.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (t *MessagesToggleSavedDialogPinRequest) Encode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode messages.toggleSavedDialogPin#ac81bbde as nil") + } + b.PutID(MessagesToggleSavedDialogPinRequestTypeID) + return t.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (t *MessagesToggleSavedDialogPinRequest) EncodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode messages.toggleSavedDialogPin#ac81bbde as nil") + } + t.SetFlags() + if err := t.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.toggleSavedDialogPin#ac81bbde: field flags: %w", err) + } + if t.Peer == nil { + return fmt.Errorf("unable to encode messages.toggleSavedDialogPin#ac81bbde: field peer is nil") + } + if err := t.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.toggleSavedDialogPin#ac81bbde: field peer: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (t *MessagesToggleSavedDialogPinRequest) Decode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode messages.toggleSavedDialogPin#ac81bbde to nil") + } + if err := b.ConsumeID(MessagesToggleSavedDialogPinRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.toggleSavedDialogPin#ac81bbde: %w", err) + } + return t.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (t *MessagesToggleSavedDialogPinRequest) DecodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode messages.toggleSavedDialogPin#ac81bbde to nil") + } + { + if err := t.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.toggleSavedDialogPin#ac81bbde: field flags: %w", err) + } + } + t.Pinned = t.Flags.Has(0) + { + value, err := DecodeInputDialogPeer(b) + if err != nil { + return fmt.Errorf("unable to decode messages.toggleSavedDialogPin#ac81bbde: field peer: %w", err) + } + t.Peer = value + } + return nil +} + +// SetPinned sets value of Pinned conditional field. +func (t *MessagesToggleSavedDialogPinRequest) SetPinned(value bool) { + if value { + t.Flags.Set(0) + t.Pinned = true + } else { + t.Flags.Unset(0) + t.Pinned = false + } +} + +// GetPinned returns value of Pinned conditional field. +func (t *MessagesToggleSavedDialogPinRequest) GetPinned() (value bool) { + if t == nil { + return + } + return t.Flags.Has(0) +} + +// GetPeer returns value of Peer field. +func (t *MessagesToggleSavedDialogPinRequest) GetPeer() (value InputDialogPeerClass) { + if t == nil { + return + } + return t.Peer +} + +// MessagesToggleSavedDialogPin invokes method messages.toggleSavedDialogPin#ac81bbde returning error if any. +// +// See https://core.telegram.org/method/messages.toggleSavedDialogPin for reference. +func (c *Client) MessagesToggleSavedDialogPin(ctx context.Context, request *MessagesToggleSavedDialogPinRequest) (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_messages_toggle_saved_dialog_pin_slices_gen.go b/tg/tl_messages_toggle_saved_dialog_pin_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_toggle_saved_dialog_pin_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_registry_gen.go b/tg/tl_registry_gen.go index 39b8da5255..ab8436baf0 100644 --- a/tg/tl_registry_gen.go +++ b/tg/tl_registry_gen.go @@ -32,7 +32,7 @@ var ( ) // Layer version of schema. -const Layer = 169 +const Layer = 170 // TypesMap returns mapping from type ids to TL type names. func TypesMap() map[uint32]string { @@ -128,7 +128,7 @@ func TypesMap() map[uint32]string { ChatPhotoEmptyTypeID: "chatPhotoEmpty#37c1011c", ChatPhotoTypeID: "chatPhoto#1c6e1c11", MessageEmptyTypeID: "messageEmpty#90a6ca84", - MessageTypeID: "message#38116ee0", + MessageTypeID: "message#76bec211", MessageServiceTypeID: "messageService#2b085862", MessageMediaEmptyTypeID: "messageMediaEmpty#3ded6320", MessageMediaPhotoTypeID: "messageMediaPhoto#695150d7", @@ -383,6 +383,8 @@ func TypesMap() map[uint32]string { UpdatePeerWallpaperTypeID: "updatePeerWallpaper#ae3f101d", UpdateBotMessageReactionTypeID: "updateBotMessageReaction#ac21d3ce", UpdateBotMessageReactionsTypeID: "updateBotMessageReactions#9cb7759", + UpdateSavedDialogPinnedTypeID: "updateSavedDialogPinned#aeaf9e74", + UpdatePinnedSavedDialogsTypeID: "updatePinnedSavedDialogs#686c85a6", UpdatesStateTypeID: "updates.state#a56c2a3e", UpdatesDifferenceEmptyTypeID: "updates.differenceEmpty#5d75a138", UpdatesDifferenceTypeID: "updates.difference#f49ca0", @@ -634,7 +636,7 @@ func TypesMap() map[uint32]string { BotInlineMediaResultTypeID: "botInlineMediaResult#17db940b", MessagesBotResultsTypeID: "messages.botResults#e021f2f6", ExportedMessageLinkTypeID: "exportedMessageLink#5dab1af4", - MessageFwdHeaderTypeID: "messageFwdHeader#5f777dce", + MessageFwdHeaderTypeID: "messageFwdHeader#4e4df4bb", AuthCodeTypeSMSTypeID: "auth.codeTypeSms#72a3158c", AuthCodeTypeCallTypeID: "auth.codeTypeCall#741cd3e3", AuthCodeTypeFlashCallTypeID: "auth.codeTypeFlashCall#226ccefb", @@ -1237,6 +1239,10 @@ func TypesMap() map[uint32]string { StoryReactionPublicForwardTypeID: "storyReactionPublicForward#bbab2643", StoryReactionPublicRepostTypeID: "storyReactionPublicRepost#cfcd0f13", StoriesStoryReactionsListTypeID: "stories.storyReactionsList#aa5f789c", + SavedDialogTypeID: "savedDialog#bd87cb6c", + MessagesSavedDialogsTypeID: "messages.savedDialogs#f83ae221", + MessagesSavedDialogsSliceTypeID: "messages.savedDialogsSlice#44ba9dd9", + MessagesSavedDialogsNotModifiedTypeID: "messages.savedDialogsNotModified#c01f6fe8", InvokeAfterMsgRequestTypeID: "invokeAfterMsg#cb9f372d", InvokeAfterMsgsRequestTypeID: "invokeAfterMsgs#3dc4b4f0", InitConnectionRequestTypeID: "initConnection#c1cd5ea9", @@ -1389,7 +1395,7 @@ func TypesMap() map[uint32]string { MessagesGetMessagesRequestTypeID: "messages.getMessages#63c66506", MessagesGetDialogsRequestTypeID: "messages.getDialogs#a0f4cb4f", MessagesGetHistoryRequestTypeID: "messages.getHistory#4423e6c5", - MessagesSearchRequestTypeID: "messages.search#a0fda762", + MessagesSearchRequestTypeID: "messages.search#a7b4e929", MessagesReadHistoryRequestTypeID: "messages.readHistory#e306d3a", MessagesDeleteHistoryRequestTypeID: "messages.deleteHistory#b08f922a", MessagesDeleteMessagesRequestTypeID: "messages.deleteMessages#e58e95d2", @@ -1492,7 +1498,7 @@ func TypesMap() map[uint32]string { MessagesGetEmojiKeywordsDifferenceRequestTypeID: "messages.getEmojiKeywordsDifference#1508b6af", MessagesGetEmojiKeywordsLanguagesRequestTypeID: "messages.getEmojiKeywordsLanguages#4e9963b2", MessagesGetEmojiURLRequestTypeID: "messages.getEmojiURL#d5b10c26", - MessagesGetSearchCountersRequestTypeID: "messages.getSearchCounters#ae7cc1", + MessagesGetSearchCountersRequestTypeID: "messages.getSearchCounters#1bbcf300", MessagesRequestURLAuthRequestTypeID: "messages.requestUrlAuth#198fb446", MessagesAcceptURLAuthRequestTypeID: "messages.acceptUrlAuth#b12c7125", MessagesHidePeerSettingsBarRequestTypeID: "messages.hidePeerSettingsBar#4facb138", @@ -1528,8 +1534,8 @@ func TypesMap() map[uint32]string { MessagesCheckHistoryImportPeerRequestTypeID: "messages.checkHistoryImportPeer#5dc60f03", MessagesSetChatThemeRequestTypeID: "messages.setChatTheme#e63be13f", MessagesGetMessageReadParticipantsRequestTypeID: "messages.getMessageReadParticipants#31c1c44f", - MessagesGetSearchResultsCalendarRequestTypeID: "messages.getSearchResultsCalendar#49f0bde9", - MessagesGetSearchResultsPositionsRequestTypeID: "messages.getSearchResultsPositions#6e9583a3", + MessagesGetSearchResultsCalendarRequestTypeID: "messages.getSearchResultsCalendar#6aa3f6bd", + MessagesGetSearchResultsPositionsRequestTypeID: "messages.getSearchResultsPositions#9c7f2f10", MessagesHideChatJoinRequestRequestTypeID: "messages.hideChatJoinRequest#7fe7e815", MessagesHideAllChatJoinRequestsRequestTypeID: "messages.hideAllChatJoinRequests#e085f4ea", MessagesToggleNoForwardsRequestTypeID: "messages.toggleNoForwards#b11eafa2", @@ -1574,6 +1580,12 @@ func TypesMap() map[uint32]string { MessagesRequestAppWebViewRequestTypeID: "messages.requestAppWebView#8c5a3b3c", MessagesSetChatWallPaperRequestTypeID: "messages.setChatWallPaper#8ffacae1", MessagesSearchEmojiStickerSetsRequestTypeID: "messages.searchEmojiStickerSets#92b4494c", + MessagesGetSavedDialogsRequestTypeID: "messages.getSavedDialogs#5381d21a", + MessagesGetSavedHistoryRequestTypeID: "messages.getSavedHistory#3d9a414d", + MessagesDeleteSavedHistoryRequestTypeID: "messages.deleteSavedHistory#6e98102b", + MessagesGetPinnedSavedDialogsRequestTypeID: "messages.getPinnedSavedDialogs#d63d94e0", + MessagesToggleSavedDialogPinRequestTypeID: "messages.toggleSavedDialogPin#ac81bbde", + MessagesReorderPinnedSavedDialogsRequestTypeID: "messages.reorderPinnedSavedDialogs#8b716587", UpdatesGetStateRequestTypeID: "updates.getState#edd4882a", UpdatesGetDifferenceRequestTypeID: "updates.getDifference#19c2f763", UpdatesGetChannelDifferenceRequestTypeID: "updates.getChannelDifference#3173d78", @@ -2165,6 +2177,8 @@ func NamesMap() map[string]uint32 { "updatePeerWallpaper": UpdatePeerWallpaperTypeID, "updateBotMessageReaction": UpdateBotMessageReactionTypeID, "updateBotMessageReactions": UpdateBotMessageReactionsTypeID, + "updateSavedDialogPinned": UpdateSavedDialogPinnedTypeID, + "updatePinnedSavedDialogs": UpdatePinnedSavedDialogsTypeID, "updates.state": UpdatesStateTypeID, "updates.differenceEmpty": UpdatesDifferenceEmptyTypeID, "updates.difference": UpdatesDifferenceTypeID, @@ -3019,6 +3033,10 @@ func NamesMap() map[string]uint32 { "storyReactionPublicForward": StoryReactionPublicForwardTypeID, "storyReactionPublicRepost": StoryReactionPublicRepostTypeID, "stories.storyReactionsList": StoriesStoryReactionsListTypeID, + "savedDialog": SavedDialogTypeID, + "messages.savedDialogs": MessagesSavedDialogsTypeID, + "messages.savedDialogsSlice": MessagesSavedDialogsSliceTypeID, + "messages.savedDialogsNotModified": MessagesSavedDialogsNotModifiedTypeID, "invokeAfterMsg": InvokeAfterMsgRequestTypeID, "invokeAfterMsgs": InvokeAfterMsgsRequestTypeID, "initConnection": InitConnectionRequestTypeID, @@ -3356,6 +3374,12 @@ func NamesMap() map[string]uint32 { "messages.requestAppWebView": MessagesRequestAppWebViewRequestTypeID, "messages.setChatWallPaper": MessagesSetChatWallPaperRequestTypeID, "messages.searchEmojiStickerSets": MessagesSearchEmojiStickerSetsRequestTypeID, + "messages.getSavedDialogs": MessagesGetSavedDialogsRequestTypeID, + "messages.getSavedHistory": MessagesGetSavedHistoryRequestTypeID, + "messages.deleteSavedHistory": MessagesDeleteSavedHistoryRequestTypeID, + "messages.getPinnedSavedDialogs": MessagesGetPinnedSavedDialogsRequestTypeID, + "messages.toggleSavedDialogPin": MessagesToggleSavedDialogPinRequestTypeID, + "messages.reorderPinnedSavedDialogs": MessagesReorderPinnedSavedDialogsRequestTypeID, "updates.getState": UpdatesGetStateRequestTypeID, "updates.getDifference": UpdatesGetDifferenceRequestTypeID, "updates.getChannelDifference": UpdatesGetChannelDifferenceRequestTypeID, @@ -3947,6 +3971,8 @@ func TypesConstructorMap() map[uint32]func() bin.Object { UpdatePeerWallpaperTypeID: func() bin.Object { return &UpdatePeerWallpaper{} }, UpdateBotMessageReactionTypeID: func() bin.Object { return &UpdateBotMessageReaction{} }, UpdateBotMessageReactionsTypeID: func() bin.Object { return &UpdateBotMessageReactions{} }, + UpdateSavedDialogPinnedTypeID: func() bin.Object { return &UpdateSavedDialogPinned{} }, + UpdatePinnedSavedDialogsTypeID: func() bin.Object { return &UpdatePinnedSavedDialogs{} }, UpdatesStateTypeID: func() bin.Object { return &UpdatesState{} }, UpdatesDifferenceEmptyTypeID: func() bin.Object { return &UpdatesDifferenceEmpty{} }, UpdatesDifferenceTypeID: func() bin.Object { return &UpdatesDifference{} }, @@ -4801,6 +4827,10 @@ func TypesConstructorMap() map[uint32]func() bin.Object { StoryReactionPublicForwardTypeID: func() bin.Object { return &StoryReactionPublicForward{} }, StoryReactionPublicRepostTypeID: func() bin.Object { return &StoryReactionPublicRepost{} }, StoriesStoryReactionsListTypeID: func() bin.Object { return &StoriesStoryReactionsList{} }, + SavedDialogTypeID: func() bin.Object { return &SavedDialog{} }, + MessagesSavedDialogsTypeID: func() bin.Object { return &MessagesSavedDialogs{} }, + MessagesSavedDialogsSliceTypeID: func() bin.Object { return &MessagesSavedDialogsSlice{} }, + MessagesSavedDialogsNotModifiedTypeID: func() bin.Object { return &MessagesSavedDialogsNotModified{} }, InvokeAfterMsgRequestTypeID: func() bin.Object { return &InvokeAfterMsgRequest{} }, InvokeAfterMsgsRequestTypeID: func() bin.Object { return &InvokeAfterMsgsRequest{} }, InitConnectionRequestTypeID: func() bin.Object { return &InitConnectionRequest{} }, @@ -5138,6 +5168,12 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MessagesRequestAppWebViewRequestTypeID: func() bin.Object { return &MessagesRequestAppWebViewRequest{} }, MessagesSetChatWallPaperRequestTypeID: func() bin.Object { return &MessagesSetChatWallPaperRequest{} }, MessagesSearchEmojiStickerSetsRequestTypeID: func() bin.Object { return &MessagesSearchEmojiStickerSetsRequest{} }, + MessagesGetSavedDialogsRequestTypeID: func() bin.Object { return &MessagesGetSavedDialogsRequest{} }, + MessagesGetSavedHistoryRequestTypeID: func() bin.Object { return &MessagesGetSavedHistoryRequest{} }, + MessagesDeleteSavedHistoryRequestTypeID: func() bin.Object { return &MessagesDeleteSavedHistoryRequest{} }, + MessagesGetPinnedSavedDialogsRequestTypeID: func() bin.Object { return &MessagesGetPinnedSavedDialogsRequest{} }, + MessagesToggleSavedDialogPinRequestTypeID: func() bin.Object { return &MessagesToggleSavedDialogPinRequest{} }, + MessagesReorderPinnedSavedDialogsRequestTypeID: func() bin.Object { return &MessagesReorderPinnedSavedDialogsRequest{} }, UpdatesGetStateRequestTypeID: func() bin.Object { return &UpdatesGetStateRequest{} }, UpdatesGetDifferenceRequestTypeID: func() bin.Object { return &UpdatesGetDifferenceRequest{} }, UpdatesGetChannelDifferenceRequestTypeID: func() bin.Object { return &UpdatesGetChannelDifferenceRequest{} }, @@ -6186,6 +6222,11 @@ func ClassConstructorsMap() map[string][]uint32 { MessagesRecentStickersNotModifiedTypeID, MessagesRecentStickersTypeID, }, + MessagesSavedDialogsClassName: { + MessagesSavedDialogsTypeID, + MessagesSavedDialogsSliceTypeID, + MessagesSavedDialogsNotModifiedTypeID, + }, MessagesSavedGifsClassName: { MessagesSavedGifsNotModifiedTypeID, MessagesSavedGifsTypeID, @@ -6644,6 +6685,8 @@ func ClassConstructorsMap() map[string][]uint32 { UpdatePeerWallpaperTypeID, UpdateBotMessageReactionTypeID, UpdateBotMessageReactionsTypeID, + UpdateSavedDialogPinnedTypeID, + UpdatePinnedSavedDialogsTypeID, }, UpdatesChannelDifferenceClassName: { UpdatesChannelDifferenceEmptyTypeID, diff --git a/tg/tl_saved_dialog_gen.go b/tg/tl_saved_dialog_gen.go new file mode 100644 index 0000000000..be837a224c --- /dev/null +++ b/tg/tl_saved_dialog_gen.go @@ -0,0 +1,246 @@ +// 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{} +) + +// SavedDialog represents TL type `savedDialog#bd87cb6c`. +// +// See https://core.telegram.org/constructor/savedDialog for reference. +type SavedDialog struct { + // Flags field of SavedDialog. + Flags bin.Fields + // Pinned field of SavedDialog. + Pinned bool + // Peer field of SavedDialog. + Peer PeerClass + // TopMessage field of SavedDialog. + TopMessage int +} + +// SavedDialogTypeID is TL type id of SavedDialog. +const SavedDialogTypeID = 0xbd87cb6c + +// Ensuring interfaces in compile-time for SavedDialog. +var ( + _ bin.Encoder = &SavedDialog{} + _ bin.Decoder = &SavedDialog{} + _ bin.BareEncoder = &SavedDialog{} + _ bin.BareDecoder = &SavedDialog{} +) + +func (s *SavedDialog) Zero() bool { + if s == nil { + return true + } + if !(s.Flags.Zero()) { + return false + } + if !(s.Pinned == false) { + return false + } + if !(s.Peer == nil) { + return false + } + if !(s.TopMessage == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *SavedDialog) String() string { + if s == nil { + return "SavedDialog(nil)" + } + type Alias SavedDialog + return fmt.Sprintf("SavedDialog%+v", Alias(*s)) +} + +// FillFrom fills SavedDialog from given interface. +func (s *SavedDialog) FillFrom(from interface { + GetPinned() (value bool) + GetPeer() (value PeerClass) + GetTopMessage() (value int) +}) { + s.Pinned = from.GetPinned() + s.Peer = from.GetPeer() + s.TopMessage = from.GetTopMessage() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*SavedDialog) TypeID() uint32 { + return SavedDialogTypeID +} + +// TypeName returns name of type in TL schema. +func (*SavedDialog) TypeName() string { + return "savedDialog" +} + +// TypeInfo returns info about TL type. +func (s *SavedDialog) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "savedDialog", + ID: SavedDialogTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Pinned", + SchemaName: "pinned", + Null: !s.Flags.Has(2), + }, + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "TopMessage", + SchemaName: "top_message", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (s *SavedDialog) SetFlags() { + if !(s.Pinned == false) { + s.Flags.Set(2) + } +} + +// Encode implements bin.Encoder. +func (s *SavedDialog) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode savedDialog#bd87cb6c as nil") + } + b.PutID(SavedDialogTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *SavedDialog) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode savedDialog#bd87cb6c as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode savedDialog#bd87cb6c: field flags: %w", err) + } + if s.Peer == nil { + return fmt.Errorf("unable to encode savedDialog#bd87cb6c: field peer is nil") + } + if err := s.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode savedDialog#bd87cb6c: field peer: %w", err) + } + b.PutInt(s.TopMessage) + return nil +} + +// Decode implements bin.Decoder. +func (s *SavedDialog) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode savedDialog#bd87cb6c to nil") + } + if err := b.ConsumeID(SavedDialogTypeID); err != nil { + return fmt.Errorf("unable to decode savedDialog#bd87cb6c: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *SavedDialog) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode savedDialog#bd87cb6c to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode savedDialog#bd87cb6c: field flags: %w", err) + } + } + s.Pinned = s.Flags.Has(2) + { + value, err := DecodePeer(b) + if err != nil { + return fmt.Errorf("unable to decode savedDialog#bd87cb6c: field peer: %w", err) + } + s.Peer = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode savedDialog#bd87cb6c: field top_message: %w", err) + } + s.TopMessage = value + } + return nil +} + +// SetPinned sets value of Pinned conditional field. +func (s *SavedDialog) SetPinned(value bool) { + if value { + s.Flags.Set(2) + s.Pinned = true + } else { + s.Flags.Unset(2) + s.Pinned = false + } +} + +// GetPinned returns value of Pinned conditional field. +func (s *SavedDialog) GetPinned() (value bool) { + if s == nil { + return + } + return s.Flags.Has(2) +} + +// GetPeer returns value of Peer field. +func (s *SavedDialog) GetPeer() (value PeerClass) { + if s == nil { + return + } + return s.Peer +} + +// GetTopMessage returns value of TopMessage field. +func (s *SavedDialog) GetTopMessage() (value int) { + if s == nil { + return + } + return s.TopMessage +} diff --git a/tg/tl_saved_dialog_slices_gen.go b/tg/tl_saved_dialog_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_saved_dialog_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_server_gen.go b/tg/tl_server_gen.go index ac7489e7f4..21a726fa39 100644 --- a/tg/tl_server_gen.go +++ b/tg/tl_server_gen.go @@ -6079,6 +6079,116 @@ func (s *ServerDispatcher) OnMessagesSearchEmojiStickerSets(f func(ctx context.C s.handlers[MessagesSearchEmojiStickerSetsRequestTypeID] = handler } +func (s *ServerDispatcher) OnMessagesGetSavedDialogs(f func(ctx context.Context, request *MessagesGetSavedDialogsRequest) (MessagesSavedDialogsClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesGetSavedDialogsRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return &MessagesSavedDialogsBox{SavedDialogs: response}, nil + } + + s.handlers[MessagesGetSavedDialogsRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnMessagesGetSavedHistory(f func(ctx context.Context, request *MessagesGetSavedHistoryRequest) (MessagesMessagesClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesGetSavedHistoryRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return &MessagesMessagesBox{Messages: response}, nil + } + + s.handlers[MessagesGetSavedHistoryRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnMessagesDeleteSavedHistory(f func(ctx context.Context, request *MessagesDeleteSavedHistoryRequest) (*MessagesAffectedHistory, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesDeleteSavedHistoryRequest + 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[MessagesDeleteSavedHistoryRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnMessagesGetPinnedSavedDialogs(f func(ctx context.Context) (MessagesSavedDialogsClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesGetPinnedSavedDialogsRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx) + if err != nil { + return nil, err + } + return &MessagesSavedDialogsBox{SavedDialogs: response}, nil + } + + s.handlers[MessagesGetPinnedSavedDialogsRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnMessagesToggleSavedDialogPin(f func(ctx context.Context, request *MessagesToggleSavedDialogPinRequest) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesToggleSavedDialogPinRequest + 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[MessagesToggleSavedDialogPinRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnMessagesReorderPinnedSavedDialogs(f func(ctx context.Context, request *MessagesReorderPinnedSavedDialogsRequest) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesReorderPinnedSavedDialogsRequest + 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[MessagesReorderPinnedSavedDialogsRequestTypeID] = handler +} + func (s *ServerDispatcher) OnUpdatesGetState(f func(ctx context.Context) (*UpdatesState, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request UpdatesGetStateRequest diff --git a/tg/tl_update_gen.go b/tg/tl_update_gen.go index a58f8d853d..f48744505e 100644 --- a/tg/tl_update_gen.go +++ b/tg/tl_update_gen.go @@ -24782,6 +24782,397 @@ func (u *UpdateBotMessageReactions) GetQts() (value int) { return u.Qts } +// UpdateSavedDialogPinned represents TL type `updateSavedDialogPinned#aeaf9e74`. +// +// See https://core.telegram.org/constructor/updateSavedDialogPinned for reference. +type UpdateSavedDialogPinned struct { + // Flags field of UpdateSavedDialogPinned. + Flags bin.Fields + // Pinned field of UpdateSavedDialogPinned. + Pinned bool + // Peer field of UpdateSavedDialogPinned. + Peer DialogPeerClass +} + +// UpdateSavedDialogPinnedTypeID is TL type id of UpdateSavedDialogPinned. +const UpdateSavedDialogPinnedTypeID = 0xaeaf9e74 + +// construct implements constructor of UpdateClass. +func (u UpdateSavedDialogPinned) construct() UpdateClass { return &u } + +// Ensuring interfaces in compile-time for UpdateSavedDialogPinned. +var ( + _ bin.Encoder = &UpdateSavedDialogPinned{} + _ bin.Decoder = &UpdateSavedDialogPinned{} + _ bin.BareEncoder = &UpdateSavedDialogPinned{} + _ bin.BareDecoder = &UpdateSavedDialogPinned{} + + _ UpdateClass = &UpdateSavedDialogPinned{} +) + +func (u *UpdateSavedDialogPinned) Zero() bool { + if u == nil { + return true + } + if !(u.Flags.Zero()) { + return false + } + if !(u.Pinned == false) { + return false + } + if !(u.Peer == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *UpdateSavedDialogPinned) String() string { + if u == nil { + return "UpdateSavedDialogPinned(nil)" + } + type Alias UpdateSavedDialogPinned + return fmt.Sprintf("UpdateSavedDialogPinned%+v", Alias(*u)) +} + +// FillFrom fills UpdateSavedDialogPinned from given interface. +func (u *UpdateSavedDialogPinned) FillFrom(from interface { + GetPinned() (value bool) + GetPeer() (value DialogPeerClass) +}) { + u.Pinned = from.GetPinned() + u.Peer = from.GetPeer() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*UpdateSavedDialogPinned) TypeID() uint32 { + return UpdateSavedDialogPinnedTypeID +} + +// TypeName returns name of type in TL schema. +func (*UpdateSavedDialogPinned) TypeName() string { + return "updateSavedDialogPinned" +} + +// TypeInfo returns info about TL type. +func (u *UpdateSavedDialogPinned) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "updateSavedDialogPinned", + ID: UpdateSavedDialogPinnedTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Pinned", + SchemaName: "pinned", + Null: !u.Flags.Has(0), + }, + { + Name: "Peer", + SchemaName: "peer", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (u *UpdateSavedDialogPinned) SetFlags() { + if !(u.Pinned == false) { + u.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (u *UpdateSavedDialogPinned) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateSavedDialogPinned#aeaf9e74 as nil") + } + b.PutID(UpdateSavedDialogPinnedTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *UpdateSavedDialogPinned) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateSavedDialogPinned#aeaf9e74 as nil") + } + u.SetFlags() + if err := u.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode updateSavedDialogPinned#aeaf9e74: field flags: %w", err) + } + if u.Peer == nil { + return fmt.Errorf("unable to encode updateSavedDialogPinned#aeaf9e74: field peer is nil") + } + if err := u.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode updateSavedDialogPinned#aeaf9e74: field peer: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (u *UpdateSavedDialogPinned) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateSavedDialogPinned#aeaf9e74 to nil") + } + if err := b.ConsumeID(UpdateSavedDialogPinnedTypeID); err != nil { + return fmt.Errorf("unable to decode updateSavedDialogPinned#aeaf9e74: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *UpdateSavedDialogPinned) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateSavedDialogPinned#aeaf9e74 to nil") + } + { + if err := u.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode updateSavedDialogPinned#aeaf9e74: field flags: %w", err) + } + } + u.Pinned = u.Flags.Has(0) + { + value, err := DecodeDialogPeer(b) + if err != nil { + return fmt.Errorf("unable to decode updateSavedDialogPinned#aeaf9e74: field peer: %w", err) + } + u.Peer = value + } + return nil +} + +// SetPinned sets value of Pinned conditional field. +func (u *UpdateSavedDialogPinned) SetPinned(value bool) { + if value { + u.Flags.Set(0) + u.Pinned = true + } else { + u.Flags.Unset(0) + u.Pinned = false + } +} + +// GetPinned returns value of Pinned conditional field. +func (u *UpdateSavedDialogPinned) GetPinned() (value bool) { + if u == nil { + return + } + return u.Flags.Has(0) +} + +// GetPeer returns value of Peer field. +func (u *UpdateSavedDialogPinned) GetPeer() (value DialogPeerClass) { + if u == nil { + return + } + return u.Peer +} + +// UpdatePinnedSavedDialogs represents TL type `updatePinnedSavedDialogs#686c85a6`. +// +// See https://core.telegram.org/constructor/updatePinnedSavedDialogs for reference. +type UpdatePinnedSavedDialogs struct { + // Flags field of UpdatePinnedSavedDialogs. + Flags bin.Fields + // Order field of UpdatePinnedSavedDialogs. + // + // Use SetOrder and GetOrder helpers. + Order []DialogPeerClass +} + +// UpdatePinnedSavedDialogsTypeID is TL type id of UpdatePinnedSavedDialogs. +const UpdatePinnedSavedDialogsTypeID = 0x686c85a6 + +// construct implements constructor of UpdateClass. +func (u UpdatePinnedSavedDialogs) construct() UpdateClass { return &u } + +// Ensuring interfaces in compile-time for UpdatePinnedSavedDialogs. +var ( + _ bin.Encoder = &UpdatePinnedSavedDialogs{} + _ bin.Decoder = &UpdatePinnedSavedDialogs{} + _ bin.BareEncoder = &UpdatePinnedSavedDialogs{} + _ bin.BareDecoder = &UpdatePinnedSavedDialogs{} + + _ UpdateClass = &UpdatePinnedSavedDialogs{} +) + +func (u *UpdatePinnedSavedDialogs) Zero() bool { + if u == nil { + return true + } + if !(u.Flags.Zero()) { + return false + } + if !(u.Order == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *UpdatePinnedSavedDialogs) String() string { + if u == nil { + return "UpdatePinnedSavedDialogs(nil)" + } + type Alias UpdatePinnedSavedDialogs + return fmt.Sprintf("UpdatePinnedSavedDialogs%+v", Alias(*u)) +} + +// FillFrom fills UpdatePinnedSavedDialogs from given interface. +func (u *UpdatePinnedSavedDialogs) FillFrom(from interface { + GetOrder() (value []DialogPeerClass, ok bool) +}) { + if val, ok := from.GetOrder(); ok { + u.Order = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*UpdatePinnedSavedDialogs) TypeID() uint32 { + return UpdatePinnedSavedDialogsTypeID +} + +// TypeName returns name of type in TL schema. +func (*UpdatePinnedSavedDialogs) TypeName() string { + return "updatePinnedSavedDialogs" +} + +// TypeInfo returns info about TL type. +func (u *UpdatePinnedSavedDialogs) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "updatePinnedSavedDialogs", + ID: UpdatePinnedSavedDialogsTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Order", + SchemaName: "order", + Null: !u.Flags.Has(0), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (u *UpdatePinnedSavedDialogs) SetFlags() { + if !(u.Order == nil) { + u.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (u *UpdatePinnedSavedDialogs) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updatePinnedSavedDialogs#686c85a6 as nil") + } + b.PutID(UpdatePinnedSavedDialogsTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *UpdatePinnedSavedDialogs) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updatePinnedSavedDialogs#686c85a6 as nil") + } + u.SetFlags() + if err := u.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode updatePinnedSavedDialogs#686c85a6: field flags: %w", err) + } + if u.Flags.Has(0) { + b.PutVectorHeader(len(u.Order)) + for idx, v := range u.Order { + if v == nil { + return fmt.Errorf("unable to encode updatePinnedSavedDialogs#686c85a6: field order element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode updatePinnedSavedDialogs#686c85a6: field order element with index %d: %w", idx, err) + } + } + } + return nil +} + +// Decode implements bin.Decoder. +func (u *UpdatePinnedSavedDialogs) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updatePinnedSavedDialogs#686c85a6 to nil") + } + if err := b.ConsumeID(UpdatePinnedSavedDialogsTypeID); err != nil { + return fmt.Errorf("unable to decode updatePinnedSavedDialogs#686c85a6: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *UpdatePinnedSavedDialogs) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updatePinnedSavedDialogs#686c85a6 to nil") + } + { + if err := u.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode updatePinnedSavedDialogs#686c85a6: field flags: %w", err) + } + } + if u.Flags.Has(0) { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode updatePinnedSavedDialogs#686c85a6: field order: %w", err) + } + + if headerLen > 0 { + u.Order = make([]DialogPeerClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeDialogPeer(b) + if err != nil { + return fmt.Errorf("unable to decode updatePinnedSavedDialogs#686c85a6: field order: %w", err) + } + u.Order = append(u.Order, value) + } + } + return nil +} + +// SetOrder sets value of Order conditional field. +func (u *UpdatePinnedSavedDialogs) SetOrder(value []DialogPeerClass) { + u.Flags.Set(0) + u.Order = value +} + +// GetOrder returns value of Order conditional field and +// boolean which is true if field was set. +func (u *UpdatePinnedSavedDialogs) GetOrder() (value []DialogPeerClass, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(0) { + return value, false + } + return u.Order, true +} + +// MapOrder returns field Order wrapped in DialogPeerClassArray helper. +func (u *UpdatePinnedSavedDialogs) MapOrder() (value DialogPeerClassArray, ok bool) { + if !u.Flags.Has(0) { + return value, false + } + return DialogPeerClassArray(u.Order), true +} + // UpdateClassName is schema name of UpdateClass. const UpdateClassName = "Update" @@ -24918,6 +25309,8 @@ const UpdateClassName = "Update" // case *tg.UpdatePeerWallpaper: // updatePeerWallpaper#ae3f101d // case *tg.UpdateBotMessageReaction: // updateBotMessageReaction#ac21d3ce // case *tg.UpdateBotMessageReactions: // updateBotMessageReactions#9cb7759 +// case *tg.UpdateSavedDialogPinned: // updateSavedDialogPinned#aeaf9e74 +// case *tg.UpdatePinnedSavedDialogs: // updatePinnedSavedDialogs#686c85a6 // default: panic(v) // } type UpdateClass interface { @@ -25800,6 +26193,20 @@ func DecodeUpdate(buf *bin.Buffer) (UpdateClass, error) { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) } return &v, nil + case UpdateSavedDialogPinnedTypeID: + // Decoding updateSavedDialogPinned#aeaf9e74. + v := UpdateSavedDialogPinned{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) + } + return &v, nil + case UpdatePinnedSavedDialogsTypeID: + // Decoding updatePinnedSavedDialogs#686c85a6. + v := UpdatePinnedSavedDialogs{} + 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 109235eb90..1febd85b85 100644 --- a/tg/tl_update_slices_gen.go +++ b/tg/tl_update_slices_gen.go @@ -1507,6 +1507,32 @@ func (s UpdateClassArray) AsUpdateBotMessageReactions() (to UpdateBotMessageReac return to } +// AsUpdateSavedDialogPinned returns copy with only UpdateSavedDialogPinned constructors. +func (s UpdateClassArray) AsUpdateSavedDialogPinned() (to UpdateSavedDialogPinnedArray) { + for _, elem := range s { + value, ok := elem.(*UpdateSavedDialogPinned) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsUpdatePinnedSavedDialogs returns copy with only UpdatePinnedSavedDialogs constructors. +func (s UpdateClassArray) AsUpdatePinnedSavedDialogs() (to UpdatePinnedSavedDialogsArray) { + for _, elem := range s { + value, ok := elem.(*UpdatePinnedSavedDialogs) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // UpdateNewMessageArray is adapter for slice of UpdateNewMessage. type UpdateNewMessageArray []UpdateNewMessage @@ -10546,3 +10572,167 @@ func (s UpdateBotMessageReactionsArray) SortStableByDate() UpdateBotMessageReact return a.GetDate() < b.GetDate() }) } + +// UpdateSavedDialogPinnedArray is adapter for slice of UpdateSavedDialogPinned. +type UpdateSavedDialogPinnedArray []UpdateSavedDialogPinned + +// Sort sorts slice of UpdateSavedDialogPinned. +func (s UpdateSavedDialogPinnedArray) Sort(less func(a, b UpdateSavedDialogPinned) bool) UpdateSavedDialogPinnedArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of UpdateSavedDialogPinned. +func (s UpdateSavedDialogPinnedArray) SortStable(less func(a, b UpdateSavedDialogPinned) bool) UpdateSavedDialogPinnedArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of UpdateSavedDialogPinned. +func (s UpdateSavedDialogPinnedArray) Retain(keep func(x UpdateSavedDialogPinned) bool) UpdateSavedDialogPinnedArray { + 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 UpdateSavedDialogPinnedArray) First() (v UpdateSavedDialogPinned, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s UpdateSavedDialogPinnedArray) Last() (v UpdateSavedDialogPinned, 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 *UpdateSavedDialogPinnedArray) PopFirst() (v UpdateSavedDialogPinned, 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 UpdateSavedDialogPinned + 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 *UpdateSavedDialogPinnedArray) Pop() (v UpdateSavedDialogPinned, 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 +} + +// UpdatePinnedSavedDialogsArray is adapter for slice of UpdatePinnedSavedDialogs. +type UpdatePinnedSavedDialogsArray []UpdatePinnedSavedDialogs + +// Sort sorts slice of UpdatePinnedSavedDialogs. +func (s UpdatePinnedSavedDialogsArray) Sort(less func(a, b UpdatePinnedSavedDialogs) bool) UpdatePinnedSavedDialogsArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of UpdatePinnedSavedDialogs. +func (s UpdatePinnedSavedDialogsArray) SortStable(less func(a, b UpdatePinnedSavedDialogs) bool) UpdatePinnedSavedDialogsArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of UpdatePinnedSavedDialogs. +func (s UpdatePinnedSavedDialogsArray) Retain(keep func(x UpdatePinnedSavedDialogs) bool) UpdatePinnedSavedDialogsArray { + 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 UpdatePinnedSavedDialogsArray) First() (v UpdatePinnedSavedDialogs, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s UpdatePinnedSavedDialogsArray) Last() (v UpdatePinnedSavedDialogs, 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 *UpdatePinnedSavedDialogsArray) PopFirst() (v UpdatePinnedSavedDialogs, 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 UpdatePinnedSavedDialogs + 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 *UpdatePinnedSavedDialogsArray) Pop() (v UpdatePinnedSavedDialogs, 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 +}