From ecb10ed075dc1b905c783b9983554009f7b023ba Mon Sep 17 00:00:00 2001 From: GitHub Date: Wed, 28 Dec 2022 07:45:13 +0000 Subject: [PATCH 1/2] feat(schema): update Telegram to the latest layer --- _schema/tdesktop.tl | 54 ++- _schema/telegram.tl | 54 ++- tg/tl_attach_menu_bot_gen.go | 35 ++ ...channels_toggle_participants_hidden_gen.go | 210 +++++++++ ...s_toggle_participants_hidden_slices_gen.go | 35 ++ tg/tl_chat_full_gen.go | 35 ++ tg/tl_document_attribute_gen.go | 35 ++ tg/tl_handlers_gen.go | 20 +- tg/tl_input_media_gen.go | 210 +++++++++ tg/tl_message_action_gen.go | 256 +++++++++++ tg/tl_message_action_slices_gen.go | 95 ++++ tg/tl_message_media_gen.go | 70 +++ ..._messages_toggle_bot_in_attach_menu_gen.go | 77 +++- tg/tl_photos_update_profile_photo_gen.go | 80 +++- ...photos_upload_contact_profile_photo_gen.go | 420 ++++++++++++++++++ ...upload_contact_profile_photo_slices_gen.go | 35 ++ tg/tl_photos_upload_profile_photo_gen.go | 35 ++ tg/tl_registry_gen.go | 34 +- tg/tl_reply_markup_gen.go | 35 ++ tg/tl_server_gen.go | 38 +- tg/tl_sticker_set_covered_gen.go | 142 ++++++ tg/tl_sticker_set_covered_slices_gen.go | 95 ++++ tg/tl_update_gen.go | 374 ++++++---------- tg/tl_update_slices_gen.go | 204 ++++----- tg/tl_user_full_gen.go | 190 ++++++-- tg/tl_user_profile_photo_gen.go | 35 ++ 26 files changed, 2438 insertions(+), 465 deletions(-) create mode 100644 tg/tl_channels_toggle_participants_hidden_gen.go create mode 100644 tg/tl_channels_toggle_participants_hidden_slices_gen.go create mode 100644 tg/tl_photos_upload_contact_profile_photo_gen.go create mode 100644 tg/tl_photos_upload_contact_profile_photo_slices_gen.go diff --git a/_schema/tdesktop.tl b/_schema/tdesktop.tl index 42749af056..cc280fb68e 100644 --- a/_schema/tdesktop.tl +++ b/_schema/tdesktop.tl @@ -1,8 +1,8 @@ // Code generated by ./cmd/dltl, DO NOT EDIT. // // Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/Resources/tl/api.tl -// Layer: 150 -// SHA256: 16379ae5b0f59f8a9aa17d9f8289db7a61869ad5acddf74cd07fcac7e5f91d5e +// Layer: 151 +// SHA256: 53b88e0873d7e5c9aab54d9d0b8ef4d4eaa15dde37e1df618c361206bf9c53eb boolFalse#bc799737 = Bool; @@ -44,23 +44,23 @@ inputFileBig#fa4f0bb5 id:long parts:int name:string = InputFile; inputMediaEmpty#9664f57f = InputMedia; -inputMediaUploadedPhoto#1e287d04 flags:# file:InputFile stickers:flags.0?Vector ttl_seconds:flags.1?int = InputMedia; +inputMediaUploadedPhoto#1e287d04 flags:# spoiler:flags.2?true file:InputFile stickers:flags.0?Vector ttl_seconds:flags.1?int = InputMedia; -inputMediaPhoto#b3ba0635 flags:# id:InputPhoto ttl_seconds:flags.0?int = InputMedia; +inputMediaPhoto#b3ba0635 flags:# spoiler:flags.1?true id:InputPhoto ttl_seconds:flags.0?int = InputMedia; inputMediaGeoPoint#f9c44144 geo_point:InputGeoPoint = InputMedia; inputMediaContact#f8ab7dfb phone_number:string first_name:string last_name:string vcard:string = InputMedia; -inputMediaUploadedDocument#5b38c6c1 flags:# nosound_video:flags.3?true force_file:flags.4?true file:InputFile thumb:flags.2?InputFile mime_type:string attributes:Vector stickers:flags.0?Vector ttl_seconds:flags.1?int = InputMedia; +inputMediaUploadedDocument#5b38c6c1 flags:# nosound_video:flags.3?true force_file:flags.4?true spoiler:flags.5?true file:InputFile thumb:flags.2?InputFile mime_type:string attributes:Vector stickers:flags.0?Vector ttl_seconds:flags.1?int = InputMedia; -inputMediaDocument#33473058 flags:# id:InputDocument ttl_seconds:flags.0?int query:flags.1?string = InputMedia; +inputMediaDocument#33473058 flags:# spoiler:flags.2?true id:InputDocument ttl_seconds:flags.0?int query:flags.1?string = InputMedia; inputMediaVenue#c13d1c11 geo_point:InputGeoPoint title:string address:string provider:string venue_id:string venue_type:string = InputMedia; -inputMediaPhotoExternal#e5bbfe1a flags:# url:string ttl_seconds:flags.0?int = InputMedia; +inputMediaPhotoExternal#e5bbfe1a flags:# spoiler:flags.1?true url:string ttl_seconds:flags.0?int = InputMedia; -inputMediaDocumentExternal#fb52dc99 flags:# url:string ttl_seconds:flags.0?int = InputMedia; +inputMediaDocumentExternal#fb52dc99 flags:# spoiler:flags.1?true url:string ttl_seconds:flags.0?int = InputMedia; inputMediaGame#d33f43f3 id:InputGame = InputMedia; @@ -138,7 +138,7 @@ user#8f97c628 flags:# self:flags.10?true contact:flags.11?true mutual_contact:fl userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto; -userProfilePhoto#82d1f706 flags:# has_video:flags.0?true photo_id:long stripped_thumb:flags.1?bytes dc_id:int = UserProfilePhoto; +userProfilePhoto#82d1f706 flags:# has_video:flags.0?true personal:flags.2?true photo_id:long stripped_thumb:flags.1?bytes dc_id:int = UserProfilePhoto; userStatusEmpty#9d05049 = UserStatus; @@ -164,7 +164,7 @@ channelForbidden#17d493d5 flags:# broadcast:flags.5?true megagroup:flags.8?true chatFull#c9d31138 flags:# can_set_username:flags.7?true has_scheduled:flags.8?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector available_reactions:flags.18?ChatReactions = ChatFull; -channelFull#f2355507 flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true antispam:flags2.1?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions = ChatFull; +channelFull#f2355507 flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true antispam:flags2.1?true participants_hidden:flags2.2?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions = ChatFull; chatParticipant#c02d4007 user_id:long inviter_id:long date:int = ChatParticipant; @@ -188,7 +188,7 @@ messageService#2b085862 flags:# out:flags.1?true mentioned:flags.4?true media_un messageMediaEmpty#3ded6320 = MessageMedia; -messageMediaPhoto#695150d7 flags:# photo:flags.0?Photo ttl_seconds:flags.2?int = MessageMedia; +messageMediaPhoto#695150d7 flags:# spoiler:flags.3?true photo:flags.0?Photo ttl_seconds:flags.2?int = MessageMedia; messageMediaGeo#56e0d474 geo:GeoPoint = MessageMedia; @@ -196,7 +196,7 @@ messageMediaContact#70322949 phone_number:string first_name:string last_name:str messageMediaUnsupported#9f84f49e = MessageMedia; -messageMediaDocument#9cb070d7 flags:# nopremium:flags.3?true document:flags.0?Document ttl_seconds:flags.2?int = MessageMedia; +messageMediaDocument#9cb070d7 flags:# nopremium:flags.3?true spoiler:flags.4?true document:flags.0?Document ttl_seconds:flags.2?int = MessageMedia; messageMediaWebPage#a32dd600 webpage:WebPage = MessageMedia; @@ -282,6 +282,10 @@ messageActionTopicCreate#d999256 flags:# title:string icon_color:int icon_emoji_ messageActionTopicEdit#c0944820 flags:# title:flags.0?string icon_emoji_id:flags.1?long closed:flags.2?Bool hidden:flags.3?Bool = MessageAction; +messageActionSuggestProfilePhoto#57de635e photo:Photo = MessageAction; + +messageActionAttachMenuBotAllowed#e7e75f97 = MessageAction; + dialog#d58a08c6 flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int ttl_period:flags.5?int = Dialog; dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog; @@ -354,7 +358,7 @@ inputReportReasonIllegalDrugs#a8eb2be = ReportReason; inputReportReasonPersonalDetails#9ec7863d = ReportReason; -userFull#c4b1fc3f flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true id:long about:flags.1?string settings:PeerSettings profile_photo:flags.2?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector = UserFull; +userFull#f8d32aed flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector = UserFull; contact#145ade0b user_id:long mutual:Bool = Contact; @@ -444,8 +448,6 @@ updateUserStatus#e5bdf8de user_id:long status:UserStatus = Update; updateUserName#a7848924 user_id:long first_name:string last_name:string usernames:Vector = Update; -updateUserPhoto#f227868c user_id:long date:int photo:UserProfilePhoto previous:Bool = Update; - updateNewEncryptedMessage#12bcbd9a message:EncryptedMessage qts:int = Update; updateEncryptedChatTyping#1710f156 chat_id:int = Update; @@ -646,6 +648,8 @@ updateChannelPinnedTopic#192efbe3 flags:# pinned:flags.0?true channel_id:long to updateChannelPinnedTopics#fe198602 flags:# channel_id:long order:flags.0?Vector = Update; +updateUser#20529438 user_id:long = 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; @@ -872,7 +876,7 @@ documentAttributeFilename#15590068 file_name:string = DocumentAttribute; documentAttributeHasStickers#9801d2f7 = DocumentAttribute; -documentAttributeCustomEmoji#fd149899 flags:# free:flags.0?true alt:string stickerset:InputStickerSet = DocumentAttribute; +documentAttributeCustomEmoji#fd149899 flags:# free:flags.0?true text_color:flags.1?true alt:string stickerset:InputStickerSet = DocumentAttribute; messages.stickersNotModified#f1749a22 = messages.Stickers; @@ -984,7 +988,7 @@ replyKeyboardHide#a03e5b85 flags:# selective:flags.2?true = ReplyMarkup; replyKeyboardForceReply#86b40b08 flags:# single_use:flags.1?true selective:flags.2?true placeholder:flags.3?string = ReplyMarkup; -replyKeyboardMarkup#85dd99d1 flags:# resize:flags.0?true single_use:flags.1?true selective:flags.2?true rows:Vector placeholder:flags.3?string = ReplyMarkup; +replyKeyboardMarkup#85dd99d1 flags:# resize:flags.0?true single_use:flags.1?true selective:flags.2?true persistent:flags.4?true rows:Vector placeholder:flags.3?string = ReplyMarkup; replyInlineMarkup#48a30254 rows:Vector = ReplyMarkup; @@ -1222,6 +1226,8 @@ stickerSetMultiCovered#3407e51b set:StickerSet covers:Vector = Sticker stickerSetFullCovered#40d13c0e set:StickerSet packs:Vector keywords:Vector documents:Vector = StickerSetCovered; +stickerSetNoCovered#77b15d1c set:StickerSet = StickerSetCovered; + maskCoords#aed6dbb2 n:int x:double y:double zoom:double = MaskCoords; inputStickeredMediaPhoto#4a992157 id:InputPhoto = InputStickeredMedia; @@ -2016,7 +2022,7 @@ attachMenuBotIconColor#4576f3f0 name:string color:int = AttachMenuBotIconColor; attachMenuBotIcon#b2a7386b flags:# name:string icon:Document colors:flags.0?Vector = AttachMenuBotIcon; -attachMenuBot#c8aa2cd2 flags:# inactive:flags.0?true has_settings:flags.1?true bot_id:long short_name:string peer_types:Vector icons:Vector = AttachMenuBot; +attachMenuBot#c8aa2cd2 flags:# inactive:flags.0?true has_settings:flags.1?true request_write_access:flags.2?true bot_id:long short_name:string peer_types:Vector icons:Vector = AttachMenuBot; attachMenuBotsNotModified#f1d88a5c = AttachMenuBots; @@ -2739,7 +2745,7 @@ messages.getAttachMenuBots#16fcc2cb hash:long = AttachMenuBots; messages.getAttachMenuBot#77216192 bot:InputUser = AttachMenuBotsBot; -messages.toggleBotInAttachMenu#1aee33af bot:InputUser enabled:Bool = Bool; +messages.toggleBotInAttachMenu#69f59d69 flags:# write_allowed:flags.0?true bot:InputUser enabled:Bool = Bool; messages.requestWebView#178b480b flags:# from_bot_menu:flags.4?true silent:flags.5?true peer:InputPeer bot:InputUser url:flags.1?string start_param:flags.3?string theme_params:flags.2?DataJSON platform:string reply_to_msg_id:flags.0?int top_msg_id:flags.9?int send_as:flags.13?InputPeer = WebViewResult; @@ -2781,14 +2787,16 @@ updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date: updates.getChannelDifference#3173d78 flags:# force:flags.0?true channel:InputChannel filter:ChannelMessagesFilter pts:int limit:int = updates.ChannelDifference; -photos.updateProfilePhoto#72d4742c id:InputPhoto = photos.Photo; +photos.updateProfilePhoto#1c3d5956 flags:# fallback:flags.0?true id:InputPhoto = photos.Photo; -photos.uploadProfilePhoto#89f30f69 flags:# file:flags.0?InputFile video:flags.1?InputFile video_start_ts:flags.2?double = photos.Photo; +photos.uploadProfilePhoto#89f30f69 flags:# fallback:flags.3?true file:flags.0?InputFile video:flags.1?InputFile video_start_ts:flags.2?double = photos.Photo; photos.deletePhotos#87cf7f2f id:Vector = Vector; photos.getUserPhotos#91cd32a8 user_id:InputUser offset:int max_id:long limit:int = photos.Photos; +photos.uploadContactProfilePhoto#b91a83bf flags:# suggest:flags.3?true save:flags.4?true user_id:InputUser file:flags.0?InputFile video:flags.1?InputFile video_start_ts:flags.2?double = photos.Photo; + upload.saveFilePart#b304a621 file_id:long file_part:int bytes:bytes = Bool; upload.getFile#be5335be flags:# precise:flags.0?true cdn_supported:flags.1?true location:InputFileLocation offset:long limit:int = upload.File; @@ -2959,6 +2967,8 @@ channels.toggleAntiSpam#68f3e4eb channel:InputChannel enabled:Bool = Updates; channels.reportAntiSpamFalsePositive#a850a693 channel:InputChannel msg_id:int = Bool; +channels.toggleParticipantsHidden#6a6e7854 channel:InputChannel enabled:Bool = Updates; + bots.sendCustomRequest#aa2769ed custom_method:string params:DataJSON = DataJSON; bots.answerWebhookJSONQuery#e6213f4d query_id:long data:DataJSON = Bool; @@ -3099,4 +3109,4 @@ stats.getMessagePublicForwards#5630281b channel:InputChannel msg_id:int offset_r stats.getMessageStats#b6e0a3f5 flags:# dark:flags.0?true channel:InputChannel msg_id:int = stats.MessageStats; -// LAYER 150 +// LAYER 151 diff --git a/_schema/telegram.tl b/_schema/telegram.tl index efce0d734c..124bed54e7 100644 --- a/_schema/telegram.tl +++ b/_schema/telegram.tl @@ -2,8 +2,8 @@ // // Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/Resources/tl/api.tl // Merge: _schema/legacy.tl -// Layer: 150 -// SHA256: 16379ae5b0f59f8a9aa17d9f8289db7a61869ad5acddf74cd07fcac7e5f91d5e +// Layer: 151 +// SHA256: 53b88e0873d7e5c9aab54d9d0b8ef4d4eaa15dde37e1df618c361206bf9c53eb boolFalse#bc799737 = Bool; @@ -45,23 +45,23 @@ inputFileBig#fa4f0bb5 id:long parts:int name:string = InputFile; inputMediaEmpty#9664f57f = InputMedia; -inputMediaUploadedPhoto#1e287d04 flags:# file:InputFile stickers:flags.0?Vector ttl_seconds:flags.1?int = InputMedia; +inputMediaUploadedPhoto#1e287d04 flags:# spoiler:flags.2?true file:InputFile stickers:flags.0?Vector ttl_seconds:flags.1?int = InputMedia; -inputMediaPhoto#b3ba0635 flags:# id:InputPhoto ttl_seconds:flags.0?int = InputMedia; +inputMediaPhoto#b3ba0635 flags:# spoiler:flags.1?true id:InputPhoto ttl_seconds:flags.0?int = InputMedia; inputMediaGeoPoint#f9c44144 geo_point:InputGeoPoint = InputMedia; inputMediaContact#f8ab7dfb phone_number:string first_name:string last_name:string vcard:string = InputMedia; -inputMediaUploadedDocument#5b38c6c1 flags:# nosound_video:flags.3?true force_file:flags.4?true file:InputFile thumb:flags.2?InputFile mime_type:string attributes:Vector stickers:flags.0?Vector ttl_seconds:flags.1?int = InputMedia; +inputMediaUploadedDocument#5b38c6c1 flags:# nosound_video:flags.3?true force_file:flags.4?true spoiler:flags.5?true file:InputFile thumb:flags.2?InputFile mime_type:string attributes:Vector stickers:flags.0?Vector ttl_seconds:flags.1?int = InputMedia; -inputMediaDocument#33473058 flags:# id:InputDocument ttl_seconds:flags.0?int query:flags.1?string = InputMedia; +inputMediaDocument#33473058 flags:# spoiler:flags.2?true id:InputDocument ttl_seconds:flags.0?int query:flags.1?string = InputMedia; inputMediaVenue#c13d1c11 geo_point:InputGeoPoint title:string address:string provider:string venue_id:string venue_type:string = InputMedia; -inputMediaPhotoExternal#e5bbfe1a flags:# url:string ttl_seconds:flags.0?int = InputMedia; +inputMediaPhotoExternal#e5bbfe1a flags:# spoiler:flags.1?true url:string ttl_seconds:flags.0?int = InputMedia; -inputMediaDocumentExternal#fb52dc99 flags:# url:string ttl_seconds:flags.0?int = InputMedia; +inputMediaDocumentExternal#fb52dc99 flags:# spoiler:flags.1?true url:string ttl_seconds:flags.0?int = InputMedia; inputMediaGame#d33f43f3 id:InputGame = InputMedia; @@ -139,7 +139,7 @@ user#8f97c628 flags:# self:flags.10?true contact:flags.11?true mutual_contact:fl userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto; -userProfilePhoto#82d1f706 flags:# has_video:flags.0?true photo_id:long stripped_thumb:flags.1?bytes dc_id:int = UserProfilePhoto; +userProfilePhoto#82d1f706 flags:# has_video:flags.0?true personal:flags.2?true photo_id:long stripped_thumb:flags.1?bytes dc_id:int = UserProfilePhoto; userStatusEmpty#9d05049 = UserStatus; @@ -165,7 +165,7 @@ channelForbidden#17d493d5 flags:# broadcast:flags.5?true megagroup:flags.8?true chatFull#c9d31138 flags:# can_set_username:flags.7?true has_scheduled:flags.8?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector available_reactions:flags.18?ChatReactions = ChatFull; -channelFull#f2355507 flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true antispam:flags2.1?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions = ChatFull; +channelFull#f2355507 flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true antispam:flags2.1?true participants_hidden:flags2.2?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions = ChatFull; chatParticipant#c02d4007 user_id:long inviter_id:long date:int = ChatParticipant; @@ -189,7 +189,7 @@ messageService#2b085862 flags:# out:flags.1?true mentioned:flags.4?true media_un messageMediaEmpty#3ded6320 = MessageMedia; -messageMediaPhoto#695150d7 flags:# photo:flags.0?Photo ttl_seconds:flags.2?int = MessageMedia; +messageMediaPhoto#695150d7 flags:# spoiler:flags.3?true photo:flags.0?Photo ttl_seconds:flags.2?int = MessageMedia; messageMediaGeo#56e0d474 geo:GeoPoint = MessageMedia; @@ -197,7 +197,7 @@ messageMediaContact#70322949 phone_number:string first_name:string last_name:str messageMediaUnsupported#9f84f49e = MessageMedia; -messageMediaDocument#9cb070d7 flags:# nopremium:flags.3?true document:flags.0?Document ttl_seconds:flags.2?int = MessageMedia; +messageMediaDocument#9cb070d7 flags:# nopremium:flags.3?true spoiler:flags.4?true document:flags.0?Document ttl_seconds:flags.2?int = MessageMedia; messageMediaWebPage#a32dd600 webpage:WebPage = MessageMedia; @@ -283,6 +283,10 @@ messageActionTopicCreate#d999256 flags:# title:string icon_color:int icon_emoji_ messageActionTopicEdit#c0944820 flags:# title:flags.0?string icon_emoji_id:flags.1?long closed:flags.2?Bool hidden:flags.3?Bool = MessageAction; +messageActionSuggestProfilePhoto#57de635e photo:Photo = MessageAction; + +messageActionAttachMenuBotAllowed#e7e75f97 = MessageAction; + dialog#d58a08c6 flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int ttl_period:flags.5?int = Dialog; dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog; @@ -355,7 +359,7 @@ inputReportReasonIllegalDrugs#a8eb2be = ReportReason; inputReportReasonPersonalDetails#9ec7863d = ReportReason; -userFull#c4b1fc3f flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true id:long about:flags.1?string settings:PeerSettings profile_photo:flags.2?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector = UserFull; +userFull#f8d32aed flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector = UserFull; contact#145ade0b user_id:long mutual:Bool = Contact; @@ -445,8 +449,6 @@ updateUserStatus#e5bdf8de user_id:long status:UserStatus = Update; updateUserName#a7848924 user_id:long first_name:string last_name:string usernames:Vector = Update; -updateUserPhoto#f227868c user_id:long date:int photo:UserProfilePhoto previous:Bool = Update; - updateNewEncryptedMessage#12bcbd9a message:EncryptedMessage qts:int = Update; updateEncryptedChatTyping#1710f156 chat_id:int = Update; @@ -647,6 +649,8 @@ updateChannelPinnedTopic#192efbe3 flags:# pinned:flags.0?true channel_id:long to updateChannelPinnedTopics#fe198602 flags:# channel_id:long order:flags.0?Vector = Update; +updateUser#20529438 user_id:long = 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; @@ -873,7 +877,7 @@ documentAttributeFilename#15590068 file_name:string = DocumentAttribute; documentAttributeHasStickers#9801d2f7 = DocumentAttribute; -documentAttributeCustomEmoji#fd149899 flags:# free:flags.0?true alt:string stickerset:InputStickerSet = DocumentAttribute; +documentAttributeCustomEmoji#fd149899 flags:# free:flags.0?true text_color:flags.1?true alt:string stickerset:InputStickerSet = DocumentAttribute; messages.stickersNotModified#f1749a22 = messages.Stickers; @@ -985,7 +989,7 @@ replyKeyboardHide#a03e5b85 flags:# selective:flags.2?true = ReplyMarkup; replyKeyboardForceReply#86b40b08 flags:# single_use:flags.1?true selective:flags.2?true placeholder:flags.3?string = ReplyMarkup; -replyKeyboardMarkup#85dd99d1 flags:# resize:flags.0?true single_use:flags.1?true selective:flags.2?true rows:Vector placeholder:flags.3?string = ReplyMarkup; +replyKeyboardMarkup#85dd99d1 flags:# resize:flags.0?true single_use:flags.1?true selective:flags.2?true persistent:flags.4?true rows:Vector placeholder:flags.3?string = ReplyMarkup; replyInlineMarkup#48a30254 rows:Vector = ReplyMarkup; @@ -1223,6 +1227,8 @@ stickerSetMultiCovered#3407e51b set:StickerSet covers:Vector = Sticker stickerSetFullCovered#40d13c0e set:StickerSet packs:Vector keywords:Vector documents:Vector = StickerSetCovered; +stickerSetNoCovered#77b15d1c set:StickerSet = StickerSetCovered; + maskCoords#aed6dbb2 n:int x:double y:double zoom:double = MaskCoords; inputStickeredMediaPhoto#4a992157 id:InputPhoto = InputStickeredMedia; @@ -2017,7 +2023,7 @@ attachMenuBotIconColor#4576f3f0 name:string color:int = AttachMenuBotIconColor; attachMenuBotIcon#b2a7386b flags:# name:string icon:Document colors:flags.0?Vector = AttachMenuBotIcon; -attachMenuBot#c8aa2cd2 flags:# inactive:flags.0?true has_settings:flags.1?true bot_id:long short_name:string peer_types:Vector icons:Vector = AttachMenuBot; +attachMenuBot#c8aa2cd2 flags:# inactive:flags.0?true has_settings:flags.1?true request_write_access:flags.2?true bot_id:long short_name:string peer_types:Vector icons:Vector = AttachMenuBot; attachMenuBotsNotModified#f1d88a5c = AttachMenuBots; @@ -2740,7 +2746,7 @@ messages.getAttachMenuBots#16fcc2cb hash:long = AttachMenuBots; messages.getAttachMenuBot#77216192 bot:InputUser = AttachMenuBotsBot; -messages.toggleBotInAttachMenu#1aee33af bot:InputUser enabled:Bool = Bool; +messages.toggleBotInAttachMenu#69f59d69 flags:# write_allowed:flags.0?true bot:InputUser enabled:Bool = Bool; messages.requestWebView#178b480b flags:# from_bot_menu:flags.4?true silent:flags.5?true peer:InputPeer bot:InputUser url:flags.1?string start_param:flags.3?string theme_params:flags.2?DataJSON platform:string reply_to_msg_id:flags.0?int top_msg_id:flags.9?int send_as:flags.13?InputPeer = WebViewResult; @@ -2782,14 +2788,16 @@ updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date: updates.getChannelDifference#3173d78 flags:# force:flags.0?true channel:InputChannel filter:ChannelMessagesFilter pts:int limit:int = updates.ChannelDifference; -photos.updateProfilePhoto#72d4742c id:InputPhoto = photos.Photo; +photos.updateProfilePhoto#1c3d5956 flags:# fallback:flags.0?true id:InputPhoto = photos.Photo; -photos.uploadProfilePhoto#89f30f69 flags:# file:flags.0?InputFile video:flags.1?InputFile video_start_ts:flags.2?double = photos.Photo; +photos.uploadProfilePhoto#89f30f69 flags:# fallback:flags.3?true file:flags.0?InputFile video:flags.1?InputFile video_start_ts:flags.2?double = photos.Photo; photos.deletePhotos#87cf7f2f id:Vector = Vector; photos.getUserPhotos#91cd32a8 user_id:InputUser offset:int max_id:long limit:int = photos.Photos; +photos.uploadContactProfilePhoto#b91a83bf flags:# suggest:flags.3?true save:flags.4?true user_id:InputUser file:flags.0?InputFile video:flags.1?InputFile video_start_ts:flags.2?double = photos.Photo; + upload.saveFilePart#b304a621 file_id:long file_part:int bytes:bytes = Bool; upload.getFile#be5335be flags:# precise:flags.0?true cdn_supported:flags.1?true location:InputFileLocation offset:long limit:int = upload.File; @@ -2960,6 +2968,8 @@ channels.toggleAntiSpam#68f3e4eb channel:InputChannel enabled:Bool = Updates; channels.reportAntiSpamFalsePositive#a850a693 channel:InputChannel msg_id:int = Bool; +channels.toggleParticipantsHidden#6a6e7854 channel:InputChannel enabled:Bool = Updates; + bots.sendCustomRequest#aa2769ed custom_method:string params:DataJSON = DataJSON; bots.answerWebhookJSONQuery#e6213f4d query_id:long data:DataJSON = Bool; @@ -3132,4 +3142,4 @@ test.useError#ee75af01 = Error; test.useConfigSimple#f9b7b23d = help.ConfigSimple; -// LAYER 150 +// LAYER 151 diff --git a/tg/tl_attach_menu_bot_gen.go b/tg/tl_attach_menu_bot_gen.go index 43f2c3e380..4c365444d0 100644 --- a/tg/tl_attach_menu_bot_gen.go +++ b/tg/tl_attach_menu_bot_gen.go @@ -55,6 +55,8 @@ type AttachMenuBot struct { // Links: // 1) https://core.telegram.org/api/bots/webapps#settings-button-pressed HasSettings bool + // RequestWriteAccess field of AttachMenuBot. + RequestWriteAccess bool // Bot ID BotID int64 // Attachment menu item name @@ -89,6 +91,9 @@ func (a *AttachMenuBot) Zero() bool { if !(a.HasSettings == false) { return false } + if !(a.RequestWriteAccess == false) { + return false + } if !(a.BotID == 0) { return false } @@ -118,6 +123,7 @@ func (a *AttachMenuBot) String() string { func (a *AttachMenuBot) FillFrom(from interface { GetInactive() (value bool) GetHasSettings() (value bool) + GetRequestWriteAccess() (value bool) GetBotID() (value int64) GetShortName() (value string) GetPeerTypes() (value []AttachMenuPeerTypeClass) @@ -125,6 +131,7 @@ func (a *AttachMenuBot) FillFrom(from interface { }) { a.Inactive = from.GetInactive() a.HasSettings = from.GetHasSettings() + a.RequestWriteAccess = from.GetRequestWriteAccess() a.BotID = from.GetBotID() a.ShortName = from.GetShortName() a.PeerTypes = from.GetPeerTypes() @@ -164,6 +171,11 @@ func (a *AttachMenuBot) TypeInfo() tdp.Type { SchemaName: "has_settings", Null: !a.Flags.Has(1), }, + { + Name: "RequestWriteAccess", + SchemaName: "request_write_access", + Null: !a.Flags.Has(2), + }, { Name: "BotID", SchemaName: "bot_id", @@ -192,6 +204,9 @@ func (a *AttachMenuBot) SetFlags() { if !(a.HasSettings == false) { a.Flags.Set(1) } + if !(a.RequestWriteAccess == false) { + a.Flags.Set(2) + } } // Encode implements bin.Encoder. @@ -255,6 +270,7 @@ func (a *AttachMenuBot) DecodeBare(b *bin.Buffer) error { } a.Inactive = a.Flags.Has(0) a.HasSettings = a.Flags.Has(1) + a.RequestWriteAccess = a.Flags.Has(2) { value, err := b.Long() if err != nil { @@ -344,6 +360,25 @@ func (a *AttachMenuBot) GetHasSettings() (value bool) { return a.Flags.Has(1) } +// SetRequestWriteAccess sets value of RequestWriteAccess conditional field. +func (a *AttachMenuBot) SetRequestWriteAccess(value bool) { + if value { + a.Flags.Set(2) + a.RequestWriteAccess = true + } else { + a.Flags.Unset(2) + a.RequestWriteAccess = false + } +} + +// GetRequestWriteAccess returns value of RequestWriteAccess conditional field. +func (a *AttachMenuBot) GetRequestWriteAccess() (value bool) { + if a == nil { + return + } + return a.Flags.Has(2) +} + // GetBotID returns value of BotID field. func (a *AttachMenuBot) GetBotID() (value int64) { if a == nil { diff --git a/tg/tl_channels_toggle_participants_hidden_gen.go b/tg/tl_channels_toggle_participants_hidden_gen.go new file mode 100644 index 0000000000..a2a3a1e352 --- /dev/null +++ b/tg/tl_channels_toggle_participants_hidden_gen.go @@ -0,0 +1,210 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// ChannelsToggleParticipantsHiddenRequest represents TL type `channels.toggleParticipantsHidden#6a6e7854`. +// +// See https://core.telegram.org/method/channels.toggleParticipantsHidden for reference. +type ChannelsToggleParticipantsHiddenRequest struct { + // Channel field of ChannelsToggleParticipantsHiddenRequest. + Channel InputChannelClass + // Enabled field of ChannelsToggleParticipantsHiddenRequest. + Enabled bool +} + +// ChannelsToggleParticipantsHiddenRequestTypeID is TL type id of ChannelsToggleParticipantsHiddenRequest. +const ChannelsToggleParticipantsHiddenRequestTypeID = 0x6a6e7854 + +// Ensuring interfaces in compile-time for ChannelsToggleParticipantsHiddenRequest. +var ( + _ bin.Encoder = &ChannelsToggleParticipantsHiddenRequest{} + _ bin.Decoder = &ChannelsToggleParticipantsHiddenRequest{} + _ bin.BareEncoder = &ChannelsToggleParticipantsHiddenRequest{} + _ bin.BareDecoder = &ChannelsToggleParticipantsHiddenRequest{} +) + +func (t *ChannelsToggleParticipantsHiddenRequest) Zero() bool { + if t == nil { + return true + } + if !(t.Channel == nil) { + return false + } + if !(t.Enabled == false) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (t *ChannelsToggleParticipantsHiddenRequest) String() string { + if t == nil { + return "ChannelsToggleParticipantsHiddenRequest(nil)" + } + type Alias ChannelsToggleParticipantsHiddenRequest + return fmt.Sprintf("ChannelsToggleParticipantsHiddenRequest%+v", Alias(*t)) +} + +// FillFrom fills ChannelsToggleParticipantsHiddenRequest from given interface. +func (t *ChannelsToggleParticipantsHiddenRequest) FillFrom(from interface { + GetChannel() (value InputChannelClass) + GetEnabled() (value bool) +}) { + t.Channel = from.GetChannel() + t.Enabled = from.GetEnabled() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChannelsToggleParticipantsHiddenRequest) TypeID() uint32 { + return ChannelsToggleParticipantsHiddenRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChannelsToggleParticipantsHiddenRequest) TypeName() string { + return "channels.toggleParticipantsHidden" +} + +// TypeInfo returns info about TL type. +func (t *ChannelsToggleParticipantsHiddenRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "channels.toggleParticipantsHidden", + ID: ChannelsToggleParticipantsHiddenRequestTypeID, + } + if t == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Channel", + SchemaName: "channel", + }, + { + Name: "Enabled", + SchemaName: "enabled", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (t *ChannelsToggleParticipantsHiddenRequest) Encode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode channels.toggleParticipantsHidden#6a6e7854 as nil") + } + b.PutID(ChannelsToggleParticipantsHiddenRequestTypeID) + return t.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (t *ChannelsToggleParticipantsHiddenRequest) EncodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode channels.toggleParticipantsHidden#6a6e7854 as nil") + } + if t.Channel == nil { + return fmt.Errorf("unable to encode channels.toggleParticipantsHidden#6a6e7854: field channel is nil") + } + if err := t.Channel.Encode(b); err != nil { + return fmt.Errorf("unable to encode channels.toggleParticipantsHidden#6a6e7854: field channel: %w", err) + } + b.PutBool(t.Enabled) + return nil +} + +// Decode implements bin.Decoder. +func (t *ChannelsToggleParticipantsHiddenRequest) Decode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode channels.toggleParticipantsHidden#6a6e7854 to nil") + } + if err := b.ConsumeID(ChannelsToggleParticipantsHiddenRequestTypeID); err != nil { + return fmt.Errorf("unable to decode channels.toggleParticipantsHidden#6a6e7854: %w", err) + } + return t.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (t *ChannelsToggleParticipantsHiddenRequest) DecodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode channels.toggleParticipantsHidden#6a6e7854 to nil") + } + { + value, err := DecodeInputChannel(b) + if err != nil { + return fmt.Errorf("unable to decode channels.toggleParticipantsHidden#6a6e7854: field channel: %w", err) + } + t.Channel = value + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode channels.toggleParticipantsHidden#6a6e7854: field enabled: %w", err) + } + t.Enabled = value + } + return nil +} + +// GetChannel returns value of Channel field. +func (t *ChannelsToggleParticipantsHiddenRequest) GetChannel() (value InputChannelClass) { + if t == nil { + return + } + return t.Channel +} + +// GetEnabled returns value of Enabled field. +func (t *ChannelsToggleParticipantsHiddenRequest) GetEnabled() (value bool) { + if t == nil { + return + } + return t.Enabled +} + +// GetChannelAsNotEmpty returns mapped value of Channel field. +func (t *ChannelsToggleParticipantsHiddenRequest) GetChannelAsNotEmpty() (NotEmptyInputChannel, bool) { + return t.Channel.AsNotEmpty() +} + +// ChannelsToggleParticipantsHidden invokes method channels.toggleParticipantsHidden#6a6e7854 returning error if any. +// +// See https://core.telegram.org/method/channels.toggleParticipantsHidden for reference. +func (c *Client) ChannelsToggleParticipantsHidden(ctx context.Context, request *ChannelsToggleParticipantsHiddenRequest) (UpdatesClass, error) { + var result UpdatesBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.Updates, nil +} diff --git a/tg/tl_channels_toggle_participants_hidden_slices_gen.go b/tg/tl_channels_toggle_participants_hidden_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_channels_toggle_participants_hidden_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_chat_full_gen.go b/tg/tl_chat_full_gen.go index e3b87b9994..1f4b59716e 100644 --- a/tg/tl_chat_full_gen.go +++ b/tg/tl_chat_full_gen.go @@ -1039,6 +1039,8 @@ type ChannelFull struct { CanDeleteChannel bool // Antispam field of ChannelFull. Antispam bool + // ParticipantsHidden field of ChannelFull. + ParticipantsHidden bool // ID of the channel ID int64 // Info about the channel @@ -1259,6 +1261,9 @@ func (c *ChannelFull) Zero() bool { if !(c.Antispam == false) { return false } + if !(c.ParticipantsHidden == false) { + return false + } if !(c.ID == 0) { return false } @@ -1389,6 +1394,7 @@ func (c *ChannelFull) FillFrom(from interface { GetBlocked() (value bool) GetCanDeleteChannel() (value bool) GetAntispam() (value bool) + GetParticipantsHidden() (value bool) GetID() (value int64) GetAbout() (value string) GetParticipantsCount() (value int, ok bool) @@ -1435,6 +1441,7 @@ func (c *ChannelFull) FillFrom(from interface { c.Blocked = from.GetBlocked() c.CanDeleteChannel = from.GetCanDeleteChannel() c.Antispam = from.GetAntispam() + c.ParticipantsHidden = from.GetParticipantsHidden() c.ID = from.GetID() c.About = from.GetAbout() if val, ok := from.GetParticipantsCount(); ok { @@ -1623,6 +1630,11 @@ func (c *ChannelFull) TypeInfo() tdp.Type { SchemaName: "antispam", Null: !c.Flags2.Has(1), }, + { + Name: "ParticipantsHidden", + SchemaName: "participants_hidden", + Null: !c.Flags2.Has(2), + }, { Name: "ID", SchemaName: "id", @@ -1825,6 +1837,9 @@ func (c *ChannelFull) SetFlags() { if !(c.Antispam == false) { c.Flags2.Set(1) } + if !(c.ParticipantsHidden == false) { + c.Flags2.Set(2) + } if !(c.ParticipantsCount == 0) { c.Flags.Set(0) } @@ -2099,6 +2114,7 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { } c.CanDeleteChannel = c.Flags2.Has(0) c.Antispam = c.Flags2.Has(1) + c.ParticipantsHidden = c.Flags2.Has(2) { value, err := b.Long() if err != nil { @@ -2561,6 +2577,25 @@ func (c *ChannelFull) GetAntispam() (value bool) { return c.Flags2.Has(1) } +// SetParticipantsHidden sets value of ParticipantsHidden conditional field. +func (c *ChannelFull) SetParticipantsHidden(value bool) { + if value { + c.Flags2.Set(2) + c.ParticipantsHidden = true + } else { + c.Flags2.Unset(2) + c.ParticipantsHidden = false + } +} + +// GetParticipantsHidden returns value of ParticipantsHidden conditional field. +func (c *ChannelFull) GetParticipantsHidden() (value bool) { + if c == nil { + return + } + return c.Flags2.Has(2) +} + // GetID returns value of ID field. func (c *ChannelFull) GetID() (value int64) { if c == nil { diff --git a/tg/tl_document_attribute_gen.go b/tg/tl_document_attribute_gen.go index 47336dafa0..c6644729d5 100644 --- a/tg/tl_document_attribute_gen.go +++ b/tg/tl_document_attribute_gen.go @@ -1434,6 +1434,8 @@ type DocumentAttributeCustomEmoji struct { Flags bin.Fields // Whether this custom emoji can be sent by non-Premium users Free bool + // TextColor field of DocumentAttributeCustomEmoji. + TextColor bool // The actual emoji Alt string // The emoji stickerset to which this emoji belongs. @@ -1466,6 +1468,9 @@ func (d *DocumentAttributeCustomEmoji) Zero() bool { if !(d.Free == false) { return false } + if !(d.TextColor == false) { + return false + } if !(d.Alt == "") { return false } @@ -1488,10 +1493,12 @@ func (d *DocumentAttributeCustomEmoji) String() string { // FillFrom fills DocumentAttributeCustomEmoji from given interface. func (d *DocumentAttributeCustomEmoji) FillFrom(from interface { GetFree() (value bool) + GetTextColor() (value bool) GetAlt() (value string) GetStickerset() (value InputStickerSetClass) }) { d.Free = from.GetFree() + d.TextColor = from.GetTextColor() d.Alt = from.GetAlt() d.Stickerset = from.GetStickerset() } @@ -1524,6 +1531,11 @@ func (d *DocumentAttributeCustomEmoji) TypeInfo() tdp.Type { SchemaName: "free", Null: !d.Flags.Has(0), }, + { + Name: "TextColor", + SchemaName: "text_color", + Null: !d.Flags.Has(1), + }, { Name: "Alt", SchemaName: "alt", @@ -1541,6 +1553,9 @@ func (d *DocumentAttributeCustomEmoji) SetFlags() { if !(d.Free == false) { d.Flags.Set(0) } + if !(d.TextColor == false) { + d.Flags.Set(1) + } } // Encode implements bin.Encoder. @@ -1593,6 +1608,7 @@ func (d *DocumentAttributeCustomEmoji) DecodeBare(b *bin.Buffer) error { } } d.Free = d.Flags.Has(0) + d.TextColor = d.Flags.Has(1) { value, err := b.String() if err != nil { @@ -1629,6 +1645,25 @@ func (d *DocumentAttributeCustomEmoji) GetFree() (value bool) { return d.Flags.Has(0) } +// SetTextColor sets value of TextColor conditional field. +func (d *DocumentAttributeCustomEmoji) SetTextColor(value bool) { + if value { + d.Flags.Set(1) + d.TextColor = true + } else { + d.Flags.Unset(1) + d.TextColor = false + } +} + +// GetTextColor returns value of TextColor conditional field. +func (d *DocumentAttributeCustomEmoji) GetTextColor() (value bool) { + if d == nil { + return + } + return d.Flags.Has(1) +} + // GetAlt returns value of Alt field. func (d *DocumentAttributeCustomEmoji) GetAlt() (value string) { if d == nil { diff --git a/tg/tl_handlers_gen.go b/tg/tl_handlers_gen.go index 825e67e8b6..e1651b82da 100644 --- a/tg/tl_handlers_gen.go +++ b/tg/tl_handlers_gen.go @@ -186,16 +186,6 @@ func (u UpdateDispatcher) OnUserName(handler UserNameHandler) { } } -// UserPhotoHandler is a UserPhoto event handler. -type UserPhotoHandler func(ctx context.Context, e Entities, update *UpdateUserPhoto) error - -// OnUserPhoto sets UserPhoto handler. -func (u UpdateDispatcher) OnUserPhoto(handler UserPhotoHandler) { - u.handlers[UpdateUserPhotoTypeID] = func(ctx context.Context, e Entities, update UpdateClass) error { - return handler(ctx, e, update.(*UpdateUserPhoto)) - } -} - // NewEncryptedMessageHandler is a NewEncryptedMessage event handler. type NewEncryptedMessageHandler func(ctx context.Context, e Entities, update *UpdateNewEncryptedMessage) error @@ -1195,3 +1185,13 @@ func (u UpdateDispatcher) OnChannelPinnedTopics(handler ChannelPinnedTopicsHandl return handler(ctx, e, update.(*UpdateChannelPinnedTopics)) } } + +// UserHandler is a User event handler. +type UserHandler func(ctx context.Context, e Entities, update *UpdateUser) error + +// OnUser sets User handler. +func (u UpdateDispatcher) OnUser(handler UserHandler) { + u.handlers[UpdateUserTypeID] = func(ctx context.Context, e Entities, update UpdateClass) error { + return handler(ctx, e, update.(*UpdateUser)) + } +} diff --git a/tg/tl_input_media_gen.go b/tg/tl_input_media_gen.go index e2631dcc03..a9ee949d8a 100644 --- a/tg/tl_input_media_gen.go +++ b/tg/tl_input_media_gen.go @@ -143,6 +143,8 @@ type InputMediaUploadedPhoto struct { // Links: // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields Flags bin.Fields + // Spoiler field of InputMediaUploadedPhoto. + Spoiler bool // The uploaded file¹ // // Links: @@ -181,6 +183,9 @@ func (i *InputMediaUploadedPhoto) Zero() bool { if !(i.Flags.Zero()) { return false } + if !(i.Spoiler == false) { + return false + } if !(i.File == nil) { return false } @@ -205,10 +210,12 @@ func (i *InputMediaUploadedPhoto) String() string { // FillFrom fills InputMediaUploadedPhoto from given interface. func (i *InputMediaUploadedPhoto) FillFrom(from interface { + GetSpoiler() (value bool) GetFile() (value InputFileClass) GetStickers() (value []InputDocumentClass, ok bool) GetTTLSeconds() (value int, ok bool) }) { + i.Spoiler = from.GetSpoiler() i.File = from.GetFile() if val, ok := from.GetStickers(); ok { i.Stickers = val @@ -243,6 +250,11 @@ func (i *InputMediaUploadedPhoto) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "Spoiler", + SchemaName: "spoiler", + Null: !i.Flags.Has(2), + }, { Name: "File", SchemaName: "file", @@ -263,6 +275,9 @@ func (i *InputMediaUploadedPhoto) TypeInfo() tdp.Type { // SetFlags sets flags for non-zero fields. func (i *InputMediaUploadedPhoto) SetFlags() { + if !(i.Spoiler == false) { + i.Flags.Set(2) + } if !(i.Stickers == nil) { i.Flags.Set(0) } @@ -333,6 +348,7 @@ func (i *InputMediaUploadedPhoto) DecodeBare(b *bin.Buffer) error { return fmt.Errorf("unable to decode inputMediaUploadedPhoto#1e287d04: field flags: %w", err) } } + i.Spoiler = i.Flags.Has(2) { value, err := DecodeInputFile(b) if err != nil { @@ -367,6 +383,25 @@ func (i *InputMediaUploadedPhoto) DecodeBare(b *bin.Buffer) error { return nil } +// SetSpoiler sets value of Spoiler conditional field. +func (i *InputMediaUploadedPhoto) SetSpoiler(value bool) { + if value { + i.Flags.Set(2) + i.Spoiler = true + } else { + i.Flags.Unset(2) + i.Spoiler = false + } +} + +// GetSpoiler returns value of Spoiler conditional field. +func (i *InputMediaUploadedPhoto) GetSpoiler() (value bool) { + if i == nil { + return + } + return i.Flags.Has(2) +} + // GetFile returns value of File field. func (i *InputMediaUploadedPhoto) GetFile() (value InputFileClass) { if i == nil { @@ -429,6 +464,8 @@ type InputMediaPhoto struct { // Links: // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields Flags bin.Fields + // Spoiler field of InputMediaPhoto. + Spoiler bool // Photo to be forwarded ID InputPhotoClass // Time to live in seconds of self-destructing photo @@ -460,6 +497,9 @@ func (i *InputMediaPhoto) Zero() bool { if !(i.Flags.Zero()) { return false } + if !(i.Spoiler == false) { + return false + } if !(i.ID == nil) { return false } @@ -481,9 +521,11 @@ func (i *InputMediaPhoto) String() string { // FillFrom fills InputMediaPhoto from given interface. func (i *InputMediaPhoto) FillFrom(from interface { + GetSpoiler() (value bool) GetID() (value InputPhotoClass) GetTTLSeconds() (value int, ok bool) }) { + i.Spoiler = from.GetSpoiler() i.ID = from.GetID() if val, ok := from.GetTTLSeconds(); ok { i.TTLSeconds = val @@ -514,6 +556,11 @@ func (i *InputMediaPhoto) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "Spoiler", + SchemaName: "spoiler", + Null: !i.Flags.Has(1), + }, { Name: "ID", SchemaName: "id", @@ -529,6 +576,9 @@ func (i *InputMediaPhoto) TypeInfo() tdp.Type { // SetFlags sets flags for non-zero fields. func (i *InputMediaPhoto) SetFlags() { + if !(i.Spoiler == false) { + i.Flags.Set(1) + } if !(i.TTLSeconds == 0) { i.Flags.Set(0) } @@ -585,6 +635,7 @@ func (i *InputMediaPhoto) DecodeBare(b *bin.Buffer) error { return fmt.Errorf("unable to decode inputMediaPhoto#b3ba0635: field flags: %w", err) } } + i.Spoiler = i.Flags.Has(1) { value, err := DecodeInputPhoto(b) if err != nil { @@ -602,6 +653,25 @@ func (i *InputMediaPhoto) DecodeBare(b *bin.Buffer) error { return nil } +// SetSpoiler sets value of Spoiler conditional field. +func (i *InputMediaPhoto) SetSpoiler(value bool) { + if value { + i.Flags.Set(1) + i.Spoiler = true + } else { + i.Flags.Unset(1) + i.Spoiler = false + } +} + +// GetSpoiler returns value of Spoiler conditional field. +func (i *InputMediaPhoto) GetSpoiler() (value bool) { + if i == nil { + return + } + return i.Flags.Has(1) +} + // GetID returns value of ID field. func (i *InputMediaPhoto) GetID() (value InputPhotoClass) { if i == nil { @@ -999,6 +1069,8 @@ type InputMediaUploadedDocument struct { NosoundVideo bool // Force the media file to be uploaded as document ForceFile bool + // Spoiler field of InputMediaUploadedDocument. + Spoiler bool // The uploaded file¹ // // Links: @@ -1051,6 +1123,9 @@ func (i *InputMediaUploadedDocument) Zero() bool { if !(i.ForceFile == false) { return false } + if !(i.Spoiler == false) { + return false + } if !(i.File == nil) { return false } @@ -1086,6 +1161,7 @@ func (i *InputMediaUploadedDocument) String() string { func (i *InputMediaUploadedDocument) FillFrom(from interface { GetNosoundVideo() (value bool) GetForceFile() (value bool) + GetSpoiler() (value bool) GetFile() (value InputFileClass) GetThumb() (value InputFileClass, ok bool) GetMimeType() (value string) @@ -1095,6 +1171,7 @@ func (i *InputMediaUploadedDocument) FillFrom(from interface { }) { i.NosoundVideo = from.GetNosoundVideo() i.ForceFile = from.GetForceFile() + i.Spoiler = from.GetSpoiler() i.File = from.GetFile() if val, ok := from.GetThumb(); ok { i.Thumb = val @@ -1145,6 +1222,11 @@ func (i *InputMediaUploadedDocument) TypeInfo() tdp.Type { SchemaName: "force_file", Null: !i.Flags.Has(4), }, + { + Name: "Spoiler", + SchemaName: "spoiler", + Null: !i.Flags.Has(5), + }, { Name: "File", SchemaName: "file", @@ -1184,6 +1266,9 @@ func (i *InputMediaUploadedDocument) SetFlags() { if !(i.ForceFile == false) { i.Flags.Set(4) } + if !(i.Spoiler == false) { + i.Flags.Set(5) + } if !(i.Thumb == nil) { i.Flags.Set(2) } @@ -1277,6 +1362,7 @@ func (i *InputMediaUploadedDocument) DecodeBare(b *bin.Buffer) error { } i.NosoundVideo = i.Flags.Has(3) i.ForceFile = i.Flags.Has(4) + i.Spoiler = i.Flags.Has(5) { value, err := DecodeInputFile(b) if err != nil { @@ -1380,6 +1466,25 @@ func (i *InputMediaUploadedDocument) GetForceFile() (value bool) { return i.Flags.Has(4) } +// SetSpoiler sets value of Spoiler conditional field. +func (i *InputMediaUploadedDocument) SetSpoiler(value bool) { + if value { + i.Flags.Set(5) + i.Spoiler = true + } else { + i.Flags.Unset(5) + i.Spoiler = false + } +} + +// GetSpoiler returns value of Spoiler conditional field. +func (i *InputMediaUploadedDocument) GetSpoiler() (value bool) { + if i == nil { + return + } + return i.Flags.Has(5) +} + // GetFile returns value of File field. func (i *InputMediaUploadedDocument) GetFile() (value InputFileClass) { if i == nil { @@ -1481,6 +1586,8 @@ type InputMediaDocument struct { // Links: // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields Flags bin.Fields + // Spoiler field of InputMediaDocument. + Spoiler bool // The document to be forwarded. ID InputDocumentClass // Time to live of self-destructing document @@ -1517,6 +1624,9 @@ func (i *InputMediaDocument) Zero() bool { if !(i.Flags.Zero()) { return false } + if !(i.Spoiler == false) { + return false + } if !(i.ID == nil) { return false } @@ -1541,10 +1651,12 @@ func (i *InputMediaDocument) String() string { // FillFrom fills InputMediaDocument from given interface. func (i *InputMediaDocument) FillFrom(from interface { + GetSpoiler() (value bool) GetID() (value InputDocumentClass) GetTTLSeconds() (value int, ok bool) GetQuery() (value string, ok bool) }) { + i.Spoiler = from.GetSpoiler() i.ID = from.GetID() if val, ok := from.GetTTLSeconds(); ok { i.TTLSeconds = val @@ -1579,6 +1691,11 @@ func (i *InputMediaDocument) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "Spoiler", + SchemaName: "spoiler", + Null: !i.Flags.Has(2), + }, { Name: "ID", SchemaName: "id", @@ -1599,6 +1716,9 @@ func (i *InputMediaDocument) TypeInfo() tdp.Type { // SetFlags sets flags for non-zero fields. func (i *InputMediaDocument) SetFlags() { + if !(i.Spoiler == false) { + i.Flags.Set(2) + } if !(i.TTLSeconds == 0) { i.Flags.Set(0) } @@ -1661,6 +1781,7 @@ func (i *InputMediaDocument) DecodeBare(b *bin.Buffer) error { return fmt.Errorf("unable to decode inputMediaDocument#33473058: field flags: %w", err) } } + i.Spoiler = i.Flags.Has(2) { value, err := DecodeInputDocument(b) if err != nil { @@ -1685,6 +1806,25 @@ func (i *InputMediaDocument) DecodeBare(b *bin.Buffer) error { return nil } +// SetSpoiler sets value of Spoiler conditional field. +func (i *InputMediaDocument) SetSpoiler(value bool) { + if value { + i.Flags.Set(2) + i.Spoiler = true + } else { + i.Flags.Unset(2) + i.Spoiler = false + } +} + +// GetSpoiler returns value of Spoiler conditional field. +func (i *InputMediaDocument) GetSpoiler() (value bool) { + if i == nil { + return + } + return i.Flags.Has(2) +} + // GetID returns value of ID field. func (i *InputMediaDocument) GetID() (value InputDocumentClass) { if i == nil { @@ -2014,6 +2154,8 @@ type InputMediaPhotoExternal struct { // Links: // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields Flags bin.Fields + // Spoiler field of InputMediaPhotoExternal. + Spoiler bool // URL of the photo URL string // Self-destruct time to live of photo @@ -2045,6 +2187,9 @@ func (i *InputMediaPhotoExternal) Zero() bool { if !(i.Flags.Zero()) { return false } + if !(i.Spoiler == false) { + return false + } if !(i.URL == "") { return false } @@ -2066,9 +2211,11 @@ func (i *InputMediaPhotoExternal) String() string { // FillFrom fills InputMediaPhotoExternal from given interface. func (i *InputMediaPhotoExternal) FillFrom(from interface { + GetSpoiler() (value bool) GetURL() (value string) GetTTLSeconds() (value int, ok bool) }) { + i.Spoiler = from.GetSpoiler() i.URL = from.GetURL() if val, ok := from.GetTTLSeconds(); ok { i.TTLSeconds = val @@ -2099,6 +2246,11 @@ func (i *InputMediaPhotoExternal) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "Spoiler", + SchemaName: "spoiler", + Null: !i.Flags.Has(1), + }, { Name: "URL", SchemaName: "url", @@ -2114,6 +2266,9 @@ func (i *InputMediaPhotoExternal) TypeInfo() tdp.Type { // SetFlags sets flags for non-zero fields. func (i *InputMediaPhotoExternal) SetFlags() { + if !(i.Spoiler == false) { + i.Flags.Set(1) + } if !(i.TTLSeconds == 0) { i.Flags.Set(0) } @@ -2165,6 +2320,7 @@ func (i *InputMediaPhotoExternal) DecodeBare(b *bin.Buffer) error { return fmt.Errorf("unable to decode inputMediaPhotoExternal#e5bbfe1a: field flags: %w", err) } } + i.Spoiler = i.Flags.Has(1) { value, err := b.String() if err != nil { @@ -2182,6 +2338,25 @@ func (i *InputMediaPhotoExternal) DecodeBare(b *bin.Buffer) error { return nil } +// SetSpoiler sets value of Spoiler conditional field. +func (i *InputMediaPhotoExternal) SetSpoiler(value bool) { + if value { + i.Flags.Set(1) + i.Spoiler = true + } else { + i.Flags.Unset(1) + i.Spoiler = false + } +} + +// GetSpoiler returns value of Spoiler conditional field. +func (i *InputMediaPhotoExternal) GetSpoiler() (value bool) { + if i == nil { + return + } + return i.Flags.Has(1) +} + // GetURL returns value of URL field. func (i *InputMediaPhotoExternal) GetURL() (value string) { if i == nil { @@ -2218,6 +2393,8 @@ type InputMediaDocumentExternal struct { // Links: // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields Flags bin.Fields + // Spoiler field of InputMediaDocumentExternal. + Spoiler bool // URL of the document URL string // Self-destruct time to live of document @@ -2249,6 +2426,9 @@ func (i *InputMediaDocumentExternal) Zero() bool { if !(i.Flags.Zero()) { return false } + if !(i.Spoiler == false) { + return false + } if !(i.URL == "") { return false } @@ -2270,9 +2450,11 @@ func (i *InputMediaDocumentExternal) String() string { // FillFrom fills InputMediaDocumentExternal from given interface. func (i *InputMediaDocumentExternal) FillFrom(from interface { + GetSpoiler() (value bool) GetURL() (value string) GetTTLSeconds() (value int, ok bool) }) { + i.Spoiler = from.GetSpoiler() i.URL = from.GetURL() if val, ok := from.GetTTLSeconds(); ok { i.TTLSeconds = val @@ -2303,6 +2485,11 @@ func (i *InputMediaDocumentExternal) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "Spoiler", + SchemaName: "spoiler", + Null: !i.Flags.Has(1), + }, { Name: "URL", SchemaName: "url", @@ -2318,6 +2505,9 @@ func (i *InputMediaDocumentExternal) TypeInfo() tdp.Type { // SetFlags sets flags for non-zero fields. func (i *InputMediaDocumentExternal) SetFlags() { + if !(i.Spoiler == false) { + i.Flags.Set(1) + } if !(i.TTLSeconds == 0) { i.Flags.Set(0) } @@ -2369,6 +2559,7 @@ func (i *InputMediaDocumentExternal) DecodeBare(b *bin.Buffer) error { return fmt.Errorf("unable to decode inputMediaDocumentExternal#fb52dc99: field flags: %w", err) } } + i.Spoiler = i.Flags.Has(1) { value, err := b.String() if err != nil { @@ -2386,6 +2577,25 @@ func (i *InputMediaDocumentExternal) DecodeBare(b *bin.Buffer) error { return nil } +// SetSpoiler sets value of Spoiler conditional field. +func (i *InputMediaDocumentExternal) SetSpoiler(value bool) { + if value { + i.Flags.Set(1) + i.Spoiler = true + } else { + i.Flags.Unset(1) + i.Spoiler = false + } +} + +// GetSpoiler returns value of Spoiler conditional field. +func (i *InputMediaDocumentExternal) GetSpoiler() (value bool) { + if i == nil { + return + } + return i.Flags.Has(1) +} + // GetURL returns value of URL field. func (i *InputMediaDocumentExternal) GetURL() (value string) { if i == nil { diff --git a/tg/tl_message_action_gen.go b/tg/tl_message_action_gen.go index b42b100840..08cbdee37d 100644 --- a/tg/tl_message_action_gen.go +++ b/tg/tl_message_action_gen.go @@ -5981,6 +5981,246 @@ func (m *MessageActionTopicEdit) GetHidden() (value bool, ok bool) { return m.Hidden, true } +// MessageActionSuggestProfilePhoto represents TL type `messageActionSuggestProfilePhoto#57de635e`. +// +// See https://core.telegram.org/constructor/messageActionSuggestProfilePhoto for reference. +type MessageActionSuggestProfilePhoto struct { + // Photo field of MessageActionSuggestProfilePhoto. + Photo PhotoClass +} + +// MessageActionSuggestProfilePhotoTypeID is TL type id of MessageActionSuggestProfilePhoto. +const MessageActionSuggestProfilePhotoTypeID = 0x57de635e + +// construct implements constructor of MessageActionClass. +func (m MessageActionSuggestProfilePhoto) construct() MessageActionClass { return &m } + +// Ensuring interfaces in compile-time for MessageActionSuggestProfilePhoto. +var ( + _ bin.Encoder = &MessageActionSuggestProfilePhoto{} + _ bin.Decoder = &MessageActionSuggestProfilePhoto{} + _ bin.BareEncoder = &MessageActionSuggestProfilePhoto{} + _ bin.BareDecoder = &MessageActionSuggestProfilePhoto{} + + _ MessageActionClass = &MessageActionSuggestProfilePhoto{} +) + +func (m *MessageActionSuggestProfilePhoto) Zero() bool { + if m == nil { + return true + } + if !(m.Photo == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (m *MessageActionSuggestProfilePhoto) String() string { + if m == nil { + return "MessageActionSuggestProfilePhoto(nil)" + } + type Alias MessageActionSuggestProfilePhoto + return fmt.Sprintf("MessageActionSuggestProfilePhoto%+v", Alias(*m)) +} + +// FillFrom fills MessageActionSuggestProfilePhoto from given interface. +func (m *MessageActionSuggestProfilePhoto) FillFrom(from interface { + GetPhoto() (value PhotoClass) +}) { + m.Photo = from.GetPhoto() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessageActionSuggestProfilePhoto) TypeID() uint32 { + return MessageActionSuggestProfilePhotoTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessageActionSuggestProfilePhoto) TypeName() string { + return "messageActionSuggestProfilePhoto" +} + +// TypeInfo returns info about TL type. +func (m *MessageActionSuggestProfilePhoto) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messageActionSuggestProfilePhoto", + ID: MessageActionSuggestProfilePhotoTypeID, + } + if m == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Photo", + SchemaName: "photo", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (m *MessageActionSuggestProfilePhoto) Encode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionSuggestProfilePhoto#57de635e as nil") + } + b.PutID(MessageActionSuggestProfilePhotoTypeID) + return m.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (m *MessageActionSuggestProfilePhoto) EncodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionSuggestProfilePhoto#57de635e as nil") + } + if m.Photo == nil { + return fmt.Errorf("unable to encode messageActionSuggestProfilePhoto#57de635e: field photo is nil") + } + if err := m.Photo.Encode(b); err != nil { + return fmt.Errorf("unable to encode messageActionSuggestProfilePhoto#57de635e: field photo: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (m *MessageActionSuggestProfilePhoto) Decode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionSuggestProfilePhoto#57de635e to nil") + } + if err := b.ConsumeID(MessageActionSuggestProfilePhotoTypeID); err != nil { + return fmt.Errorf("unable to decode messageActionSuggestProfilePhoto#57de635e: %w", err) + } + return m.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (m *MessageActionSuggestProfilePhoto) DecodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionSuggestProfilePhoto#57de635e to nil") + } + { + value, err := DecodePhoto(b) + if err != nil { + return fmt.Errorf("unable to decode messageActionSuggestProfilePhoto#57de635e: field photo: %w", err) + } + m.Photo = value + } + return nil +} + +// GetPhoto returns value of Photo field. +func (m *MessageActionSuggestProfilePhoto) GetPhoto() (value PhotoClass) { + if m == nil { + return + } + return m.Photo +} + +// MessageActionAttachMenuBotAllowed represents TL type `messageActionAttachMenuBotAllowed#e7e75f97`. +// +// See https://core.telegram.org/constructor/messageActionAttachMenuBotAllowed for reference. +type MessageActionAttachMenuBotAllowed struct { +} + +// MessageActionAttachMenuBotAllowedTypeID is TL type id of MessageActionAttachMenuBotAllowed. +const MessageActionAttachMenuBotAllowedTypeID = 0xe7e75f97 + +// construct implements constructor of MessageActionClass. +func (m MessageActionAttachMenuBotAllowed) construct() MessageActionClass { return &m } + +// Ensuring interfaces in compile-time for MessageActionAttachMenuBotAllowed. +var ( + _ bin.Encoder = &MessageActionAttachMenuBotAllowed{} + _ bin.Decoder = &MessageActionAttachMenuBotAllowed{} + _ bin.BareEncoder = &MessageActionAttachMenuBotAllowed{} + _ bin.BareDecoder = &MessageActionAttachMenuBotAllowed{} + + _ MessageActionClass = &MessageActionAttachMenuBotAllowed{} +) + +func (m *MessageActionAttachMenuBotAllowed) Zero() bool { + if m == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (m *MessageActionAttachMenuBotAllowed) String() string { + if m == nil { + return "MessageActionAttachMenuBotAllowed(nil)" + } + type Alias MessageActionAttachMenuBotAllowed + return fmt.Sprintf("MessageActionAttachMenuBotAllowed%+v", Alias(*m)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessageActionAttachMenuBotAllowed) TypeID() uint32 { + return MessageActionAttachMenuBotAllowedTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessageActionAttachMenuBotAllowed) TypeName() string { + return "messageActionAttachMenuBotAllowed" +} + +// TypeInfo returns info about TL type. +func (m *MessageActionAttachMenuBotAllowed) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messageActionAttachMenuBotAllowed", + ID: MessageActionAttachMenuBotAllowedTypeID, + } + if m == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (m *MessageActionAttachMenuBotAllowed) Encode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionAttachMenuBotAllowed#e7e75f97 as nil") + } + b.PutID(MessageActionAttachMenuBotAllowedTypeID) + return m.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (m *MessageActionAttachMenuBotAllowed) EncodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionAttachMenuBotAllowed#e7e75f97 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (m *MessageActionAttachMenuBotAllowed) Decode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionAttachMenuBotAllowed#e7e75f97 to nil") + } + if err := b.ConsumeID(MessageActionAttachMenuBotAllowedTypeID); err != nil { + return fmt.Errorf("unable to decode messageActionAttachMenuBotAllowed#e7e75f97: %w", err) + } + return m.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (m *MessageActionAttachMenuBotAllowed) DecodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionAttachMenuBotAllowed#e7e75f97 to nil") + } + return nil +} + // MessageActionClassName is schema name of MessageActionClass. const MessageActionClassName = "MessageAction" @@ -6030,6 +6270,8 @@ const MessageActionClassName = "MessageAction" // case *tg.MessageActionGiftPremium: // messageActionGiftPremium#aba0f5c6 // case *tg.MessageActionTopicCreate: // messageActionTopicCreate#d999256 // case *tg.MessageActionTopicEdit: // messageActionTopicEdit#c0944820 +// case *tg.MessageActionSuggestProfilePhoto: // messageActionSuggestProfilePhoto#57de635e +// case *tg.MessageActionAttachMenuBotAllowed: // messageActionAttachMenuBotAllowed#e7e75f97 // default: panic(v) // } type MessageActionClass interface { @@ -6303,6 +6545,20 @@ func DecodeMessageAction(buf *bin.Buffer) (MessageActionClass, error) { return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err) } return &v, nil + case MessageActionSuggestProfilePhotoTypeID: + // Decoding messageActionSuggestProfilePhoto#57de635e. + v := MessageActionSuggestProfilePhoto{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err) + } + return &v, nil + case MessageActionAttachMenuBotAllowedTypeID: + // Decoding messageActionAttachMenuBotAllowed#e7e75f97. + v := MessageActionAttachMenuBotAllowed{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode MessageActionClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_message_action_slices_gen.go b/tg/tl_message_action_slices_gen.go index 3abd3fb328..fba643a82b 100644 --- a/tg/tl_message_action_slices_gen.go +++ b/tg/tl_message_action_slices_gen.go @@ -480,6 +480,19 @@ func (s MessageActionClassArray) AsMessageActionTopicEdit() (to MessageActionTop return to } +// AsMessageActionSuggestProfilePhoto returns copy with only MessageActionSuggestProfilePhoto constructors. +func (s MessageActionClassArray) AsMessageActionSuggestProfilePhoto() (to MessageActionSuggestProfilePhotoArray) { + for _, elem := range s { + value, ok := elem.(*MessageActionSuggestProfilePhoto) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // MessageActionChatCreateArray is adapter for slice of MessageActionChatCreate. type MessageActionChatCreateArray []MessageActionChatCreate @@ -2775,3 +2788,85 @@ func (s *MessageActionTopicEditArray) Pop() (v MessageActionTopicEdit, ok bool) return v, true } + +// MessageActionSuggestProfilePhotoArray is adapter for slice of MessageActionSuggestProfilePhoto. +type MessageActionSuggestProfilePhotoArray []MessageActionSuggestProfilePhoto + +// Sort sorts slice of MessageActionSuggestProfilePhoto. +func (s MessageActionSuggestProfilePhotoArray) Sort(less func(a, b MessageActionSuggestProfilePhoto) bool) MessageActionSuggestProfilePhotoArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessageActionSuggestProfilePhoto. +func (s MessageActionSuggestProfilePhotoArray) SortStable(less func(a, b MessageActionSuggestProfilePhoto) bool) MessageActionSuggestProfilePhotoArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessageActionSuggestProfilePhoto. +func (s MessageActionSuggestProfilePhotoArray) Retain(keep func(x MessageActionSuggestProfilePhoto) bool) MessageActionSuggestProfilePhotoArray { + 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 MessageActionSuggestProfilePhotoArray) First() (v MessageActionSuggestProfilePhoto, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessageActionSuggestProfilePhotoArray) Last() (v MessageActionSuggestProfilePhoto, 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 *MessageActionSuggestProfilePhotoArray) PopFirst() (v MessageActionSuggestProfilePhoto, 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 MessageActionSuggestProfilePhoto + 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 *MessageActionSuggestProfilePhotoArray) Pop() (v MessageActionSuggestProfilePhoto, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_message_media_gen.go b/tg/tl_message_media_gen.go index 116083454b..484ecaec9b 100644 --- a/tg/tl_message_media_gen.go +++ b/tg/tl_message_media_gen.go @@ -143,6 +143,8 @@ type MessageMediaPhoto struct { // Links: // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields Flags bin.Fields + // Spoiler field of MessageMediaPhoto. + Spoiler bool // Photo // // Use SetPhoto and GetPhoto helpers. @@ -176,6 +178,9 @@ func (m *MessageMediaPhoto) Zero() bool { if !(m.Flags.Zero()) { return false } + if !(m.Spoiler == false) { + return false + } if !(m.Photo == nil) { return false } @@ -197,9 +202,11 @@ func (m *MessageMediaPhoto) String() string { // FillFrom fills MessageMediaPhoto from given interface. func (m *MessageMediaPhoto) FillFrom(from interface { + GetSpoiler() (value bool) GetPhoto() (value PhotoClass, ok bool) GetTTLSeconds() (value int, ok bool) }) { + m.Spoiler = from.GetSpoiler() if val, ok := from.GetPhoto(); ok { m.Photo = val } @@ -233,6 +240,11 @@ func (m *MessageMediaPhoto) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "Spoiler", + SchemaName: "spoiler", + Null: !m.Flags.Has(3), + }, { Name: "Photo", SchemaName: "photo", @@ -249,6 +261,9 @@ func (m *MessageMediaPhoto) TypeInfo() tdp.Type { // SetFlags sets flags for non-zero fields. func (m *MessageMediaPhoto) SetFlags() { + if !(m.Spoiler == false) { + m.Flags.Set(3) + } if !(m.Photo == nil) { m.Flags.Set(0) } @@ -310,6 +325,7 @@ func (m *MessageMediaPhoto) DecodeBare(b *bin.Buffer) error { return fmt.Errorf("unable to decode messageMediaPhoto#695150d7: field flags: %w", err) } } + m.Spoiler = m.Flags.Has(3) if m.Flags.Has(0) { value, err := DecodePhoto(b) if err != nil { @@ -327,6 +343,25 @@ func (m *MessageMediaPhoto) DecodeBare(b *bin.Buffer) error { return nil } +// SetSpoiler sets value of Spoiler conditional field. +func (m *MessageMediaPhoto) SetSpoiler(value bool) { + if value { + m.Flags.Set(3) + m.Spoiler = true + } else { + m.Flags.Unset(3) + m.Spoiler = false + } +} + +// GetSpoiler returns value of Spoiler conditional field. +func (m *MessageMediaPhoto) GetSpoiler() (value bool) { + if m == nil { + return + } + return m.Flags.Has(3) +} + // SetPhoto sets value of Photo conditional field. func (m *MessageMediaPhoto) SetPhoto(value PhotoClass) { m.Flags.Set(0) @@ -861,6 +896,8 @@ type MessageMediaDocument struct { // Whether this is a normal sticker, if not set this is a premium sticker and a premium // sticker animation must be played. Nopremium bool + // Spoiler field of MessageMediaDocument. + Spoiler bool // Attached document // // Use SetDocument and GetDocument helpers. @@ -897,6 +934,9 @@ func (m *MessageMediaDocument) Zero() bool { if !(m.Nopremium == false) { return false } + if !(m.Spoiler == false) { + return false + } if !(m.Document == nil) { return false } @@ -919,10 +959,12 @@ func (m *MessageMediaDocument) String() string { // FillFrom fills MessageMediaDocument from given interface. func (m *MessageMediaDocument) FillFrom(from interface { GetNopremium() (value bool) + GetSpoiler() (value bool) GetDocument() (value DocumentClass, ok bool) GetTTLSeconds() (value int, ok bool) }) { m.Nopremium = from.GetNopremium() + m.Spoiler = from.GetSpoiler() if val, ok := from.GetDocument(); ok { m.Document = val } @@ -961,6 +1003,11 @@ func (m *MessageMediaDocument) TypeInfo() tdp.Type { SchemaName: "nopremium", Null: !m.Flags.Has(3), }, + { + Name: "Spoiler", + SchemaName: "spoiler", + Null: !m.Flags.Has(4), + }, { Name: "Document", SchemaName: "document", @@ -980,6 +1027,9 @@ func (m *MessageMediaDocument) SetFlags() { if !(m.Nopremium == false) { m.Flags.Set(3) } + if !(m.Spoiler == false) { + m.Flags.Set(4) + } if !(m.Document == nil) { m.Flags.Set(0) } @@ -1042,6 +1092,7 @@ func (m *MessageMediaDocument) DecodeBare(b *bin.Buffer) error { } } m.Nopremium = m.Flags.Has(3) + m.Spoiler = m.Flags.Has(4) if m.Flags.Has(0) { value, err := DecodeDocument(b) if err != nil { @@ -1078,6 +1129,25 @@ func (m *MessageMediaDocument) GetNopremium() (value bool) { return m.Flags.Has(3) } +// SetSpoiler sets value of Spoiler conditional field. +func (m *MessageMediaDocument) SetSpoiler(value bool) { + if value { + m.Flags.Set(4) + m.Spoiler = true + } else { + m.Flags.Unset(4) + m.Spoiler = false + } +} + +// GetSpoiler returns value of Spoiler conditional field. +func (m *MessageMediaDocument) GetSpoiler() (value bool) { + if m == nil { + return + } + return m.Flags.Has(4) +} + // SetDocument sets value of Document conditional field. func (m *MessageMediaDocument) SetDocument(value DocumentClass) { m.Flags.Set(0) diff --git a/tg/tl_messages_toggle_bot_in_attach_menu_gen.go b/tg/tl_messages_toggle_bot_in_attach_menu_gen.go index 0ca1580a44..b56670d917 100644 --- a/tg/tl_messages_toggle_bot_in_attach_menu_gen.go +++ b/tg/tl_messages_toggle_bot_in_attach_menu_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// MessagesToggleBotInAttachMenuRequest represents TL type `messages.toggleBotInAttachMenu#1aee33af`. +// MessagesToggleBotInAttachMenuRequest represents TL type `messages.toggleBotInAttachMenu#69f59d69`. // Enable or disable web bot attachment menu »¹ // // Links: @@ -39,6 +39,10 @@ var ( // // See https://core.telegram.org/method/messages.toggleBotInAttachMenu for reference. type MessagesToggleBotInAttachMenuRequest struct { + // Flags field of MessagesToggleBotInAttachMenuRequest. + Flags bin.Fields + // WriteAllowed field of MessagesToggleBotInAttachMenuRequest. + WriteAllowed bool // Bot ID Bot InputUserClass // Toggle @@ -46,7 +50,7 @@ type MessagesToggleBotInAttachMenuRequest struct { } // MessagesToggleBotInAttachMenuRequestTypeID is TL type id of MessagesToggleBotInAttachMenuRequest. -const MessagesToggleBotInAttachMenuRequestTypeID = 0x1aee33af +const MessagesToggleBotInAttachMenuRequestTypeID = 0x69f59d69 // Ensuring interfaces in compile-time for MessagesToggleBotInAttachMenuRequest. var ( @@ -60,6 +64,12 @@ func (t *MessagesToggleBotInAttachMenuRequest) Zero() bool { if t == nil { return true } + if !(t.Flags.Zero()) { + return false + } + if !(t.WriteAllowed == false) { + return false + } if !(t.Bot == nil) { return false } @@ -81,9 +91,11 @@ func (t *MessagesToggleBotInAttachMenuRequest) String() string { // FillFrom fills MessagesToggleBotInAttachMenuRequest from given interface. func (t *MessagesToggleBotInAttachMenuRequest) FillFrom(from interface { + GetWriteAllowed() (value bool) GetBot() (value InputUserClass) GetEnabled() (value bool) }) { + t.WriteAllowed = from.GetWriteAllowed() t.Bot = from.GetBot() t.Enabled = from.GetEnabled() } @@ -111,6 +123,11 @@ func (t *MessagesToggleBotInAttachMenuRequest) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "WriteAllowed", + SchemaName: "write_allowed", + Null: !t.Flags.Has(0), + }, { Name: "Bot", SchemaName: "bot", @@ -123,10 +140,17 @@ func (t *MessagesToggleBotInAttachMenuRequest) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (t *MessagesToggleBotInAttachMenuRequest) SetFlags() { + if !(t.WriteAllowed == false) { + t.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (t *MessagesToggleBotInAttachMenuRequest) Encode(b *bin.Buffer) error { if t == nil { - return fmt.Errorf("can't encode messages.toggleBotInAttachMenu#1aee33af as nil") + return fmt.Errorf("can't encode messages.toggleBotInAttachMenu#69f59d69 as nil") } b.PutID(MessagesToggleBotInAttachMenuRequestTypeID) return t.EncodeBare(b) @@ -135,13 +159,17 @@ func (t *MessagesToggleBotInAttachMenuRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (t *MessagesToggleBotInAttachMenuRequest) EncodeBare(b *bin.Buffer) error { if t == nil { - return fmt.Errorf("can't encode messages.toggleBotInAttachMenu#1aee33af as nil") + return fmt.Errorf("can't encode messages.toggleBotInAttachMenu#69f59d69 as nil") + } + t.SetFlags() + if err := t.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.toggleBotInAttachMenu#69f59d69: field flags: %w", err) } if t.Bot == nil { - return fmt.Errorf("unable to encode messages.toggleBotInAttachMenu#1aee33af: field bot is nil") + return fmt.Errorf("unable to encode messages.toggleBotInAttachMenu#69f59d69: field bot is nil") } if err := t.Bot.Encode(b); err != nil { - return fmt.Errorf("unable to encode messages.toggleBotInAttachMenu#1aee33af: field bot: %w", err) + return fmt.Errorf("unable to encode messages.toggleBotInAttachMenu#69f59d69: field bot: %w", err) } b.PutBool(t.Enabled) return nil @@ -150,10 +178,10 @@ func (t *MessagesToggleBotInAttachMenuRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (t *MessagesToggleBotInAttachMenuRequest) Decode(b *bin.Buffer) error { if t == nil { - return fmt.Errorf("can't decode messages.toggleBotInAttachMenu#1aee33af to nil") + return fmt.Errorf("can't decode messages.toggleBotInAttachMenu#69f59d69 to nil") } if err := b.ConsumeID(MessagesToggleBotInAttachMenuRequestTypeID); err != nil { - return fmt.Errorf("unable to decode messages.toggleBotInAttachMenu#1aee33af: %w", err) + return fmt.Errorf("unable to decode messages.toggleBotInAttachMenu#69f59d69: %w", err) } return t.DecodeBare(b) } @@ -161,25 +189,50 @@ func (t *MessagesToggleBotInAttachMenuRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (t *MessagesToggleBotInAttachMenuRequest) DecodeBare(b *bin.Buffer) error { if t == nil { - return fmt.Errorf("can't decode messages.toggleBotInAttachMenu#1aee33af to nil") + return fmt.Errorf("can't decode messages.toggleBotInAttachMenu#69f59d69 to nil") } + { + if err := t.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.toggleBotInAttachMenu#69f59d69: field flags: %w", err) + } + } + t.WriteAllowed = t.Flags.Has(0) { value, err := DecodeInputUser(b) if err != nil { - return fmt.Errorf("unable to decode messages.toggleBotInAttachMenu#1aee33af: field bot: %w", err) + return fmt.Errorf("unable to decode messages.toggleBotInAttachMenu#69f59d69: field bot: %w", err) } t.Bot = value } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode messages.toggleBotInAttachMenu#1aee33af: field enabled: %w", err) + return fmt.Errorf("unable to decode messages.toggleBotInAttachMenu#69f59d69: field enabled: %w", err) } t.Enabled = value } return nil } +// SetWriteAllowed sets value of WriteAllowed conditional field. +func (t *MessagesToggleBotInAttachMenuRequest) SetWriteAllowed(value bool) { + if value { + t.Flags.Set(0) + t.WriteAllowed = true + } else { + t.Flags.Unset(0) + t.WriteAllowed = false + } +} + +// GetWriteAllowed returns value of WriteAllowed conditional field. +func (t *MessagesToggleBotInAttachMenuRequest) GetWriteAllowed() (value bool) { + if t == nil { + return + } + return t.Flags.Has(0) +} + // GetBot returns value of Bot field. func (t *MessagesToggleBotInAttachMenuRequest) GetBot() (value InputUserClass) { if t == nil { @@ -196,7 +249,7 @@ func (t *MessagesToggleBotInAttachMenuRequest) GetEnabled() (value bool) { return t.Enabled } -// MessagesToggleBotInAttachMenu invokes method messages.toggleBotInAttachMenu#1aee33af returning error if any. +// MessagesToggleBotInAttachMenu invokes method messages.toggleBotInAttachMenu#69f59d69 returning error if any. // Enable or disable web bot attachment menu »¹ // // Links: diff --git a/tg/tl_photos_update_profile_photo_gen.go b/tg/tl_photos_update_profile_photo_gen.go index 87d8bad9c0..241d1157c5 100644 --- a/tg/tl_photos_update_profile_photo_gen.go +++ b/tg/tl_photos_update_profile_photo_gen.go @@ -31,17 +31,21 @@ var ( _ = tdjson.Encoder{} ) -// PhotosUpdateProfilePhotoRequest represents TL type `photos.updateProfilePhoto#72d4742c`. +// PhotosUpdateProfilePhotoRequest represents TL type `photos.updateProfilePhoto#1c3d5956`. // Installs a previously uploaded photo as a profile photo. // // See https://core.telegram.org/method/photos.updateProfilePhoto for reference. type PhotosUpdateProfilePhotoRequest struct { + // Flags field of PhotosUpdateProfilePhotoRequest. + Flags bin.Fields + // Fallback field of PhotosUpdateProfilePhotoRequest. + Fallback bool // Input photo ID InputPhotoClass } // PhotosUpdateProfilePhotoRequestTypeID is TL type id of PhotosUpdateProfilePhotoRequest. -const PhotosUpdateProfilePhotoRequestTypeID = 0x72d4742c +const PhotosUpdateProfilePhotoRequestTypeID = 0x1c3d5956 // Ensuring interfaces in compile-time for PhotosUpdateProfilePhotoRequest. var ( @@ -55,6 +59,12 @@ func (u *PhotosUpdateProfilePhotoRequest) Zero() bool { if u == nil { return true } + if !(u.Flags.Zero()) { + return false + } + if !(u.Fallback == false) { + return false + } if !(u.ID == nil) { return false } @@ -73,8 +83,10 @@ func (u *PhotosUpdateProfilePhotoRequest) String() string { // FillFrom fills PhotosUpdateProfilePhotoRequest from given interface. func (u *PhotosUpdateProfilePhotoRequest) FillFrom(from interface { + GetFallback() (value bool) GetID() (value InputPhotoClass) }) { + u.Fallback = from.GetFallback() u.ID = from.GetID() } @@ -101,6 +113,11 @@ func (u *PhotosUpdateProfilePhotoRequest) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "Fallback", + SchemaName: "fallback", + Null: !u.Flags.Has(0), + }, { Name: "ID", SchemaName: "id", @@ -109,10 +126,17 @@ func (u *PhotosUpdateProfilePhotoRequest) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (u *PhotosUpdateProfilePhotoRequest) SetFlags() { + if !(u.Fallback == false) { + u.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (u *PhotosUpdateProfilePhotoRequest) Encode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode photos.updateProfilePhoto#72d4742c as nil") + return fmt.Errorf("can't encode photos.updateProfilePhoto#1c3d5956 as nil") } b.PutID(PhotosUpdateProfilePhotoRequestTypeID) return u.EncodeBare(b) @@ -121,13 +145,17 @@ func (u *PhotosUpdateProfilePhotoRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (u *PhotosUpdateProfilePhotoRequest) EncodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode photos.updateProfilePhoto#72d4742c as nil") + return fmt.Errorf("can't encode photos.updateProfilePhoto#1c3d5956 as nil") + } + u.SetFlags() + if err := u.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode photos.updateProfilePhoto#1c3d5956: field flags: %w", err) } if u.ID == nil { - return fmt.Errorf("unable to encode photos.updateProfilePhoto#72d4742c: field id is nil") + return fmt.Errorf("unable to encode photos.updateProfilePhoto#1c3d5956: field id is nil") } if err := u.ID.Encode(b); err != nil { - return fmt.Errorf("unable to encode photos.updateProfilePhoto#72d4742c: field id: %w", err) + return fmt.Errorf("unable to encode photos.updateProfilePhoto#1c3d5956: field id: %w", err) } return nil } @@ -135,10 +163,10 @@ func (u *PhotosUpdateProfilePhotoRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (u *PhotosUpdateProfilePhotoRequest) Decode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode photos.updateProfilePhoto#72d4742c to nil") + return fmt.Errorf("can't decode photos.updateProfilePhoto#1c3d5956 to nil") } if err := b.ConsumeID(PhotosUpdateProfilePhotoRequestTypeID); err != nil { - return fmt.Errorf("unable to decode photos.updateProfilePhoto#72d4742c: %w", err) + return fmt.Errorf("unable to decode photos.updateProfilePhoto#1c3d5956: %w", err) } return u.DecodeBare(b) } @@ -146,18 +174,43 @@ func (u *PhotosUpdateProfilePhotoRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (u *PhotosUpdateProfilePhotoRequest) DecodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode photos.updateProfilePhoto#72d4742c to nil") + return fmt.Errorf("can't decode photos.updateProfilePhoto#1c3d5956 to nil") + } + { + if err := u.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode photos.updateProfilePhoto#1c3d5956: field flags: %w", err) + } } + u.Fallback = u.Flags.Has(0) { value, err := DecodeInputPhoto(b) if err != nil { - return fmt.Errorf("unable to decode photos.updateProfilePhoto#72d4742c: field id: %w", err) + return fmt.Errorf("unable to decode photos.updateProfilePhoto#1c3d5956: field id: %w", err) } u.ID = value } return nil } +// SetFallback sets value of Fallback conditional field. +func (u *PhotosUpdateProfilePhotoRequest) SetFallback(value bool) { + if value { + u.Flags.Set(0) + u.Fallback = true + } else { + u.Flags.Unset(0) + u.Fallback = false + } +} + +// GetFallback returns value of Fallback conditional field. +func (u *PhotosUpdateProfilePhotoRequest) GetFallback() (value bool) { + if u == nil { + return + } + return u.Flags.Has(0) +} + // GetID returns value of ID field. func (u *PhotosUpdateProfilePhotoRequest) GetID() (value InputPhotoClass) { if u == nil { @@ -171,7 +224,7 @@ func (u *PhotosUpdateProfilePhotoRequest) GetIDAsNotEmpty() (*InputPhoto, bool) return u.ID.AsNotEmpty() } -// PhotosUpdateProfilePhoto invokes method photos.updateProfilePhoto#72d4742c returning error if any. +// PhotosUpdateProfilePhoto invokes method photos.updateProfilePhoto#1c3d5956 returning error if any. // Installs a previously uploaded photo as a profile photo. // // Possible errors: @@ -185,12 +238,9 @@ func (u *PhotosUpdateProfilePhotoRequest) GetIDAsNotEmpty() (*InputPhoto, bool) // 400 PHOTO_ID_INVALID: Photo ID invalid. // // See https://core.telegram.org/method/photos.updateProfilePhoto for reference. -func (c *Client) PhotosUpdateProfilePhoto(ctx context.Context, id InputPhotoClass) (*PhotosPhoto, error) { +func (c *Client) PhotosUpdateProfilePhoto(ctx context.Context, request *PhotosUpdateProfilePhotoRequest) (*PhotosPhoto, error) { var result PhotosPhoto - request := &PhotosUpdateProfilePhotoRequest{ - ID: id, - } if err := c.rpc.Invoke(ctx, request, &result); err != nil { return nil, err } diff --git a/tg/tl_photos_upload_contact_profile_photo_gen.go b/tg/tl_photos_upload_contact_profile_photo_gen.go new file mode 100644 index 0000000000..a28f1f4d17 --- /dev/null +++ b/tg/tl_photos_upload_contact_profile_photo_gen.go @@ -0,0 +1,420 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// PhotosUploadContactProfilePhotoRequest represents TL type `photos.uploadContactProfilePhoto#b91a83bf`. +// +// See https://core.telegram.org/method/photos.uploadContactProfilePhoto for reference. +type PhotosUploadContactProfilePhotoRequest struct { + // Flags field of PhotosUploadContactProfilePhotoRequest. + Flags bin.Fields + // Suggest field of PhotosUploadContactProfilePhotoRequest. + Suggest bool + // Save field of PhotosUploadContactProfilePhotoRequest. + Save bool + // UserID field of PhotosUploadContactProfilePhotoRequest. + UserID InputUserClass + // File field of PhotosUploadContactProfilePhotoRequest. + // + // Use SetFile and GetFile helpers. + File InputFileClass + // Video field of PhotosUploadContactProfilePhotoRequest. + // + // Use SetVideo and GetVideo helpers. + Video InputFileClass + // VideoStartTs field of PhotosUploadContactProfilePhotoRequest. + // + // Use SetVideoStartTs and GetVideoStartTs helpers. + VideoStartTs float64 +} + +// PhotosUploadContactProfilePhotoRequestTypeID is TL type id of PhotosUploadContactProfilePhotoRequest. +const PhotosUploadContactProfilePhotoRequestTypeID = 0xb91a83bf + +// Ensuring interfaces in compile-time for PhotosUploadContactProfilePhotoRequest. +var ( + _ bin.Encoder = &PhotosUploadContactProfilePhotoRequest{} + _ bin.Decoder = &PhotosUploadContactProfilePhotoRequest{} + _ bin.BareEncoder = &PhotosUploadContactProfilePhotoRequest{} + _ bin.BareDecoder = &PhotosUploadContactProfilePhotoRequest{} +) + +func (u *PhotosUploadContactProfilePhotoRequest) Zero() bool { + if u == nil { + return true + } + if !(u.Flags.Zero()) { + return false + } + if !(u.Suggest == false) { + return false + } + if !(u.Save == false) { + return false + } + if !(u.UserID == nil) { + return false + } + if !(u.File == nil) { + return false + } + if !(u.Video == nil) { + return false + } + if !(u.VideoStartTs == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *PhotosUploadContactProfilePhotoRequest) String() string { + if u == nil { + return "PhotosUploadContactProfilePhotoRequest(nil)" + } + type Alias PhotosUploadContactProfilePhotoRequest + return fmt.Sprintf("PhotosUploadContactProfilePhotoRequest%+v", Alias(*u)) +} + +// FillFrom fills PhotosUploadContactProfilePhotoRequest from given interface. +func (u *PhotosUploadContactProfilePhotoRequest) FillFrom(from interface { + GetSuggest() (value bool) + GetSave() (value bool) + GetUserID() (value InputUserClass) + GetFile() (value InputFileClass, ok bool) + GetVideo() (value InputFileClass, ok bool) + GetVideoStartTs() (value float64, ok bool) +}) { + u.Suggest = from.GetSuggest() + u.Save = from.GetSave() + u.UserID = from.GetUserID() + if val, ok := from.GetFile(); ok { + u.File = val + } + + if val, ok := from.GetVideo(); ok { + u.Video = val + } + + if val, ok := from.GetVideoStartTs(); ok { + u.VideoStartTs = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PhotosUploadContactProfilePhotoRequest) TypeID() uint32 { + return PhotosUploadContactProfilePhotoRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*PhotosUploadContactProfilePhotoRequest) TypeName() string { + return "photos.uploadContactProfilePhoto" +} + +// TypeInfo returns info about TL type. +func (u *PhotosUploadContactProfilePhotoRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "photos.uploadContactProfilePhoto", + ID: PhotosUploadContactProfilePhotoRequestTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Suggest", + SchemaName: "suggest", + Null: !u.Flags.Has(3), + }, + { + Name: "Save", + SchemaName: "save", + Null: !u.Flags.Has(4), + }, + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "File", + SchemaName: "file", + Null: !u.Flags.Has(0), + }, + { + Name: "Video", + SchemaName: "video", + Null: !u.Flags.Has(1), + }, + { + Name: "VideoStartTs", + SchemaName: "video_start_ts", + Null: !u.Flags.Has(2), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (u *PhotosUploadContactProfilePhotoRequest) SetFlags() { + if !(u.Suggest == false) { + u.Flags.Set(3) + } + if !(u.Save == false) { + u.Flags.Set(4) + } + if !(u.File == nil) { + u.Flags.Set(0) + } + if !(u.Video == nil) { + u.Flags.Set(1) + } + if !(u.VideoStartTs == 0) { + u.Flags.Set(2) + } +} + +// Encode implements bin.Encoder. +func (u *PhotosUploadContactProfilePhotoRequest) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode photos.uploadContactProfilePhoto#b91a83bf as nil") + } + b.PutID(PhotosUploadContactProfilePhotoRequestTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *PhotosUploadContactProfilePhotoRequest) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode photos.uploadContactProfilePhoto#b91a83bf as nil") + } + u.SetFlags() + if err := u.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode photos.uploadContactProfilePhoto#b91a83bf: field flags: %w", err) + } + if u.UserID == nil { + return fmt.Errorf("unable to encode photos.uploadContactProfilePhoto#b91a83bf: field user_id is nil") + } + if err := u.UserID.Encode(b); err != nil { + return fmt.Errorf("unable to encode photos.uploadContactProfilePhoto#b91a83bf: field user_id: %w", err) + } + if u.Flags.Has(0) { + if u.File == nil { + return fmt.Errorf("unable to encode photos.uploadContactProfilePhoto#b91a83bf: field file is nil") + } + if err := u.File.Encode(b); err != nil { + return fmt.Errorf("unable to encode photos.uploadContactProfilePhoto#b91a83bf: field file: %w", err) + } + } + if u.Flags.Has(1) { + if u.Video == nil { + return fmt.Errorf("unable to encode photos.uploadContactProfilePhoto#b91a83bf: field video is nil") + } + if err := u.Video.Encode(b); err != nil { + return fmt.Errorf("unable to encode photos.uploadContactProfilePhoto#b91a83bf: field video: %w", err) + } + } + if u.Flags.Has(2) { + b.PutDouble(u.VideoStartTs) + } + return nil +} + +// Decode implements bin.Decoder. +func (u *PhotosUploadContactProfilePhotoRequest) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode photos.uploadContactProfilePhoto#b91a83bf to nil") + } + if err := b.ConsumeID(PhotosUploadContactProfilePhotoRequestTypeID); err != nil { + return fmt.Errorf("unable to decode photos.uploadContactProfilePhoto#b91a83bf: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *PhotosUploadContactProfilePhotoRequest) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode photos.uploadContactProfilePhoto#b91a83bf to nil") + } + { + if err := u.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode photos.uploadContactProfilePhoto#b91a83bf: field flags: %w", err) + } + } + u.Suggest = u.Flags.Has(3) + u.Save = u.Flags.Has(4) + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode photos.uploadContactProfilePhoto#b91a83bf: field user_id: %w", err) + } + u.UserID = value + } + if u.Flags.Has(0) { + value, err := DecodeInputFile(b) + if err != nil { + return fmt.Errorf("unable to decode photos.uploadContactProfilePhoto#b91a83bf: field file: %w", err) + } + u.File = value + } + if u.Flags.Has(1) { + value, err := DecodeInputFile(b) + if err != nil { + return fmt.Errorf("unable to decode photos.uploadContactProfilePhoto#b91a83bf: field video: %w", err) + } + u.Video = value + } + if u.Flags.Has(2) { + value, err := b.Double() + if err != nil { + return fmt.Errorf("unable to decode photos.uploadContactProfilePhoto#b91a83bf: field video_start_ts: %w", err) + } + u.VideoStartTs = value + } + return nil +} + +// SetSuggest sets value of Suggest conditional field. +func (u *PhotosUploadContactProfilePhotoRequest) SetSuggest(value bool) { + if value { + u.Flags.Set(3) + u.Suggest = true + } else { + u.Flags.Unset(3) + u.Suggest = false + } +} + +// GetSuggest returns value of Suggest conditional field. +func (u *PhotosUploadContactProfilePhotoRequest) GetSuggest() (value bool) { + if u == nil { + return + } + return u.Flags.Has(3) +} + +// SetSave sets value of Save conditional field. +func (u *PhotosUploadContactProfilePhotoRequest) SetSave(value bool) { + if value { + u.Flags.Set(4) + u.Save = true + } else { + u.Flags.Unset(4) + u.Save = false + } +} + +// GetSave returns value of Save conditional field. +func (u *PhotosUploadContactProfilePhotoRequest) GetSave() (value bool) { + if u == nil { + return + } + return u.Flags.Has(4) +} + +// GetUserID returns value of UserID field. +func (u *PhotosUploadContactProfilePhotoRequest) GetUserID() (value InputUserClass) { + if u == nil { + return + } + return u.UserID +} + +// SetFile sets value of File conditional field. +func (u *PhotosUploadContactProfilePhotoRequest) SetFile(value InputFileClass) { + u.Flags.Set(0) + u.File = value +} + +// GetFile returns value of File conditional field and +// boolean which is true if field was set. +func (u *PhotosUploadContactProfilePhotoRequest) GetFile() (value InputFileClass, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(0) { + return value, false + } + return u.File, true +} + +// SetVideo sets value of Video conditional field. +func (u *PhotosUploadContactProfilePhotoRequest) SetVideo(value InputFileClass) { + u.Flags.Set(1) + u.Video = value +} + +// GetVideo returns value of Video conditional field and +// boolean which is true if field was set. +func (u *PhotosUploadContactProfilePhotoRequest) GetVideo() (value InputFileClass, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(1) { + return value, false + } + return u.Video, true +} + +// SetVideoStartTs sets value of VideoStartTs conditional field. +func (u *PhotosUploadContactProfilePhotoRequest) SetVideoStartTs(value float64) { + u.Flags.Set(2) + u.VideoStartTs = value +} + +// GetVideoStartTs returns value of VideoStartTs conditional field and +// boolean which is true if field was set. +func (u *PhotosUploadContactProfilePhotoRequest) GetVideoStartTs() (value float64, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(2) { + return value, false + } + return u.VideoStartTs, true +} + +// PhotosUploadContactProfilePhoto invokes method photos.uploadContactProfilePhoto#b91a83bf returning error if any. +// +// See https://core.telegram.org/method/photos.uploadContactProfilePhoto for reference. +func (c *Client) PhotosUploadContactProfilePhoto(ctx context.Context, request *PhotosUploadContactProfilePhotoRequest) (*PhotosPhoto, error) { + var result PhotosPhoto + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_photos_upload_contact_profile_photo_slices_gen.go b/tg/tl_photos_upload_contact_profile_photo_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_photos_upload_contact_profile_photo_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_photos_upload_profile_photo_gen.go b/tg/tl_photos_upload_profile_photo_gen.go index 8998217b6d..5e6314622d 100644 --- a/tg/tl_photos_upload_profile_photo_gen.go +++ b/tg/tl_photos_upload_profile_photo_gen.go @@ -41,6 +41,8 @@ type PhotosUploadProfilePhotoRequest struct { // Links: // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields Flags bin.Fields + // Fallback field of PhotosUploadProfilePhotoRequest. + Fallback bool // File saved in parts by means of upload.saveFilePart¹ method // // Links: @@ -80,6 +82,9 @@ func (u *PhotosUploadProfilePhotoRequest) Zero() bool { if !(u.Flags.Zero()) { return false } + if !(u.Fallback == false) { + return false + } if !(u.File == nil) { return false } @@ -104,10 +109,12 @@ func (u *PhotosUploadProfilePhotoRequest) String() string { // FillFrom fills PhotosUploadProfilePhotoRequest from given interface. func (u *PhotosUploadProfilePhotoRequest) FillFrom(from interface { + GetFallback() (value bool) GetFile() (value InputFileClass, ok bool) GetVideo() (value InputFileClass, ok bool) GetVideoStartTs() (value float64, ok bool) }) { + u.Fallback = from.GetFallback() if val, ok := from.GetFile(); ok { u.File = val } @@ -145,6 +152,11 @@ func (u *PhotosUploadProfilePhotoRequest) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "Fallback", + SchemaName: "fallback", + Null: !u.Flags.Has(3), + }, { Name: "File", SchemaName: "file", @@ -166,6 +178,9 @@ func (u *PhotosUploadProfilePhotoRequest) TypeInfo() tdp.Type { // SetFlags sets flags for non-zero fields. func (u *PhotosUploadProfilePhotoRequest) SetFlags() { + if !(u.Fallback == false) { + u.Flags.Set(3) + } if !(u.File == nil) { u.Flags.Set(0) } @@ -238,6 +253,7 @@ func (u *PhotosUploadProfilePhotoRequest) DecodeBare(b *bin.Buffer) error { return fmt.Errorf("unable to decode photos.uploadProfilePhoto#89f30f69: field flags: %w", err) } } + u.Fallback = u.Flags.Has(3) if u.Flags.Has(0) { value, err := DecodeInputFile(b) if err != nil { @@ -262,6 +278,25 @@ func (u *PhotosUploadProfilePhotoRequest) DecodeBare(b *bin.Buffer) error { return nil } +// SetFallback sets value of Fallback conditional field. +func (u *PhotosUploadProfilePhotoRequest) SetFallback(value bool) { + if value { + u.Flags.Set(3) + u.Fallback = true + } else { + u.Flags.Unset(3) + u.Fallback = false + } +} + +// GetFallback returns value of Fallback conditional field. +func (u *PhotosUploadProfilePhotoRequest) GetFallback() (value bool) { + if u == nil { + return + } + return u.Flags.Has(3) +} + // SetFile sets value of File conditional field. func (u *PhotosUploadProfilePhotoRequest) SetFile(value InputFileClass) { u.Flags.Set(0) diff --git a/tg/tl_registry_gen.go b/tg/tl_registry_gen.go index abb04396b5..d5e2784965 100644 --- a/tg/tl_registry_gen.go +++ b/tg/tl_registry_gen.go @@ -32,7 +32,7 @@ var ( ) // Layer version of schema. -const Layer = 150 +const Layer = 151 // TypesMap returns mapping from type ids to TL type names. func TypesMap() map[uint32]string { @@ -176,6 +176,8 @@ func TypesMap() map[uint32]string { MessageActionGiftPremiumTypeID: "messageActionGiftPremium#aba0f5c6", MessageActionTopicCreateTypeID: "messageActionTopicCreate#d999256", MessageActionTopicEditTypeID: "messageActionTopicEdit#c0944820", + MessageActionSuggestProfilePhotoTypeID: "messageActionSuggestProfilePhoto#57de635e", + MessageActionAttachMenuBotAllowedTypeID: "messageActionAttachMenuBotAllowed#e7e75f97", DialogTypeID: "dialog#d58a08c6", DialogFolderTypeID: "dialogFolder#71bd134c", PhotoEmptyTypeID: "photoEmpty#2331b22d", @@ -212,7 +214,7 @@ func TypesMap() map[uint32]string { InputReportReasonFakeTypeID: "inputReportReasonFake#f5ddd6e7", InputReportReasonIllegalDrugsTypeID: "inputReportReasonIllegalDrugs#a8eb2be", InputReportReasonPersonalDetailsTypeID: "inputReportReasonPersonalDetails#9ec7863d", - UserFullTypeID: "userFull#c4b1fc3f", + UserFullTypeID: "userFull#f8d32aed", ContactTypeID: "contact#145ade0b", ImportedContactTypeID: "importedContact#c13e3c50", ContactStatusTypeID: "contactStatus#16d9703b", @@ -257,7 +259,6 @@ func TypesMap() map[uint32]string { UpdateChatParticipantsTypeID: "updateChatParticipants#7761198", UpdateUserStatusTypeID: "updateUserStatus#e5bdf8de", UpdateUserNameTypeID: "updateUserName#a7848924", - UpdateUserPhotoTypeID: "updateUserPhoto#f227868c", UpdateNewEncryptedMessageTypeID: "updateNewEncryptedMessage#12bcbd9a", UpdateEncryptedChatTypingTypeID: "updateEncryptedChatTyping#1710f156", UpdateEncryptionTypeID: "updateEncryption#b4a2e88d", @@ -358,6 +359,7 @@ func TypesMap() map[uint32]string { UpdateMessageExtendedMediaTypeID: "updateMessageExtendedMedia#5a73a98c", UpdateChannelPinnedTopicTypeID: "updateChannelPinnedTopic#192efbe3", UpdateChannelPinnedTopicsTypeID: "updateChannelPinnedTopics#fe198602", + UpdateUserTypeID: "updateUser#20529438", UpdatesStateTypeID: "updates.state#a56c2a3e", UpdatesDifferenceEmptyTypeID: "updates.differenceEmpty#5d75a138", UpdatesDifferenceTypeID: "updates.difference#f49ca0", @@ -646,6 +648,7 @@ func TypesMap() map[uint32]string { StickerSetCoveredTypeID: "stickerSetCovered#6410a5d2", StickerSetMultiCoveredTypeID: "stickerSetMultiCovered#3407e51b", StickerSetFullCoveredTypeID: "stickerSetFullCovered#40d13c0e", + StickerSetNoCoveredTypeID: "stickerSetNoCovered#77b15d1c", MaskCoordsTypeID: "maskCoords#aed6dbb2", InputStickeredMediaPhotoTypeID: "inputStickeredMediaPhoto#4a992157", InputStickeredMediaDocumentTypeID: "inputStickeredMediaDocument#438865b", @@ -1403,7 +1406,7 @@ func TypesMap() map[uint32]string { MessagesSearchSentMediaRequestTypeID: "messages.searchSentMedia#107e31a0", MessagesGetAttachMenuBotsRequestTypeID: "messages.getAttachMenuBots#16fcc2cb", MessagesGetAttachMenuBotRequestTypeID: "messages.getAttachMenuBot#77216192", - MessagesToggleBotInAttachMenuRequestTypeID: "messages.toggleBotInAttachMenu#1aee33af", + MessagesToggleBotInAttachMenuRequestTypeID: "messages.toggleBotInAttachMenu#69f59d69", MessagesRequestWebViewRequestTypeID: "messages.requestWebView#178b480b", MessagesProlongWebViewRequestTypeID: "messages.prolongWebView#7ff34309", MessagesRequestSimpleWebViewRequestTypeID: "messages.requestSimpleWebView#299bec8e", @@ -1424,10 +1427,11 @@ func TypesMap() map[uint32]string { UpdatesGetStateRequestTypeID: "updates.getState#edd4882a", UpdatesGetDifferenceRequestTypeID: "updates.getDifference#25939651", UpdatesGetChannelDifferenceRequestTypeID: "updates.getChannelDifference#3173d78", - PhotosUpdateProfilePhotoRequestTypeID: "photos.updateProfilePhoto#72d4742c", + PhotosUpdateProfilePhotoRequestTypeID: "photos.updateProfilePhoto#1c3d5956", PhotosUploadProfilePhotoRequestTypeID: "photos.uploadProfilePhoto#89f30f69", PhotosDeletePhotosRequestTypeID: "photos.deletePhotos#87cf7f2f", PhotosGetUserPhotosRequestTypeID: "photos.getUserPhotos#91cd32a8", + PhotosUploadContactProfilePhotoRequestTypeID: "photos.uploadContactProfilePhoto#b91a83bf", UploadSaveFilePartRequestTypeID: "upload.saveFilePart#b304a621", UploadGetFileRequestTypeID: "upload.getFile#be5335be", UploadSaveBigFilePartRequestTypeID: "upload.saveBigFilePart#de7b673d", @@ -1513,6 +1517,7 @@ func TypesMap() map[uint32]string { ChannelsReorderPinnedForumTopicsRequestTypeID: "channels.reorderPinnedForumTopics#2950a18f", ChannelsToggleAntiSpamRequestTypeID: "channels.toggleAntiSpam#68f3e4eb", ChannelsReportAntiSpamFalsePositiveRequestTypeID: "channels.reportAntiSpamFalsePositive#a850a693", + ChannelsToggleParticipantsHiddenRequestTypeID: "channels.toggleParticipantsHidden#6a6e7854", BotsSendCustomRequestRequestTypeID: "bots.sendCustomRequest#aa2769ed", BotsAnswerWebhookJSONQueryRequestTypeID: "bots.answerWebhookJSONQuery#e6213f4d", BotsSetBotCommandsRequestTypeID: "bots.setBotCommands#517165a", @@ -1741,6 +1746,8 @@ func NamesMap() map[string]uint32 { "messageActionGiftPremium": MessageActionGiftPremiumTypeID, "messageActionTopicCreate": MessageActionTopicCreateTypeID, "messageActionTopicEdit": MessageActionTopicEditTypeID, + "messageActionSuggestProfilePhoto": MessageActionSuggestProfilePhotoTypeID, + "messageActionAttachMenuBotAllowed": MessageActionAttachMenuBotAllowedTypeID, "dialog": DialogTypeID, "dialogFolder": DialogFolderTypeID, "photoEmpty": PhotoEmptyTypeID, @@ -1822,7 +1829,6 @@ func NamesMap() map[string]uint32 { "updateChatParticipants": UpdateChatParticipantsTypeID, "updateUserStatus": UpdateUserStatusTypeID, "updateUserName": UpdateUserNameTypeID, - "updateUserPhoto": UpdateUserPhotoTypeID, "updateNewEncryptedMessage": UpdateNewEncryptedMessageTypeID, "updateEncryptedChatTyping": UpdateEncryptedChatTypingTypeID, "updateEncryption": UpdateEncryptionTypeID, @@ -1923,6 +1929,7 @@ func NamesMap() map[string]uint32 { "updateMessageExtendedMedia": UpdateMessageExtendedMediaTypeID, "updateChannelPinnedTopic": UpdateChannelPinnedTopicTypeID, "updateChannelPinnedTopics": UpdateChannelPinnedTopicsTypeID, + "updateUser": UpdateUserTypeID, "updates.state": UpdatesStateTypeID, "updates.differenceEmpty": UpdatesDifferenceEmptyTypeID, "updates.difference": UpdatesDifferenceTypeID, @@ -2211,6 +2218,7 @@ func NamesMap() map[string]uint32 { "stickerSetCovered": StickerSetCoveredTypeID, "stickerSetMultiCovered": StickerSetMultiCoveredTypeID, "stickerSetFullCovered": StickerSetFullCoveredTypeID, + "stickerSetNoCovered": StickerSetNoCoveredTypeID, "maskCoords": MaskCoordsTypeID, "inputStickeredMediaPhoto": InputStickeredMediaPhotoTypeID, "inputStickeredMediaDocument": InputStickeredMediaDocumentTypeID, @@ -2993,6 +3001,7 @@ func NamesMap() map[string]uint32 { "photos.uploadProfilePhoto": PhotosUploadProfilePhotoRequestTypeID, "photos.deletePhotos": PhotosDeletePhotosRequestTypeID, "photos.getUserPhotos": PhotosGetUserPhotosRequestTypeID, + "photos.uploadContactProfilePhoto": PhotosUploadContactProfilePhotoRequestTypeID, "upload.saveFilePart": UploadSaveFilePartRequestTypeID, "upload.getFile": UploadGetFileRequestTypeID, "upload.saveBigFilePart": UploadSaveBigFilePartRequestTypeID, @@ -3078,6 +3087,7 @@ func NamesMap() map[string]uint32 { "channels.reorderPinnedForumTopics": ChannelsReorderPinnedForumTopicsRequestTypeID, "channels.toggleAntiSpam": ChannelsToggleAntiSpamRequestTypeID, "channels.reportAntiSpamFalsePositive": ChannelsReportAntiSpamFalsePositiveRequestTypeID, + "channels.toggleParticipantsHidden": ChannelsToggleParticipantsHiddenRequestTypeID, "bots.sendCustomRequest": BotsSendCustomRequestRequestTypeID, "bots.answerWebhookJSONQuery": BotsAnswerWebhookJSONQueryRequestTypeID, "bots.setBotCommands": BotsSetBotCommandsRequestTypeID, @@ -3306,6 +3316,8 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MessageActionGiftPremiumTypeID: func() bin.Object { return &MessageActionGiftPremium{} }, MessageActionTopicCreateTypeID: func() bin.Object { return &MessageActionTopicCreate{} }, MessageActionTopicEditTypeID: func() bin.Object { return &MessageActionTopicEdit{} }, + MessageActionSuggestProfilePhotoTypeID: func() bin.Object { return &MessageActionSuggestProfilePhoto{} }, + MessageActionAttachMenuBotAllowedTypeID: func() bin.Object { return &MessageActionAttachMenuBotAllowed{} }, DialogTypeID: func() bin.Object { return &Dialog{} }, DialogFolderTypeID: func() bin.Object { return &DialogFolder{} }, PhotoEmptyTypeID: func() bin.Object { return &PhotoEmpty{} }, @@ -3387,7 +3399,6 @@ func TypesConstructorMap() map[uint32]func() bin.Object { UpdateChatParticipantsTypeID: func() bin.Object { return &UpdateChatParticipants{} }, UpdateUserStatusTypeID: func() bin.Object { return &UpdateUserStatus{} }, UpdateUserNameTypeID: func() bin.Object { return &UpdateUserName{} }, - UpdateUserPhotoTypeID: func() bin.Object { return &UpdateUserPhoto{} }, UpdateNewEncryptedMessageTypeID: func() bin.Object { return &UpdateNewEncryptedMessage{} }, UpdateEncryptedChatTypingTypeID: func() bin.Object { return &UpdateEncryptedChatTyping{} }, UpdateEncryptionTypeID: func() bin.Object { return &UpdateEncryption{} }, @@ -3488,6 +3499,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { UpdateMessageExtendedMediaTypeID: func() bin.Object { return &UpdateMessageExtendedMedia{} }, UpdateChannelPinnedTopicTypeID: func() bin.Object { return &UpdateChannelPinnedTopic{} }, UpdateChannelPinnedTopicsTypeID: func() bin.Object { return &UpdateChannelPinnedTopics{} }, + UpdateUserTypeID: func() bin.Object { return &UpdateUser{} }, UpdatesStateTypeID: func() bin.Object { return &UpdatesState{} }, UpdatesDifferenceEmptyTypeID: func() bin.Object { return &UpdatesDifferenceEmpty{} }, UpdatesDifferenceTypeID: func() bin.Object { return &UpdatesDifference{} }, @@ -3776,6 +3788,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { StickerSetCoveredTypeID: func() bin.Object { return &StickerSetCovered{} }, StickerSetMultiCoveredTypeID: func() bin.Object { return &StickerSetMultiCovered{} }, StickerSetFullCoveredTypeID: func() bin.Object { return &StickerSetFullCovered{} }, + StickerSetNoCoveredTypeID: func() bin.Object { return &StickerSetNoCovered{} }, MaskCoordsTypeID: func() bin.Object { return &MaskCoords{} }, InputStickeredMediaPhotoTypeID: func() bin.Object { return &InputStickeredMediaPhoto{} }, InputStickeredMediaDocumentTypeID: func() bin.Object { return &InputStickeredMediaDocument{} }, @@ -4558,6 +4571,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { PhotosUploadProfilePhotoRequestTypeID: func() bin.Object { return &PhotosUploadProfilePhotoRequest{} }, PhotosDeletePhotosRequestTypeID: func() bin.Object { return &PhotosDeletePhotosRequest{} }, PhotosGetUserPhotosRequestTypeID: func() bin.Object { return &PhotosGetUserPhotosRequest{} }, + PhotosUploadContactProfilePhotoRequestTypeID: func() bin.Object { return &PhotosUploadContactProfilePhotoRequest{} }, UploadSaveFilePartRequestTypeID: func() bin.Object { return &UploadSaveFilePartRequest{} }, UploadGetFileRequestTypeID: func() bin.Object { return &UploadGetFileRequest{} }, UploadSaveBigFilePartRequestTypeID: func() bin.Object { return &UploadSaveBigFilePartRequest{} }, @@ -4643,6 +4657,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { ChannelsReorderPinnedForumTopicsRequestTypeID: func() bin.Object { return &ChannelsReorderPinnedForumTopicsRequest{} }, ChannelsToggleAntiSpamRequestTypeID: func() bin.Object { return &ChannelsToggleAntiSpamRequest{} }, ChannelsReportAntiSpamFalsePositiveRequestTypeID: func() bin.Object { return &ChannelsReportAntiSpamFalsePositiveRequest{} }, + ChannelsToggleParticipantsHiddenRequestTypeID: func() bin.Object { return &ChannelsToggleParticipantsHiddenRequest{} }, BotsSendCustomRequestRequestTypeID: func() bin.Object { return &BotsSendCustomRequestRequest{} }, BotsAnswerWebhookJSONQueryRequestTypeID: func() bin.Object { return &BotsAnswerWebhookJSONQueryRequest{} }, BotsSetBotCommandsRequestTypeID: func() bin.Object { return &BotsSetBotCommandsRequest{} }, @@ -5333,6 +5348,8 @@ func ClassConstructorsMap() map[string][]uint32 { MessageActionGiftPremiumTypeID, MessageActionTopicCreateTypeID, MessageActionTopicEditTypeID, + MessageActionSuggestProfilePhotoTypeID, + MessageActionAttachMenuBotAllowedTypeID, }, MessageClassName: { MessageEmptyTypeID, @@ -5728,6 +5745,7 @@ func ClassConstructorsMap() map[string][]uint32 { StickerSetCoveredTypeID, StickerSetMultiCoveredTypeID, StickerSetFullCoveredTypeID, + StickerSetNoCoveredTypeID, }, StorageFileTypeClassName: { StorageFileUnknownTypeID, @@ -5765,7 +5783,6 @@ func ClassConstructorsMap() map[string][]uint32 { UpdateChatParticipantsTypeID, UpdateUserStatusTypeID, UpdateUserNameTypeID, - UpdateUserPhotoTypeID, UpdateNewEncryptedMessageTypeID, UpdateEncryptedChatTypingTypeID, UpdateEncryptionTypeID, @@ -5866,6 +5883,7 @@ func ClassConstructorsMap() map[string][]uint32 { UpdateMessageExtendedMediaTypeID, UpdateChannelPinnedTopicTypeID, UpdateChannelPinnedTopicsTypeID, + UpdateUserTypeID, }, UpdatesChannelDifferenceClassName: { UpdatesChannelDifferenceEmptyTypeID, diff --git a/tg/tl_reply_markup_gen.go b/tg/tl_reply_markup_gen.go index 060330d89b..f0e0c2e660 100644 --- a/tg/tl_reply_markup_gen.go +++ b/tg/tl_reply_markup_gen.go @@ -480,6 +480,8 @@ type ReplyKeyboardMarkup struct { // A user requests to change the bot's language, bot replies to the request with a // keyboard to select the new language. Other users in the group don't see the keyboard. Selective bool + // Persistent field of ReplyKeyboardMarkup. + Persistent bool // Button row Rows []KeyboardButtonRow // The placeholder to be shown in the input field when the keyboard is active; 1-64 @@ -521,6 +523,9 @@ func (r *ReplyKeyboardMarkup) Zero() bool { if !(r.Selective == false) { return false } + if !(r.Persistent == false) { + return false + } if !(r.Rows == nil) { return false } @@ -545,12 +550,14 @@ func (r *ReplyKeyboardMarkup) FillFrom(from interface { GetResize() (value bool) GetSingleUse() (value bool) GetSelective() (value bool) + GetPersistent() (value bool) GetRows() (value []KeyboardButtonRow) GetPlaceholder() (value string, ok bool) }) { r.Resize = from.GetResize() r.SingleUse = from.GetSingleUse() r.Selective = from.GetSelective() + r.Persistent = from.GetPersistent() r.Rows = from.GetRows() if val, ok := from.GetPlaceholder(); ok { r.Placeholder = val @@ -596,6 +603,11 @@ func (r *ReplyKeyboardMarkup) TypeInfo() tdp.Type { SchemaName: "selective", Null: !r.Flags.Has(2), }, + { + Name: "Persistent", + SchemaName: "persistent", + Null: !r.Flags.Has(4), + }, { Name: "Rows", SchemaName: "rows", @@ -620,6 +632,9 @@ func (r *ReplyKeyboardMarkup) SetFlags() { if !(r.Selective == false) { r.Flags.Set(2) } + if !(r.Persistent == false) { + r.Flags.Set(4) + } if !(r.Placeholder == "") { r.Flags.Set(3) } @@ -679,6 +694,7 @@ func (r *ReplyKeyboardMarkup) DecodeBare(b *bin.Buffer) error { r.Resize = r.Flags.Has(0) r.SingleUse = r.Flags.Has(1) r.Selective = r.Flags.Has(2) + r.Persistent = r.Flags.Has(4) { headerLen, err := b.VectorHeader() if err != nil { @@ -763,6 +779,25 @@ func (r *ReplyKeyboardMarkup) GetSelective() (value bool) { return r.Flags.Has(2) } +// SetPersistent sets value of Persistent conditional field. +func (r *ReplyKeyboardMarkup) SetPersistent(value bool) { + if value { + r.Flags.Set(4) + r.Persistent = true + } else { + r.Flags.Unset(4) + r.Persistent = false + } +} + +// GetPersistent returns value of Persistent conditional field. +func (r *ReplyKeyboardMarkup) GetPersistent() (value bool) { + if r == nil { + return + } + return r.Flags.Has(4) +} + // GetRows returns value of Rows field. func (r *ReplyKeyboardMarkup) GetRows() (value []KeyboardButtonRow) { if r == nil { diff --git a/tg/tl_server_gen.go b/tg/tl_server_gen.go index 816ab3eceb..71ee1b7479 100644 --- a/tg/tl_server_gen.go +++ b/tg/tl_server_gen.go @@ -5707,14 +5707,14 @@ func (s *ServerDispatcher) OnUpdatesGetChannelDifference(f func(ctx context.Cont s.handlers[UpdatesGetChannelDifferenceRequestTypeID] = handler } -func (s *ServerDispatcher) OnPhotosUpdateProfilePhoto(f func(ctx context.Context, id InputPhotoClass) (*PhotosPhoto, error)) { +func (s *ServerDispatcher) OnPhotosUpdateProfilePhoto(f func(ctx context.Context, request *PhotosUpdateProfilePhotoRequest) (*PhotosPhoto, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request PhotosUpdateProfilePhotoRequest if err := request.Decode(b); err != nil { return nil, err } - response, err := f(ctx, request.ID) + response, err := f(ctx, &request) if err != nil { return nil, err } @@ -5775,6 +5775,23 @@ func (s *ServerDispatcher) OnPhotosGetUserPhotos(f func(ctx context.Context, req s.handlers[PhotosGetUserPhotosRequestTypeID] = handler } +func (s *ServerDispatcher) OnPhotosUploadContactProfilePhoto(f func(ctx context.Context, request *PhotosUploadContactProfilePhotoRequest) (*PhotosPhoto, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request PhotosUploadContactProfilePhotoRequest + 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[PhotosUploadContactProfilePhotoRequestTypeID] = handler +} + func (s *ServerDispatcher) OnUploadSaveFilePart(f func(ctx context.Context, request *UploadSaveFilePartRequest) (bool, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request UploadSaveFilePartRequest @@ -7300,6 +7317,23 @@ func (s *ServerDispatcher) OnChannelsReportAntiSpamFalsePositive(f func(ctx cont s.handlers[ChannelsReportAntiSpamFalsePositiveRequestTypeID] = handler } +func (s *ServerDispatcher) OnChannelsToggleParticipantsHidden(f func(ctx context.Context, request *ChannelsToggleParticipantsHiddenRequest) (UpdatesClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request ChannelsToggleParticipantsHiddenRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return &UpdatesBox{Updates: response}, nil + } + + s.handlers[ChannelsToggleParticipantsHiddenRequestTypeID] = handler +} + func (s *ServerDispatcher) OnBotsSendCustomRequest(f func(ctx context.Context, request *BotsSendCustomRequestRequest) (*DataJSON, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request BotsSendCustomRequestRequest diff --git a/tg/tl_sticker_set_covered_gen.go b/tg/tl_sticker_set_covered_gen.go index 30d2f5daec..51c2f8fcf5 100644 --- a/tg/tl_sticker_set_covered_gen.go +++ b/tg/tl_sticker_set_covered_gen.go @@ -658,6 +658,140 @@ func (s *StickerSetFullCovered) MapDocuments() (value DocumentClassArray) { return DocumentClassArray(s.Documents) } +// StickerSetNoCovered represents TL type `stickerSetNoCovered#77b15d1c`. +// +// See https://core.telegram.org/constructor/stickerSetNoCovered for reference. +type StickerSetNoCovered struct { + // Set field of StickerSetNoCovered. + Set StickerSet +} + +// StickerSetNoCoveredTypeID is TL type id of StickerSetNoCovered. +const StickerSetNoCoveredTypeID = 0x77b15d1c + +// construct implements constructor of StickerSetCoveredClass. +func (s StickerSetNoCovered) construct() StickerSetCoveredClass { return &s } + +// Ensuring interfaces in compile-time for StickerSetNoCovered. +var ( + _ bin.Encoder = &StickerSetNoCovered{} + _ bin.Decoder = &StickerSetNoCovered{} + _ bin.BareEncoder = &StickerSetNoCovered{} + _ bin.BareDecoder = &StickerSetNoCovered{} + + _ StickerSetCoveredClass = &StickerSetNoCovered{} +) + +func (s *StickerSetNoCovered) Zero() bool { + if s == nil { + return true + } + if !(s.Set.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StickerSetNoCovered) String() string { + if s == nil { + return "StickerSetNoCovered(nil)" + } + type Alias StickerSetNoCovered + return fmt.Sprintf("StickerSetNoCovered%+v", Alias(*s)) +} + +// FillFrom fills StickerSetNoCovered from given interface. +func (s *StickerSetNoCovered) FillFrom(from interface { + GetSet() (value StickerSet) +}) { + s.Set = from.GetSet() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StickerSetNoCovered) TypeID() uint32 { + return StickerSetNoCoveredTypeID +} + +// TypeName returns name of type in TL schema. +func (*StickerSetNoCovered) TypeName() string { + return "stickerSetNoCovered" +} + +// TypeInfo returns info about TL type. +func (s *StickerSetNoCovered) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "stickerSetNoCovered", + ID: StickerSetNoCoveredTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Set", + SchemaName: "set", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StickerSetNoCovered) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode stickerSetNoCovered#77b15d1c as nil") + } + b.PutID(StickerSetNoCoveredTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StickerSetNoCovered) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode stickerSetNoCovered#77b15d1c as nil") + } + if err := s.Set.Encode(b); err != nil { + return fmt.Errorf("unable to encode stickerSetNoCovered#77b15d1c: field set: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StickerSetNoCovered) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode stickerSetNoCovered#77b15d1c to nil") + } + if err := b.ConsumeID(StickerSetNoCoveredTypeID); err != nil { + return fmt.Errorf("unable to decode stickerSetNoCovered#77b15d1c: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StickerSetNoCovered) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode stickerSetNoCovered#77b15d1c to nil") + } + { + if err := s.Set.Decode(b); err != nil { + return fmt.Errorf("unable to decode stickerSetNoCovered#77b15d1c: field set: %w", err) + } + } + return nil +} + +// GetSet returns value of Set field. +func (s *StickerSetNoCovered) GetSet() (value StickerSet) { + if s == nil { + return + } + return s.Set +} + // StickerSetCoveredClassName is schema name of StickerSetCoveredClass. const StickerSetCoveredClassName = "StickerSetCovered" @@ -675,6 +809,7 @@ const StickerSetCoveredClassName = "StickerSetCovered" // case *tg.StickerSetCovered: // stickerSetCovered#6410a5d2 // case *tg.StickerSetMultiCovered: // stickerSetMultiCovered#3407e51b // case *tg.StickerSetFullCovered: // stickerSetFullCovered#40d13c0e +// case *tg.StickerSetNoCovered: // stickerSetNoCovered#77b15d1c // default: panic(v) // } type StickerSetCoveredClass interface { @@ -727,6 +862,13 @@ func DecodeStickerSetCovered(buf *bin.Buffer) (StickerSetCoveredClass, error) { return nil, fmt.Errorf("unable to decode StickerSetCoveredClass: %w", err) } return &v, nil + case StickerSetNoCoveredTypeID: + // Decoding stickerSetNoCovered#77b15d1c. + v := StickerSetNoCovered{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StickerSetCoveredClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode StickerSetCoveredClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_sticker_set_covered_slices_gen.go b/tg/tl_sticker_set_covered_slices_gen.go index 12b3f9bd9f..174693d9ec 100644 --- a/tg/tl_sticker_set_covered_slices_gen.go +++ b/tg/tl_sticker_set_covered_slices_gen.go @@ -155,6 +155,19 @@ func (s StickerSetCoveredClassArray) AsStickerSetFullCovered() (to StickerSetFul return to } +// AsStickerSetNoCovered returns copy with only StickerSetNoCovered constructors. +func (s StickerSetCoveredClassArray) AsStickerSetNoCovered() (to StickerSetNoCoveredArray) { + for _, elem := range s { + value, ok := elem.(*StickerSetNoCovered) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // StickerSetCoveredArray is adapter for slice of StickerSetCovered. type StickerSetCoveredArray []StickerSetCovered @@ -400,3 +413,85 @@ func (s *StickerSetFullCoveredArray) Pop() (v StickerSetFullCovered, ok bool) { return v, true } + +// StickerSetNoCoveredArray is adapter for slice of StickerSetNoCovered. +type StickerSetNoCoveredArray []StickerSetNoCovered + +// Sort sorts slice of StickerSetNoCovered. +func (s StickerSetNoCoveredArray) Sort(less func(a, b StickerSetNoCovered) bool) StickerSetNoCoveredArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of StickerSetNoCovered. +func (s StickerSetNoCoveredArray) SortStable(less func(a, b StickerSetNoCovered) bool) StickerSetNoCoveredArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of StickerSetNoCovered. +func (s StickerSetNoCoveredArray) Retain(keep func(x StickerSetNoCovered) bool) StickerSetNoCoveredArray { + 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 StickerSetNoCoveredArray) First() (v StickerSetNoCovered, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s StickerSetNoCoveredArray) Last() (v StickerSetNoCovered, 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 *StickerSetNoCoveredArray) PopFirst() (v StickerSetNoCovered, 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 StickerSetNoCovered + 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 *StickerSetNoCoveredArray) Pop() (v StickerSetNoCovered, 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_update_gen.go b/tg/tl_update_gen.go index f1d1094d5d..55cb4951d9 100644 --- a/tg/tl_update_gen.go +++ b/tg/tl_update_gen.go @@ -1514,230 +1514,6 @@ func (u *UpdateUserName) GetUsernames() (value []Username) { return u.Usernames } -// UpdateUserPhoto represents TL type `updateUserPhoto#f227868c`. -// Change of contact's profile photo. -// -// See https://core.telegram.org/constructor/updateUserPhoto for reference. -type UpdateUserPhoto struct { - // User identifier - UserID int64 - // Date of photo update. - Date int - // New profile photo - Photo UserProfilePhotoClass - // (boolTrue¹), if one of the previously used photos is set a profile photo. - // - // Links: - // 1) https://core.telegram.org/constructor/boolTrue - Previous bool -} - -// UpdateUserPhotoTypeID is TL type id of UpdateUserPhoto. -const UpdateUserPhotoTypeID = 0xf227868c - -// construct implements constructor of UpdateClass. -func (u UpdateUserPhoto) construct() UpdateClass { return &u } - -// Ensuring interfaces in compile-time for UpdateUserPhoto. -var ( - _ bin.Encoder = &UpdateUserPhoto{} - _ bin.Decoder = &UpdateUserPhoto{} - _ bin.BareEncoder = &UpdateUserPhoto{} - _ bin.BareDecoder = &UpdateUserPhoto{} - - _ UpdateClass = &UpdateUserPhoto{} -) - -func (u *UpdateUserPhoto) Zero() bool { - if u == nil { - return true - } - if !(u.UserID == 0) { - return false - } - if !(u.Date == 0) { - return false - } - if !(u.Photo == nil) { - return false - } - if !(u.Previous == false) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (u *UpdateUserPhoto) String() string { - if u == nil { - return "UpdateUserPhoto(nil)" - } - type Alias UpdateUserPhoto - return fmt.Sprintf("UpdateUserPhoto%+v", Alias(*u)) -} - -// FillFrom fills UpdateUserPhoto from given interface. -func (u *UpdateUserPhoto) FillFrom(from interface { - GetUserID() (value int64) - GetDate() (value int) - GetPhoto() (value UserProfilePhotoClass) - GetPrevious() (value bool) -}) { - u.UserID = from.GetUserID() - u.Date = from.GetDate() - u.Photo = from.GetPhoto() - u.Previous = from.GetPrevious() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*UpdateUserPhoto) TypeID() uint32 { - return UpdateUserPhotoTypeID -} - -// TypeName returns name of type in TL schema. -func (*UpdateUserPhoto) TypeName() string { - return "updateUserPhoto" -} - -// TypeInfo returns info about TL type. -func (u *UpdateUserPhoto) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "updateUserPhoto", - ID: UpdateUserPhotoTypeID, - } - if u == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "UserID", - SchemaName: "user_id", - }, - { - Name: "Date", - SchemaName: "date", - }, - { - Name: "Photo", - SchemaName: "photo", - }, - { - Name: "Previous", - SchemaName: "previous", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (u *UpdateUserPhoto) Encode(b *bin.Buffer) error { - if u == nil { - return fmt.Errorf("can't encode updateUserPhoto#f227868c as nil") - } - b.PutID(UpdateUserPhotoTypeID) - return u.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (u *UpdateUserPhoto) EncodeBare(b *bin.Buffer) error { - if u == nil { - return fmt.Errorf("can't encode updateUserPhoto#f227868c as nil") - } - b.PutLong(u.UserID) - b.PutInt(u.Date) - if u.Photo == nil { - return fmt.Errorf("unable to encode updateUserPhoto#f227868c: field photo is nil") - } - if err := u.Photo.Encode(b); err != nil { - return fmt.Errorf("unable to encode updateUserPhoto#f227868c: field photo: %w", err) - } - b.PutBool(u.Previous) - return nil -} - -// Decode implements bin.Decoder. -func (u *UpdateUserPhoto) Decode(b *bin.Buffer) error { - if u == nil { - return fmt.Errorf("can't decode updateUserPhoto#f227868c to nil") - } - if err := b.ConsumeID(UpdateUserPhotoTypeID); err != nil { - return fmt.Errorf("unable to decode updateUserPhoto#f227868c: %w", err) - } - return u.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (u *UpdateUserPhoto) DecodeBare(b *bin.Buffer) error { - if u == nil { - return fmt.Errorf("can't decode updateUserPhoto#f227868c to nil") - } - { - value, err := b.Long() - if err != nil { - return fmt.Errorf("unable to decode updateUserPhoto#f227868c: field user_id: %w", err) - } - u.UserID = value - } - { - value, err := b.Int() - if err != nil { - return fmt.Errorf("unable to decode updateUserPhoto#f227868c: field date: %w", err) - } - u.Date = value - } - { - value, err := DecodeUserProfilePhoto(b) - if err != nil { - return fmt.Errorf("unable to decode updateUserPhoto#f227868c: field photo: %w", err) - } - u.Photo = value - } - { - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode updateUserPhoto#f227868c: field previous: %w", err) - } - u.Previous = value - } - return nil -} - -// GetUserID returns value of UserID field. -func (u *UpdateUserPhoto) GetUserID() (value int64) { - if u == nil { - return - } - return u.UserID -} - -// GetDate returns value of Date field. -func (u *UpdateUserPhoto) GetDate() (value int) { - if u == nil { - return - } - return u.Date -} - -// GetPhoto returns value of Photo field. -func (u *UpdateUserPhoto) GetPhoto() (value UserProfilePhotoClass) { - if u == nil { - return - } - return u.Photo -} - -// GetPrevious returns value of Previous field. -func (u *UpdateUserPhoto) GetPrevious() (value bool) { - if u == nil { - return - } - return u.Previous -} - // UpdateNewEncryptedMessage represents TL type `updateNewEncryptedMessage#12bcbd9a`. // New encrypted message. // @@ -21885,6 +21661,140 @@ func (u *UpdateChannelPinnedTopics) GetOrder() (value []int, ok bool) { return u.Order, true } +// UpdateUser represents TL type `updateUser#20529438`. +// +// See https://core.telegram.org/constructor/updateUser for reference. +type UpdateUser struct { + // UserID field of UpdateUser. + UserID int64 +} + +// UpdateUserTypeID is TL type id of UpdateUser. +const UpdateUserTypeID = 0x20529438 + +// construct implements constructor of UpdateClass. +func (u UpdateUser) construct() UpdateClass { return &u } + +// Ensuring interfaces in compile-time for UpdateUser. +var ( + _ bin.Encoder = &UpdateUser{} + _ bin.Decoder = &UpdateUser{} + _ bin.BareEncoder = &UpdateUser{} + _ bin.BareDecoder = &UpdateUser{} + + _ UpdateClass = &UpdateUser{} +) + +func (u *UpdateUser) Zero() bool { + if u == nil { + return true + } + if !(u.UserID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *UpdateUser) String() string { + if u == nil { + return "UpdateUser(nil)" + } + type Alias UpdateUser + return fmt.Sprintf("UpdateUser%+v", Alias(*u)) +} + +// FillFrom fills UpdateUser from given interface. +func (u *UpdateUser) FillFrom(from interface { + GetUserID() (value int64) +}) { + u.UserID = from.GetUserID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*UpdateUser) TypeID() uint32 { + return UpdateUserTypeID +} + +// TypeName returns name of type in TL schema. +func (*UpdateUser) TypeName() string { + return "updateUser" +} + +// TypeInfo returns info about TL type. +func (u *UpdateUser) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "updateUser", + ID: UpdateUserTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (u *UpdateUser) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateUser#20529438 as nil") + } + b.PutID(UpdateUserTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *UpdateUser) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateUser#20529438 as nil") + } + b.PutLong(u.UserID) + return nil +} + +// Decode implements bin.Decoder. +func (u *UpdateUser) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateUser#20529438 to nil") + } + if err := b.ConsumeID(UpdateUserTypeID); err != nil { + return fmt.Errorf("unable to decode updateUser#20529438: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *UpdateUser) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateUser#20529438 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode updateUser#20529438: field user_id: %w", err) + } + u.UserID = value + } + return nil +} + +// GetUserID returns value of UserID field. +func (u *UpdateUser) GetUserID() (value int64) { + if u == nil { + return + } + return u.UserID +} + // UpdateClassName is schema name of UpdateClass. const UpdateClassName = "Update" @@ -21907,7 +21817,6 @@ const UpdateClassName = "Update" // case *tg.UpdateChatParticipants: // updateChatParticipants#7761198 // case *tg.UpdateUserStatus: // updateUserStatus#e5bdf8de // case *tg.UpdateUserName: // updateUserName#a7848924 -// case *tg.UpdateUserPhoto: // updateUserPhoto#f227868c // case *tg.UpdateNewEncryptedMessage: // updateNewEncryptedMessage#12bcbd9a // case *tg.UpdateEncryptedChatTyping: // updateEncryptedChatTyping#1710f156 // case *tg.UpdateEncryption: // updateEncryption#b4a2e88d @@ -22008,6 +21917,7 @@ const UpdateClassName = "Update" // case *tg.UpdateMessageExtendedMedia: // updateMessageExtendedMedia#5a73a98c // case *tg.UpdateChannelPinnedTopic: // updateChannelPinnedTopic#192efbe3 // case *tg.UpdateChannelPinnedTopics: // updateChannelPinnedTopics#fe198602 +// case *tg.UpdateUser: // updateUser#20529438 // default: panic(v) // } type UpdateClass interface { @@ -22092,13 +22002,6 @@ func DecodeUpdate(buf *bin.Buffer) (UpdateClass, error) { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) } return &v, nil - case UpdateUserPhotoTypeID: - // Decoding updateUserPhoto#f227868c. - v := UpdateUserPhoto{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) - } - return &v, nil case UpdateNewEncryptedMessageTypeID: // Decoding updateNewEncryptedMessage#12bcbd9a. v := UpdateNewEncryptedMessage{} @@ -22799,6 +22702,13 @@ func DecodeUpdate(buf *bin.Buffer) (UpdateClass, error) { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) } return &v, nil + case UpdateUserTypeID: + // Decoding updateUser#20529438. + v := UpdateUser{} + 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 55da98fd3c..df3f4db6c9 100644 --- a/tg/tl_update_slices_gen.go +++ b/tg/tl_update_slices_gen.go @@ -220,19 +220,6 @@ func (s UpdateClassArray) AsUpdateUserName() (to UpdateUserNameArray) { return to } -// AsUpdateUserPhoto returns copy with only UpdateUserPhoto constructors. -func (s UpdateClassArray) AsUpdateUserPhoto() (to UpdateUserPhotoArray) { - for _, elem := range s { - value, ok := elem.(*UpdateUserPhoto) - if !ok { - continue - } - to = append(to, *value) - } - - return to -} - // AsUpdateNewEncryptedMessage returns copy with only UpdateNewEncryptedMessage constructors. func (s UpdateClassArray) AsUpdateNewEncryptedMessage() (to UpdateNewEncryptedMessageArray) { for _, elem := range s { @@ -1351,6 +1338,19 @@ func (s UpdateClassArray) AsUpdateChannelPinnedTopics() (to UpdateChannelPinnedT return to } +// AsUpdateUser returns copy with only UpdateUser constructors. +func (s UpdateClassArray) AsUpdateUser() (to UpdateUserArray) { + for _, elem := range s { + value, ok := elem.(*UpdateUser) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // UpdateNewMessageArray is adapter for slice of UpdateNewMessage. type UpdateNewMessageArray []UpdateNewMessage @@ -2035,102 +2035,6 @@ func (s *UpdateUserNameArray) Pop() (v UpdateUserName, ok bool) { return v, true } -// UpdateUserPhotoArray is adapter for slice of UpdateUserPhoto. -type UpdateUserPhotoArray []UpdateUserPhoto - -// Sort sorts slice of UpdateUserPhoto. -func (s UpdateUserPhotoArray) Sort(less func(a, b UpdateUserPhoto) bool) UpdateUserPhotoArray { - sort.Slice(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// SortStable sorts slice of UpdateUserPhoto. -func (s UpdateUserPhotoArray) SortStable(less func(a, b UpdateUserPhoto) bool) UpdateUserPhotoArray { - sort.SliceStable(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// Retain filters in-place slice of UpdateUserPhoto. -func (s UpdateUserPhotoArray) Retain(keep func(x UpdateUserPhoto) bool) UpdateUserPhotoArray { - 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 UpdateUserPhotoArray) First() (v UpdateUserPhoto, ok bool) { - if len(s) < 1 { - return - } - return s[0], true -} - -// Last returns last element of slice (if exists). -func (s UpdateUserPhotoArray) Last() (v UpdateUserPhoto, 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 *UpdateUserPhotoArray) PopFirst() (v UpdateUserPhoto, 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 UpdateUserPhoto - 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 *UpdateUserPhotoArray) Pop() (v UpdateUserPhoto, 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 -} - -// SortByDate sorts slice of UpdateUserPhoto by Date. -func (s UpdateUserPhotoArray) SortByDate() UpdateUserPhotoArray { - return s.Sort(func(a, b UpdateUserPhoto) bool { - return a.GetDate() < b.GetDate() - }) -} - -// SortStableByDate sorts slice of UpdateUserPhoto by Date. -func (s UpdateUserPhotoArray) SortStableByDate() UpdateUserPhotoArray { - return s.SortStable(func(a, b UpdateUserPhoto) bool { - return a.GetDate() < b.GetDate() - }) -} - // UpdateNewEncryptedMessageArray is adapter for slice of UpdateNewEncryptedMessage. type UpdateNewEncryptedMessageArray []UpdateNewEncryptedMessage @@ -9364,3 +9268,85 @@ func (s *UpdateChannelPinnedTopicsArray) Pop() (v UpdateChannelPinnedTopics, ok return v, true } + +// UpdateUserArray is adapter for slice of UpdateUser. +type UpdateUserArray []UpdateUser + +// Sort sorts slice of UpdateUser. +func (s UpdateUserArray) Sort(less func(a, b UpdateUser) bool) UpdateUserArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of UpdateUser. +func (s UpdateUserArray) SortStable(less func(a, b UpdateUser) bool) UpdateUserArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of UpdateUser. +func (s UpdateUserArray) Retain(keep func(x UpdateUser) bool) UpdateUserArray { + 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 UpdateUserArray) First() (v UpdateUser, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s UpdateUserArray) Last() (v UpdateUser, 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 *UpdateUserArray) PopFirst() (v UpdateUser, 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 UpdateUser + 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 *UpdateUserArray) Pop() (v UpdateUser, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_user_full_gen.go b/tg/tl_user_full_gen.go index 167afa916b..664c445f76 100644 --- a/tg/tl_user_full_gen.go +++ b/tg/tl_user_full_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// UserFull represents TL type `userFull#c4b1fc3f`. +// UserFull represents TL type `userFull#f8d32aed`. // Extended user info // // See https://core.telegram.org/constructor/userFull for reference. @@ -67,10 +67,18 @@ type UserFull struct { About string // Peer settings Settings PeerSettings + // PersonalPhoto field of UserFull. + // + // Use SetPersonalPhoto and GetPersonalPhoto helpers. + PersonalPhoto PhotoClass // Profile photo // // Use SetProfilePhoto and GetProfilePhoto helpers. ProfilePhoto PhotoClass + // FallbackPhoto field of UserFull. + // + // Use SetFallbackPhoto and GetFallbackPhoto helpers. + FallbackPhoto PhotoClass // Notification settings NotifySettings PeerNotifySettings // For bots, info about the bot (bot commands, etc) @@ -131,7 +139,7 @@ type UserFull struct { } // UserFullTypeID is TL type id of UserFull. -const UserFullTypeID = 0xc4b1fc3f +const UserFullTypeID = 0xf8d32aed // Ensuring interfaces in compile-time for UserFull. var ( @@ -178,9 +186,15 @@ func (u *UserFull) Zero() bool { if !(u.Settings.Zero()) { return false } + if !(u.PersonalPhoto == nil) { + return false + } if !(u.ProfilePhoto == nil) { return false } + if !(u.FallbackPhoto == nil) { + return false + } if !(u.NotifySettings.Zero()) { return false } @@ -239,7 +253,9 @@ func (u *UserFull) FillFrom(from interface { GetID() (value int64) GetAbout() (value string, ok bool) GetSettings() (value PeerSettings) + GetPersonalPhoto() (value PhotoClass, ok bool) GetProfilePhoto() (value PhotoClass, ok bool) + GetFallbackPhoto() (value PhotoClass, ok bool) GetNotifySettings() (value PeerNotifySettings) GetBotInfo() (value BotInfo, ok bool) GetPinnedMsgID() (value int, ok bool) @@ -265,10 +281,18 @@ func (u *UserFull) FillFrom(from interface { } u.Settings = from.GetSettings() + if val, ok := from.GetPersonalPhoto(); ok { + u.PersonalPhoto = val + } + if val, ok := from.GetProfilePhoto(); ok { u.ProfilePhoto = val } + if val, ok := from.GetFallbackPhoto(); ok { + u.FallbackPhoto = val + } + u.NotifySettings = from.GetNotifySettings() if val, ok := from.GetBotInfo(); ok { u.BotInfo = val @@ -380,11 +404,21 @@ func (u *UserFull) TypeInfo() tdp.Type { Name: "Settings", SchemaName: "settings", }, + { + Name: "PersonalPhoto", + SchemaName: "personal_photo", + Null: !u.Flags.Has(21), + }, { Name: "ProfilePhoto", SchemaName: "profile_photo", Null: !u.Flags.Has(2), }, + { + Name: "FallbackPhoto", + SchemaName: "fallback_photo", + Null: !u.Flags.Has(22), + }, { Name: "NotifySettings", SchemaName: "notify_settings", @@ -468,9 +502,15 @@ func (u *UserFull) SetFlags() { if !(u.About == "") { u.Flags.Set(1) } + if !(u.PersonalPhoto == nil) { + u.Flags.Set(21) + } if !(u.ProfilePhoto == nil) { u.Flags.Set(2) } + if !(u.FallbackPhoto == nil) { + u.Flags.Set(22) + } if !(u.BotInfo.Zero()) { u.Flags.Set(3) } @@ -503,7 +543,7 @@ func (u *UserFull) SetFlags() { // Encode implements bin.Encoder. func (u *UserFull) Encode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode userFull#c4b1fc3f as nil") + return fmt.Errorf("can't encode userFull#f8d32aed as nil") } b.PutID(UserFullTypeID) return u.EncodeBare(b) @@ -512,33 +552,49 @@ func (u *UserFull) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (u *UserFull) EncodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode userFull#c4b1fc3f as nil") + return fmt.Errorf("can't encode userFull#f8d32aed as nil") } u.SetFlags() if err := u.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#c4b1fc3f: field flags: %w", err) + return fmt.Errorf("unable to encode userFull#f8d32aed: field flags: %w", err) } b.PutLong(u.ID) if u.Flags.Has(1) { b.PutString(u.About) } if err := u.Settings.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#c4b1fc3f: field settings: %w", err) + return fmt.Errorf("unable to encode userFull#f8d32aed: field settings: %w", err) + } + if u.Flags.Has(21) { + if u.PersonalPhoto == nil { + return fmt.Errorf("unable to encode userFull#f8d32aed: field personal_photo is nil") + } + if err := u.PersonalPhoto.Encode(b); err != nil { + return fmt.Errorf("unable to encode userFull#f8d32aed: field personal_photo: %w", err) + } } if u.Flags.Has(2) { if u.ProfilePhoto == nil { - return fmt.Errorf("unable to encode userFull#c4b1fc3f: field profile_photo is nil") + return fmt.Errorf("unable to encode userFull#f8d32aed: field profile_photo is nil") } if err := u.ProfilePhoto.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#c4b1fc3f: field profile_photo: %w", err) + return fmt.Errorf("unable to encode userFull#f8d32aed: field profile_photo: %w", err) + } + } + if u.Flags.Has(22) { + if u.FallbackPhoto == nil { + return fmt.Errorf("unable to encode userFull#f8d32aed: field fallback_photo is nil") + } + if err := u.FallbackPhoto.Encode(b); err != nil { + return fmt.Errorf("unable to encode userFull#f8d32aed: field fallback_photo: %w", err) } } if err := u.NotifySettings.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#c4b1fc3f: field notify_settings: %w", err) + return fmt.Errorf("unable to encode userFull#f8d32aed: field notify_settings: %w", err) } if u.Flags.Has(3) { if err := u.BotInfo.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#c4b1fc3f: field bot_info: %w", err) + return fmt.Errorf("unable to encode userFull#f8d32aed: field bot_info: %w", err) } } if u.Flags.Has(6) { @@ -559,19 +615,19 @@ func (u *UserFull) EncodeBare(b *bin.Buffer) error { } if u.Flags.Has(17) { if err := u.BotGroupAdminRights.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#c4b1fc3f: field bot_group_admin_rights: %w", err) + return fmt.Errorf("unable to encode userFull#f8d32aed: field bot_group_admin_rights: %w", err) } } if u.Flags.Has(18) { if err := u.BotBroadcastAdminRights.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#c4b1fc3f: field bot_broadcast_admin_rights: %w", err) + return fmt.Errorf("unable to encode userFull#f8d32aed: field bot_broadcast_admin_rights: %w", err) } } if u.Flags.Has(19) { b.PutVectorHeader(len(u.PremiumGifts)) for idx, v := range u.PremiumGifts { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#c4b1fc3f: field premium_gifts element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode userFull#f8d32aed: field premium_gifts element with index %d: %w", idx, err) } } } @@ -581,10 +637,10 @@ func (u *UserFull) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (u *UserFull) Decode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode userFull#c4b1fc3f to nil") + return fmt.Errorf("can't decode userFull#f8d32aed to nil") } if err := b.ConsumeID(UserFullTypeID); err != nil { - return fmt.Errorf("unable to decode userFull#c4b1fc3f: %w", err) + return fmt.Errorf("unable to decode userFull#f8d32aed: %w", err) } return u.DecodeBare(b) } @@ -592,11 +648,11 @@ func (u *UserFull) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (u *UserFull) DecodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode userFull#c4b1fc3f to nil") + return fmt.Errorf("can't decode userFull#f8d32aed to nil") } { if err := u.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#c4b1fc3f: field flags: %w", err) + return fmt.Errorf("unable to decode userFull#f8d32aed: field flags: %w", err) } } u.Blocked = u.Flags.Has(0) @@ -609,95 +665,109 @@ func (u *UserFull) DecodeBare(b *bin.Buffer) error { { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode userFull#c4b1fc3f: field id: %w", err) + return fmt.Errorf("unable to decode userFull#f8d32aed: field id: %w", err) } u.ID = value } if u.Flags.Has(1) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode userFull#c4b1fc3f: field about: %w", err) + return fmt.Errorf("unable to decode userFull#f8d32aed: field about: %w", err) } u.About = value } { if err := u.Settings.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#c4b1fc3f: field settings: %w", err) + return fmt.Errorf("unable to decode userFull#f8d32aed: field settings: %w", err) } } + if u.Flags.Has(21) { + value, err := DecodePhoto(b) + if err != nil { + return fmt.Errorf("unable to decode userFull#f8d32aed: field personal_photo: %w", err) + } + u.PersonalPhoto = value + } if u.Flags.Has(2) { value, err := DecodePhoto(b) if err != nil { - return fmt.Errorf("unable to decode userFull#c4b1fc3f: field profile_photo: %w", err) + return fmt.Errorf("unable to decode userFull#f8d32aed: field profile_photo: %w", err) } u.ProfilePhoto = value } + if u.Flags.Has(22) { + value, err := DecodePhoto(b) + if err != nil { + return fmt.Errorf("unable to decode userFull#f8d32aed: field fallback_photo: %w", err) + } + u.FallbackPhoto = value + } { if err := u.NotifySettings.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#c4b1fc3f: field notify_settings: %w", err) + return fmt.Errorf("unable to decode userFull#f8d32aed: field notify_settings: %w", err) } } if u.Flags.Has(3) { if err := u.BotInfo.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#c4b1fc3f: field bot_info: %w", err) + return fmt.Errorf("unable to decode userFull#f8d32aed: field bot_info: %w", err) } } if u.Flags.Has(6) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode userFull#c4b1fc3f: field pinned_msg_id: %w", err) + return fmt.Errorf("unable to decode userFull#f8d32aed: field pinned_msg_id: %w", err) } u.PinnedMsgID = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode userFull#c4b1fc3f: field common_chats_count: %w", err) + return fmt.Errorf("unable to decode userFull#f8d32aed: field common_chats_count: %w", err) } u.CommonChatsCount = value } if u.Flags.Has(11) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode userFull#c4b1fc3f: field folder_id: %w", err) + return fmt.Errorf("unable to decode userFull#f8d32aed: field folder_id: %w", err) } u.FolderID = value } if u.Flags.Has(14) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode userFull#c4b1fc3f: field ttl_period: %w", err) + return fmt.Errorf("unable to decode userFull#f8d32aed: field ttl_period: %w", err) } u.TTLPeriod = value } if u.Flags.Has(15) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode userFull#c4b1fc3f: field theme_emoticon: %w", err) + return fmt.Errorf("unable to decode userFull#f8d32aed: field theme_emoticon: %w", err) } u.ThemeEmoticon = value } if u.Flags.Has(16) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode userFull#c4b1fc3f: field private_forward_name: %w", err) + return fmt.Errorf("unable to decode userFull#f8d32aed: field private_forward_name: %w", err) } u.PrivateForwardName = value } if u.Flags.Has(17) { if err := u.BotGroupAdminRights.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#c4b1fc3f: field bot_group_admin_rights: %w", err) + return fmt.Errorf("unable to decode userFull#f8d32aed: field bot_group_admin_rights: %w", err) } } if u.Flags.Has(18) { if err := u.BotBroadcastAdminRights.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#c4b1fc3f: field bot_broadcast_admin_rights: %w", err) + return fmt.Errorf("unable to decode userFull#f8d32aed: field bot_broadcast_admin_rights: %w", err) } } if u.Flags.Has(19) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode userFull#c4b1fc3f: field premium_gifts: %w", err) + return fmt.Errorf("unable to decode userFull#f8d32aed: field premium_gifts: %w", err) } if headerLen > 0 { @@ -706,7 +776,7 @@ func (u *UserFull) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value PremiumGiftOption if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#c4b1fc3f: field premium_gifts: %w", err) + return fmt.Errorf("unable to decode userFull#f8d32aed: field premium_gifts: %w", err) } u.PremiumGifts = append(u.PremiumGifts, value) } @@ -881,6 +951,24 @@ func (u *UserFull) GetSettings() (value PeerSettings) { return u.Settings } +// SetPersonalPhoto sets value of PersonalPhoto conditional field. +func (u *UserFull) SetPersonalPhoto(value PhotoClass) { + u.Flags.Set(21) + u.PersonalPhoto = value +} + +// GetPersonalPhoto returns value of PersonalPhoto conditional field and +// boolean which is true if field was set. +func (u *UserFull) GetPersonalPhoto() (value PhotoClass, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(21) { + return value, false + } + return u.PersonalPhoto, true +} + // SetProfilePhoto sets value of ProfilePhoto conditional field. func (u *UserFull) SetProfilePhoto(value PhotoClass) { u.Flags.Set(2) @@ -899,6 +987,24 @@ func (u *UserFull) GetProfilePhoto() (value PhotoClass, ok bool) { return u.ProfilePhoto, true } +// SetFallbackPhoto sets value of FallbackPhoto conditional field. +func (u *UserFull) SetFallbackPhoto(value PhotoClass) { + u.Flags.Set(22) + u.FallbackPhoto = value +} + +// GetFallbackPhoto returns value of FallbackPhoto conditional field and +// boolean which is true if field was set. +func (u *UserFull) GetFallbackPhoto() (value PhotoClass, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(22) { + return value, false + } + return u.FallbackPhoto, true +} + // GetNotifySettings returns value of NotifySettings field. func (u *UserFull) GetNotifySettings() (value PeerNotifySettings) { if u == nil { @@ -1077,6 +1183,15 @@ func (u *UserFull) GetPremiumGifts() (value []PremiumGiftOption, ok bool) { return u.PremiumGifts, true } +// GetPersonalPhotoAsNotEmpty returns mapped value of PersonalPhoto conditional field and +// boolean which is true if field was set. +func (u *UserFull) GetPersonalPhotoAsNotEmpty() (*Photo, bool) { + if value, ok := u.GetPersonalPhoto(); ok { + return value.AsNotEmpty() + } + return nil, false +} + // GetProfilePhotoAsNotEmpty returns mapped value of ProfilePhoto conditional field and // boolean which is true if field was set. func (u *UserFull) GetProfilePhotoAsNotEmpty() (*Photo, bool) { @@ -1085,3 +1200,12 @@ func (u *UserFull) GetProfilePhotoAsNotEmpty() (*Photo, bool) { } return nil, false } + +// GetFallbackPhotoAsNotEmpty returns mapped value of FallbackPhoto conditional field and +// boolean which is true if field was set. +func (u *UserFull) GetFallbackPhotoAsNotEmpty() (*Photo, bool) { + if value, ok := u.GetFallbackPhoto(); ok { + return value.AsNotEmpty() + } + return nil, false +} diff --git a/tg/tl_user_profile_photo_gen.go b/tg/tl_user_profile_photo_gen.go index 5eb822b9ad..9b877ba0e9 100644 --- a/tg/tl_user_profile_photo_gen.go +++ b/tg/tl_user_profile_photo_gen.go @@ -148,6 +148,8 @@ type UserProfilePhoto struct { // Links: // 1) https://core.telegram.org/api/files#animated-profile-pictures HasVideo bool + // Personal field of UserProfilePhoto. + Personal bool // Identifier of the respective photo PhotoID int64 // Stripped thumbnail¹ @@ -187,6 +189,9 @@ func (u *UserProfilePhoto) Zero() bool { if !(u.HasVideo == false) { return false } + if !(u.Personal == false) { + return false + } if !(u.PhotoID == 0) { return false } @@ -212,11 +217,13 @@ func (u *UserProfilePhoto) String() string { // FillFrom fills UserProfilePhoto from given interface. func (u *UserProfilePhoto) FillFrom(from interface { GetHasVideo() (value bool) + GetPersonal() (value bool) GetPhotoID() (value int64) GetStrippedThumb() (value []byte, ok bool) GetDCID() (value int) }) { u.HasVideo = from.GetHasVideo() + u.Personal = from.GetPersonal() u.PhotoID = from.GetPhotoID() if val, ok := from.GetStrippedThumb(); ok { u.StrippedThumb = val @@ -253,6 +260,11 @@ func (u *UserProfilePhoto) TypeInfo() tdp.Type { SchemaName: "has_video", Null: !u.Flags.Has(0), }, + { + Name: "Personal", + SchemaName: "personal", + Null: !u.Flags.Has(2), + }, { Name: "PhotoID", SchemaName: "photo_id", @@ -275,6 +287,9 @@ func (u *UserProfilePhoto) SetFlags() { if !(u.HasVideo == false) { u.Flags.Set(0) } + if !(u.Personal == false) { + u.Flags.Set(2) + } if !(u.StrippedThumb == nil) { u.Flags.Set(1) } @@ -328,6 +343,7 @@ func (u *UserProfilePhoto) DecodeBare(b *bin.Buffer) error { } } u.HasVideo = u.Flags.Has(0) + u.Personal = u.Flags.Has(2) { value, err := b.Long() if err != nil { @@ -371,6 +387,25 @@ func (u *UserProfilePhoto) GetHasVideo() (value bool) { return u.Flags.Has(0) } +// SetPersonal sets value of Personal conditional field. +func (u *UserProfilePhoto) SetPersonal(value bool) { + if value { + u.Flags.Set(2) + u.Personal = true + } else { + u.Flags.Unset(2) + u.Personal = false + } +} + +// GetPersonal returns value of Personal conditional field. +func (u *UserProfilePhoto) GetPersonal() (value bool) { + if u == nil { + return + } + return u.Flags.Has(2) +} + // GetPhotoID returns value of PhotoID field. func (u *UserProfilePhoto) GetPhotoID() (value int64) { if u == nil { From 7e84b8d85f943f42c47d5a8d96d47545e59b43ff Mon Sep 17 00:00:00 2001 From: Aleksandr Razumov Date: Thu, 29 Dec 2022 22:46:43 +0300 Subject: [PATCH 2/2] fix(peers): change UpdateUserPhoto to UpdateUser --- telegram/peers/update.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telegram/peers/update.go b/telegram/peers/update.go index 5ec1664e53..a23111ebe3 100644 --- a/telegram/peers/update.go +++ b/telegram/peers/update.go @@ -82,7 +82,7 @@ func (m *Manager) applyUpdates(updates []tg.UpdateClass) { m.needUpdate.add(userPeerID(update.UserID)) case *tg.UpdateUserName: m.needUpdate.add(userPeerID(update.UserID)) - case *tg.UpdateUserPhoto: + case *tg.UpdateUser: m.needUpdate.add(userPeerID(update.UserID)) case *tg.UpdateUserPhone: m.needUpdate.add(userPeerID(update.UserID))