diff --git a/_schema/tdesktop.tl b/_schema/tdesktop.tl index 635e79d336..609660a5e2 100644 --- a/_schema/tdesktop.tl +++ b/_schema/tdesktop.tl @@ -1,8 +1,8 @@ // Code generated by ./cmd/dltl, DO NOT EDIT. // // Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/SourceFiles/mtproto/scheme/api.tl -// Layer: 228 -// SHA256: bbddd9c4c3f5ff16fd4abbf39f2a864fdac7553e9f05b6bf9ead2aeb9c8eb566 +// Layer: 229 +// SHA256: 7655504c25a5d3a368e7729d3e9e64afffcacbcb54ec85508c60f0472064b617 boolFalse#bc799737 = Bool; @@ -178,9 +178,9 @@ communityForbidden#fd3cdab8 flags:# id:long access_hash:flags.13?long title:stri community#65efe954 flags:# creator:flags.0?true left:flags.2?true min:flags.12?true flags2:# collapsed_in_dialogs:flags2.20?true id:long access_hash:flags.13?long title:string photo:ChatPhoto date:int admin_rights:flags.14?ChatAdminRights default_banned_rights:flags.18?ChatBannedRights = Chat; -chatFull#2633421b flags:# can_set_username:flags.7?true has_scheduled:flags.8?true translations_disabled:flags.19?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector available_reactions:flags.18?ChatReactions reactions_limit:flags.20?int = ChatFull; +chatFull#2633421b flags:# can_set_username:flags.7?true has_scheduled:flags.8?true translations_disabled:flags.19?true has_welcome_messages:flags.21?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector available_reactions:flags.18?ChatReactions reactions_limit:flags.20?int = ChatFull; -channelFull#a04e8d3a flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true antispam:flags2.1?true participants_hidden:flags2.2?true translations_disabled:flags2.3?true stories_pinned_available:flags2.5?true view_forum_as_messages:flags2.6?true restricted_sponsored:flags2.11?true can_view_revenue:flags2.12?true paid_media_allowed:flags2.14?true can_view_stars_revenue:flags2.15?true paid_reactions_available:flags2.16?true stargifts_available:flags2.19?true paid_messages_available:flags2.20?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions reactions_limit:flags2.13?int stories:flags2.4?PeerStories wallpaper:flags2.7?WallPaper boosts_applied:flags2.8?int boosts_unrestrict:flags2.9?int emojiset:flags2.10?StickerSet bot_verification:flags2.17?BotVerification stargifts_count:flags2.18?int send_paid_messages_stars:flags2.21?long main_tab:flags2.22?ProfileTab guard_bot_id:flags2.23?long = ChatFull; +channelFull#a04e8d3a flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true antispam:flags2.1?true participants_hidden:flags2.2?true translations_disabled:flags2.3?true stories_pinned_available:flags2.5?true view_forum_as_messages:flags2.6?true restricted_sponsored:flags2.11?true can_view_revenue:flags2.12?true paid_media_allowed:flags2.14?true can_view_stars_revenue:flags2.15?true paid_reactions_available:flags2.16?true stargifts_available:flags2.19?true paid_messages_available:flags2.20?true has_welcome_messages:flags2.24?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions reactions_limit:flags2.13?int stories:flags2.4?PeerStories wallpaper:flags2.7?WallPaper boosts_applied:flags2.8?int boosts_unrestrict:flags2.9?int emojiset:flags2.10?StickerSet bot_verification:flags2.17?BotVerification stargifts_count:flags2.18?int send_paid_messages_stars:flags2.21?long main_tab:flags2.22?ProfileTab guard_bot_id:flags2.23?long = ChatFull; communityFull#cbb7a507 flags:# id:long about:string chat_photo:Photo linked_peers:Vector admins_count:flags.1?int kicked_count:flags.2?int peer_link_requests_pending:flags.0?int = ChatFull; @@ -336,7 +336,7 @@ messageActionPrizeStars#b00c47a2 flags:# unclaimed:flags.0?true stars:long trans messageActionStarGift#ea2c31d3 flags:# name_hidden:flags.0?true saved:flags.2?true converted:flags.3?true upgraded:flags.5?true refunded:flags.9?true can_upgrade:flags.10?true prepaid_upgrade:flags.13?true upgrade_separate:flags.16?true auction_acquired:flags.17?true gift:StarGift message:flags.1?TextWithEntities convert_stars:flags.4?long upgrade_msg_id:flags.5?int upgrade_stars:flags.8?long from_id:flags.11?Peer peer:flags.12?Peer saved_id:flags.12?long prepaid_upgrade_hash:flags.14?string gift_msg_id:flags.15?int to_id:flags.18?Peer gift_num:flags.19?int = MessageAction; -messageActionStarGiftUnique#e6c31522 flags:# upgrade:flags.0?true transferred:flags.1?true saved:flags.2?true refunded:flags.5?true prepaid_upgrade:flags.11?true assigned:flags.13?true from_offer:flags.14?true craft:flags.16?true gift:StarGift can_export_at:flags.3?int transfer_stars:flags.4?long from_id:flags.6?Peer peer:flags.7?Peer saved_id:flags.7?long resale_amount:flags.8?StarsAmount can_transfer_at:flags.9?int can_resell_at:flags.10?int drop_original_details_stars:flags.12?long can_craft_at:flags.15?int = MessageAction; +messageActionStarGiftUnique#7e1c1187 flags:# upgrade:flags.0?true transferred:flags.1?true saved:flags.2?true refunded:flags.5?true prepaid_upgrade:flags.11?true assigned:flags.13?true from_offer:flags.14?true craft:flags.16?true name_hidden:flags.17?true gift:StarGift can_export_at:flags.3?int transfer_stars:flags.4?long from_id:flags.6?Peer peer:flags.7?Peer saved_id:flags.7?long resale_amount:flags.8?StarsAmount can_transfer_at:flags.9?int can_resell_at:flags.10?int drop_original_details_stars:flags.12?long can_craft_at:flags.15?int message:flags.18?TextWithEntities = MessageAction; messageActionPaidMessagesRefunded#ac1f1fcd count:int stars:long = MessageAction; @@ -378,6 +378,8 @@ messageActionManagedBotCreated#16605e3e bot_id:long = MessageAction; messageActionChangeCommunity#5d20bae8 flags:# community_id:flags.0?long = MessageAction; +messageActionChatJoinedViaCommunity#4a8bfe80 community_id:long = MessageAction; + dialog#fc89f7f3 flags:# pinned:flags.2?true unread_mark:flags.3?true view_forum_as_messages:flags.6?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 unread_poll_votes_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; @@ -860,6 +862,8 @@ updateDeleteEphemeralMessages#56dbfcf8 peer:Peer ids:Vector = Update; updateEditEphemeralMessage#4bbb8f01 message:EphemeralMessage = Update; +updateEphemeralBotCallbackQuery#7c1079d6 flags:# query_id:long user_id:long peer:flags.0?Peer msg_id:int data:bytes chat_instance:flags.1?long message:EphemeralMessage = Update; + updateBotStarsSubscription#6c0d8e23 flags:# canceled:flags.0?true payment_failed:flags.1?true restored:flags.2?true user_id:long payload:bytes qts:int = Update; updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; @@ -1002,11 +1006,13 @@ sendMessageEmojiInteraction#25972bcb emoticon:string msg_id:int interaction:Data sendMessageEmojiInteractionSeen#b665902e emoticon:string = SendMessageAction; -sendMessageTextDraftAction#376d975c random_id:long text:TextWithEntities = SendMessageAction; +sendMessageTextDraftAction#3630b85a flags:# can_stop:flags.0?true keep_on_stop:flags.1?true random_id:long text:TextWithEntities = SendMessageAction; -inputSendMessageRichMessageDraftAction#e2b23b51 random_id:long rich_message:InputRichMessage = SendMessageAction; +inputSendMessageRichMessageDraftAction#a937c7be flags:# can_stop:flags.0?true keep_on_stop:flags.1?true random_id:long rich_message:InputRichMessage = SendMessageAction; -sendMessageRichMessageDraftAction#a2cb24f9 random_id:long rich_message:RichMessage = SendMessageAction; +sendMessageRichMessageDraftAction#52564893 flags:# can_stop:flags.0?true keep_on_stop:flags.1?true random_id:long rich_message:RichMessage = SendMessageAction; + +sendMessageStopDraftAction#fbf902b0 random_id:long = SendMessageAction; contacts.found#b3134d9d my_results:Vector results:Vector chats:Vector users:Vector = contacts.Found; @@ -1212,41 +1218,7 @@ botCommand#9852d6d2 flags:# ephemeral:flags.0?true command:string description:st botInfo#4d8a0299 flags:# has_preview_medias:flags.6?true user_id:flags.0?long description:flags.1?string description_photo:flags.4?Photo description_document:flags.5?Document commands:flags.2?Vector menu_button:flags.3?BotMenuButton privacy_policy_url:flags.7?string app_settings:flags.8?BotAppSettings verifier_settings:flags.9?BotVerifierSettings = BotInfo; -keyboardButton#7d170cff flags:# style:flags.10?KeyboardButtonStyle text:string = KeyboardButton; - -keyboardButtonUrl#d80c25ec flags:# style:flags.10?KeyboardButtonStyle text:string url:string = KeyboardButton; - -keyboardButtonCallback#e62bc960 flags:# requires_password:flags.0?true style:flags.10?KeyboardButtonStyle text:string data:bytes = KeyboardButton; - -keyboardButtonRequestPhone#417efd8f flags:# style:flags.10?KeyboardButtonStyle text:string = KeyboardButton; - -keyboardButtonRequestGeoLocation#aa40f94d flags:# style:flags.10?KeyboardButtonStyle text:string = KeyboardButton; - -keyboardButtonSwitchInline#991399fc flags:# same_peer:flags.0?true style:flags.10?KeyboardButtonStyle text:string query:string peer_types:flags.1?Vector = KeyboardButton; - -keyboardButtonGame#89c590f9 flags:# style:flags.10?KeyboardButtonStyle text:string = KeyboardButton; - -keyboardButtonBuy#3fa53905 flags:# style:flags.10?KeyboardButtonStyle text:string = KeyboardButton; - -keyboardButtonUrlAuth#f51006f9 flags:# style:flags.10?KeyboardButtonStyle text:string fwd_text:flags.0?string url:string button_id:int = KeyboardButton; - -inputKeyboardButtonUrlAuth#68013e72 flags:# request_write_access:flags.0?true style:flags.10?KeyboardButtonStyle text:string fwd_text:flags.1?string url:string bot:InputUser = KeyboardButton; - -keyboardButtonRequestPoll#7a11d782 flags:# style:flags.10?KeyboardButtonStyle quiz:flags.0?Bool text:string = KeyboardButton; - -inputKeyboardButtonUserProfile#7d5e07c7 flags:# style:flags.10?KeyboardButtonStyle text:string user_id:InputUser = KeyboardButton; - -keyboardButtonUserProfile#c0fd5d09 flags:# style:flags.10?KeyboardButtonStyle text:string user_id:long = KeyboardButton; - -keyboardButtonWebView#e846b1a0 flags:# style:flags.10?KeyboardButtonStyle text:string url:string = KeyboardButton; - -keyboardButtonSimpleWebView#e15c4370 flags:# style:flags.10?KeyboardButtonStyle text:string url:string = KeyboardButton; - -keyboardButtonRequestPeer#5b0f15f5 flags:# style:flags.10?KeyboardButtonStyle text:string button_id:int peer_type:RequestPeerType max_quantity:int = KeyboardButton; - -inputKeyboardButtonRequestPeer#2b78156 flags:# name_requested:flags.0?true username_requested:flags.1?true photo_requested:flags.2?true style:flags.10?KeyboardButtonStyle text:string button_id:int peer_type:RequestPeerType max_quantity:int = KeyboardButton; - -keyboardButtonCopy#bcc4af10 flags:# style:flags.10?KeyboardButtonStyle text:string copy_text:string = KeyboardButton; +keyboardButton#2f67a72f flags:# style:flags.10?KeyboardButtonStyle text:string type:ButtonType = KeyboardButton; keyboardButtonRow#77608b83 buttons:Vector = KeyboardButtonRow; @@ -1254,9 +1226,9 @@ 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 persistent:flags.4?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 force_reply:flags.5?true rows:Vector placeholder:flags.3?string = ReplyMarkup; -replyInlineMarkup#48a30254 rows:Vector = ReplyMarkup; +replyInlineMarkup#b2b15770 flags:# force_reply:flags.5?true rows:Vector = ReplyMarkup; messageEntityUnknown#bb92ba95 offset:int length:int = MessageEntity; @@ -1596,6 +1568,8 @@ textDate#a5b45e2b flags:# relative:flags.0?true short_time:flags.1?true long_tim textDiff#9686cb50 text:RichText old_text:RichText = RichText; +textButton#afc79cd6 flags:# text:RichText type:InlineButtonType style:flags.0?RichButtonStyle = RichText; + pageBlockUnsupported#13567e8a = PageBlock; pageBlockTitle#70abc3fd text:RichText = PageBlock; @@ -1620,7 +1594,7 @@ pageBlockAnchor#ce0d37b0 name:string = PageBlock; pageBlockList#e4e88011 items:Vector = PageBlock; -pageBlockBlockquote#263d7c26 text:RichText caption:RichText = PageBlock; +pageBlockBlockquote#66d1670b flags:# collapsed:flags.0?true text:RichText caption:RichText = PageBlock; pageBlockPullquote#4f4456d3 text:RichText caption:RichText = PageBlock; @@ -1644,7 +1618,7 @@ pageBlockAudio#804361ea audio_id:long caption:PageCaption = PageBlock; pageBlockKicker#1e148390 text:RichText = PageBlock; -pageBlockTable#bf4dea82 flags:# bordered:flags.0?true striped:flags.1?true title:RichText rows:Vector = PageBlock; +pageBlockTable#bf4dea82 flags:# bordered:flags.0?true striped:flags.1?true compact:flags.2?true title:RichText rows:Vector = PageBlock; pageBlockOrderedList#1fd6f6c1 flags:# reversed:flags.2?true items:Vector start:flags.0?int type:flags.1?string = PageBlock; @@ -1674,6 +1648,10 @@ inputPageBlockMap#574b617f geo:InputGeoPoint zoom:int w:int h:int caption:PageCa pageBlockBlockquoteBlocks#e6e47c4 blocks:Vector caption:RichText = PageBlock; +pageBlockButtonRow#6d640318 flags:# align_left:flags.0?true align_center:flags.1?true align_right:flags.2?true buttons:Vector = PageBlock; + +pageBlockDocument#38fa3ba3 document_id:long caption:PageCaption = PageBlock; + phoneCallDiscardReasonMissed#85e42301 = PhoneCallDiscardReason; phoneCallDiscardReasonDisconnect#e095c1a0 = PhoneCallDiscardReason; @@ -2106,7 +2084,7 @@ chatOnlines#f041e250 onlines:int = ChatOnlines; statsURL#47a971e0 url:string = StatsURL; -chatAdminRights#5fb224d5 flags:# change_info:flags.0?true post_messages:flags.1?true edit_messages:flags.2?true delete_messages:flags.3?true ban_users:flags.4?true invite_users:flags.5?true pin_messages:flags.7?true add_admins:flags.9?true anonymous:flags.10?true manage_call:flags.11?true other:flags.12?true manage_topics:flags.13?true post_stories:flags.14?true edit_stories:flags.15?true delete_stories:flags.16?true manage_direct_messages:flags.17?true manage_ranks:flags.18?true manage_linked_peers:flags.19?true = ChatAdminRights; +chatAdminRights#5fb224d5 flags:# change_info:flags.0?true post_messages:flags.1?true edit_messages:flags.2?true delete_messages:flags.3?true ban_users:flags.4?true invite_users:flags.5?true pin_messages:flags.7?true add_admins:flags.9?true anonymous:flags.10?true manage_call:flags.11?true other:flags.12?true manage_topics:flags.13?true post_stories:flags.14?true edit_stories:flags.15?true delete_stories:flags.16?true manage_direct_messages:flags.17?true manage_ranks:flags.18?true manage_linked_peers:flags.19?true manage_welcome_messages:flags.20?true = ChatAdminRights; chatBannedRights#9f120418 flags:# view_messages:flags.0?true send_messages:flags.1?true send_media:flags.2?true send_stickers:flags.3?true send_gifs:flags.4?true send_games:flags.5?true send_inline:flags.6?true embed_links:flags.7?true send_polls:flags.8?true change_info:flags.10?true invite_users:flags.15?true pin_messages:flags.17?true manage_topics:flags.18?true send_photos:flags.19?true send_videos:flags.20?true send_roundvideos:flags.21?true send_audios:flags.22?true send_voices:flags.23?true send_docs:flags.24?true send_plain:flags.25?true edit_rank:flags.26?true send_reactions:flags.27?true manage_linked_peers:flags.28?true until_date:int = ChatBannedRights; @@ -2480,7 +2458,7 @@ inputInvoicePremiumGiftStars#dabab2ef flags:# user_id:InputUser months:int messa inputInvoiceBusinessBotTransferStars#f4997e42 bot:InputUser stars:long = InputInvoice; -inputInvoiceStarGiftResale#c39f5324 flags:# ton:flags.0?true slug:string to_id:InputPeer = InputInvoice; +inputInvoiceStarGiftResale#e9b0c658 flags:# ton:flags.0?true show_name:flags.2?true slug:string to_id:InputPeer message:flags.1?TextWithEntities = InputInvoice; inputInvoiceStarGiftPrepaidUpgrade#9a0b48b8 peer:InputPeer hash:string = InputInvoice; @@ -3280,7 +3258,7 @@ communityPeerRequest#7beafa85 flags:# visible:flags.0?true peer:Peer requested_b communities.peerLinkRequests#2244afad flags:# total_count:int requests:Vector next_offset:flags.0?string chats:Vector users:Vector = communities.PeerLinkRequests; -ephemeralMessage#d9c6dc1a flags:# out:flags.0?true id:int from_id:Peer peer_id:Peer receiver_id:long top_msg_id:flags.1?int date:int message:string entities:flags.2?Vector media:flags.3?MessageMedia reply_markup:flags.4?ReplyMarkup reply_to:flags.6?MessageReplyHeader = EphemeralMessage; +ephemeralMessage#dd27bee9 flags:# out:flags.0?true welcome_template:flags.5?true invert_media:flags.7?true noforwards:flags.12?true id:int from_id:Peer peer_id:flags.9?Peer receiver_id:long top_msg_id:flags.1?int date:int message:string entities:flags.2?Vector media:flags.3?MessageMedia reply_markup:flags.4?ReplyMarkup reply_to:flags.6?MessageReplyHeader rich_message:flags.8?RichMessage chat_instance:flags.10?long anchor_msg_id:flags.11?int = EphemeralMessage; communities.participantJoinedChats#8d78512a creator_chat_ids:Vector joined_chat_ids:Vector chats:Vector users:Vector = communities.ParticipantJoinedChats; @@ -3288,6 +3266,58 @@ messages.translatedRichMessage#4203998f result:Vector = messages.Tr messages.composedRichMessageWithAI#4c4537c8 result:RichMessage = messages.ComposedRichMessageWithAI; +buttonTypeDefault#c9dd90e9 = ButtonType; + +buttonTypeRequestPhone#df3d36f9 = ButtonType; + +buttonTypeRequestGeoLocation#9beee140 = ButtonType; + +buttonTypeRequestPoll#aacfff84 flags:# quiz:flags.0?Bool = ButtonType; + +buttonTypeRequestPeer#4f58a237 flags:# button_id:int peer_type:RequestPeerType max_quantity:int = ButtonType; + +inputButtonTypeRequestPeer#3fe268fe flags:# name_requested:flags.0?true username_requested:flags.1?true photo_requested:flags.2?true button_id:int peer_type:RequestPeerType max_quantity:int = ButtonType; + +buttonTypeSimpleWebView#c01a597a url:string = ButtonType; + +inlineButtonTypeUrl#eca4f8d4 url:string = InlineButtonType; + +inlineButtonTypeUrlAuth#bfd02da2 flags:# fwd_text:flags.0?string url:string button_id:int = InlineButtonType; + +inputInlineButtonTypeUrlAuth#9961bcb4 flags:# request_write_access:flags.0?true fwd_text:flags.1?string url:string bot:flags.2?InputUser = InlineButtonType; + +inlineButtonTypeWebView#3bcab5b4 url:string = InlineButtonType; + +inlineButtonTypeCallback#2955bc38 flags:# requires_password:flags.0?true data:bytes = InlineButtonType; + +inlineButtonTypeGame#5cd3709d = InlineButtonType; + +inlineButtonTypeBuy#48bad7a5 = InlineButtonType; + +inlineButtonTypeSwitchInline#93773ff5 flags:# same_peer:flags.0?true query:string peer_types:flags.1?Vector = InlineButtonType; + +inlineButtonTypeUserProfile#3fa33fcf user_id:long = InlineButtonType; + +inputInlineButtonTypeUserProfile#53f3ce5a user_id:InputUser = InlineButtonType; + +inlineButtonTypeCopy#b41d3272 copy_text:string = InlineButtonType; + +inlineButtonTypeDisabled#a438619d = InlineButtonType; + +keyboardInlineButton#11c1a322 flags:# style:flags.10?KeyboardButtonStyle text:string type:InlineButtonType = KeyboardInlineButton; + +keyboardInlineButtonRow#19420af6 buttons:Vector = KeyboardInlineButtonRow; + +richButtonStyle#3c610bd flags:# bg_primary:flags.0?true bg_danger:flags.1?true bg_success:flags.2?true link:flags.3?true = RichButtonStyle; + +pageButton#692a5488 flags:# text:RichText type:InlineButtonType style:flags.0?RichButtonStyle = PageButton; + +ephemeral.welcomeMessagesNotModified#59ffdb31 = ephemeral.WelcomeMessages; + +ephemeral.welcomeMessages#104fc872 hash:long messages:Vector = ephemeral.WelcomeMessages; + +auth.firebasePnvIntent#df5ac00c nonce:string digital_credential_payload:string = auth.FirebasePnvIntent; + ---functions--- @@ -3365,6 +3395,12 @@ auth.initPasskeyLogin#518ad0b7 api_id:int api_hash:string = auth.PasskeyLoginOpt auth.finishPasskeyLogin#9857ad07 flags:# credential:InputPasskeyCredential from_dc_id:flags.0?int from_auth_key_id:flags.0?long = auth.Authorization; +auth.initFirebasePnvLogin#777df37a api_id:int api_hash:string = auth.FirebasePnvIntent; + +auth.finishFirebasePnvLogin#2c85094c google_token:string = auth.Authorization; + +auth.firebasePnvSignUp#783f6b56 flags:# no_joined_notifications:flags.0?true first_name:string last_name:string = auth.Authorization; + account.registerDevice#ec86017a flags:# no_muted:flags.0?true token_type:int token:string app_sandbox:Bool secret:bytes other_uids:Vector = Bool; account.unregisterDevice#6a0d3206 token_type:int token:string other_uids:Vector = Bool; @@ -3713,7 +3749,7 @@ messages.sendMessage#fef48f62 flags:# no_webpage:flags.1?true silent:flags.5?tru messages.sendMedia#330e77f flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true allow_paid_floodskip:flags.19?true peer:InputPeer reply_to:flags.0?InputReplyTo media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int schedule_repeat_period:flags.24?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long allow_paid_stars:flags.21?long suggested_post:flags.22?SuggestedPost = Updates; -messages.forwardMessages#13704a7c flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true drop_author:flags.11?true drop_media_captions:flags.12?true noforwards:flags.14?true allow_paid_floodskip:flags.19?true from_peer:InputPeer id:Vector random_id:Vector to_peer:InputPeer top_msg_id:flags.9?int reply_to:flags.22?InputReplyTo schedule_date:flags.10?int schedule_repeat_period:flags.24?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long video_timestamp:flags.20?int allow_paid_stars:flags.21?long suggested_post:flags.23?SuggestedPost = Updates; +messages.forwardMessages#13704a7c flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true drop_author:flags.11?true drop_media_captions:flags.12?true noforwards:flags.14?true allow_paid_floodskip:flags.19?true from_ephemeral:flags.25?true from_peer:InputPeer id:Vector random_id:Vector to_peer:InputPeer top_msg_id:flags.9?int reply_to:flags.22?InputReplyTo schedule_date:flags.10?int schedule_repeat_period:flags.24?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long video_timestamp:flags.20?int allow_paid_stars:flags.21?long suggested_post:flags.23?SuggestedPost = Updates; messages.reportSpam#cf1592db peer:InputPeer = Bool; @@ -4895,12 +4931,20 @@ communities.toggleParticipantBanned#9967ad0f flags:# unban:flags.0?true communit communities.getParticipantJoinedChats#f87eabab community:InputChannel participant:InputPeer = communities.ParticipantJoinedChats; -ephemeral.sendMessage#68cbd09f flags:# peer:InputPeer receiver_id:InputUser query_id:flags.0?long message:string entities:flags.1?Vector media:flags.2?InputMedia reply_markup:flags.3?ReplyMarkup rich_message:flags.4?InputRichMessage random_id:long reply_to:flags.5?InputReplyTo = Updates; +ephemeral.sendMessage#ba8d5f35 flags:# invert_media:flags.6?true welcome:flags.7?true anchor:flags.9?true noforwards:flags.10?true peer:flags.8?InputPeer receiver_id:InputUser query_id:flags.0?long message:string entities:flags.1?Vector media:flags.2?InputMedia reply_markup:flags.3?ReplyMarkup rich_message:flags.4?InputRichMessage random_id:long reply_to:flags.5?InputReplyTo = Updates; -ephemeral.deleteMessage#a3c0d511 peer:InputPeer receiver_id:InputUser id:int = Bool; +ephemeral.deleteMessage#92f6e797 flags:# peer:flags.0?InputPeer receiver_id:InputUser id:int = Bool; ephemeral.reportMessage#8704f2bf peer:InputPeer id:int option:bytes message:string = ReportResult; ephemeral.getCallbackAnswer#3fa464c8 flags:# peer:InputPeer id:int data:flags.1?bytes = messages.BotCallbackAnswer; -// LAYER 228 +ephemeral.editMessage#cf9c725b flags:# invert_media:flags.5?true welcome:flags.6?true peer:flags.7?InputPeer receiver_id:InputUser id:int message:flags.0?string media:flags.3?InputMedia entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup rich_message:flags.4?InputRichMessage = Updates; + +ephemeral.deleteWelcomeMessage#e882a9e1 peer:InputPeer id:int = Bool; + +ephemeral.deleteAllWelcomeMessages#734f9721 peer:InputPeer = Bool; + +ephemeral.getWelcomeMessages#db9ac18d peer:InputPeer hash:long = ephemeral.WelcomeMessages; + +// LAYER 229 diff --git a/_schema/tdlib.tl b/_schema/tdlib.tl index a2b070fa2d..ffb4e4e0b3 100644 --- a/_schema/tdlib.tl +++ b/_schema/tdlib.tl @@ -1,8 +1,8 @@ // Code generated by ./cmd/dltl, DO NOT EDIT. // // Source: https://raw.githubusercontent.com/tdlib/td/master/td/generate/scheme/telegram_api.tl -// Layer: 228 -// SHA256: 921a58e71f2baebb840609366c506fb92ffac8db3c5bb832423aacd7cd6817cf +// Layer: 229 +// SHA256: 4c44853dd138f6484281317b2a6da7e778b770014bf2d63db76d4138b33bec4f int#a8509bda ? = Int; @@ -218,9 +218,9 @@ communityForbidden#fd3cdab8 flags:# id:long access_hash:flags.13?long title:stri community#65efe954 flags:# creator:flags.0?true left:flags.2?true min:flags.12?true flags2:# collapsed_in_dialogs:flags2.20?true id:long access_hash:flags.13?long title:string photo:ChatPhoto date:int admin_rights:flags.14?ChatAdminRights default_banned_rights:flags.18?ChatBannedRights = Chat; -chatFull#2633421b flags:# can_set_username:flags.7?true has_scheduled:flags.8?true translations_disabled:flags.19?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector available_reactions:flags.18?ChatReactions reactions_limit:flags.20?int = ChatFull; +chatFull#2633421b flags:# can_set_username:flags.7?true has_scheduled:flags.8?true translations_disabled:flags.19?true has_welcome_messages:flags.21?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector available_reactions:flags.18?ChatReactions reactions_limit:flags.20?int = ChatFull; -channelFull#a04e8d3a flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true antispam:flags2.1?true participants_hidden:flags2.2?true translations_disabled:flags2.3?true stories_pinned_available:flags2.5?true view_forum_as_messages:flags2.6?true restricted_sponsored:flags2.11?true can_view_revenue:flags2.12?true paid_media_allowed:flags2.14?true can_view_stars_revenue:flags2.15?true paid_reactions_available:flags2.16?true stargifts_available:flags2.19?true paid_messages_available:flags2.20?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions reactions_limit:flags2.13?int stories:flags2.4?PeerStories wallpaper:flags2.7?WallPaper boosts_applied:flags2.8?int boosts_unrestrict:flags2.9?int emojiset:flags2.10?StickerSet bot_verification:flags2.17?BotVerification stargifts_count:flags2.18?int send_paid_messages_stars:flags2.21?long main_tab:flags2.22?ProfileTab guard_bot_id:flags2.23?long = ChatFull; +channelFull#a04e8d3a flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true antispam:flags2.1?true participants_hidden:flags2.2?true translations_disabled:flags2.3?true stories_pinned_available:flags2.5?true view_forum_as_messages:flags2.6?true restricted_sponsored:flags2.11?true can_view_revenue:flags2.12?true paid_media_allowed:flags2.14?true can_view_stars_revenue:flags2.15?true paid_reactions_available:flags2.16?true stargifts_available:flags2.19?true paid_messages_available:flags2.20?true has_welcome_messages:flags2.24?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions reactions_limit:flags2.13?int stories:flags2.4?PeerStories wallpaper:flags2.7?WallPaper boosts_applied:flags2.8?int boosts_unrestrict:flags2.9?int emojiset:flags2.10?StickerSet bot_verification:flags2.17?BotVerification stargifts_count:flags2.18?int send_paid_messages_stars:flags2.21?long main_tab:flags2.22?ProfileTab guard_bot_id:flags2.23?long = ChatFull; communityFull#cbb7a507 flags:# id:long about:string chat_photo:Photo linked_peers:Vector admins_count:flags.1?int kicked_count:flags.2?int peer_link_requests_pending:flags.0?int = ChatFull; @@ -376,7 +376,7 @@ messageActionPrizeStars#b00c47a2 flags:# unclaimed:flags.0?true stars:long trans messageActionStarGift#ea2c31d3 flags:# name_hidden:flags.0?true saved:flags.2?true converted:flags.3?true upgraded:flags.5?true refunded:flags.9?true can_upgrade:flags.10?true prepaid_upgrade:flags.13?true upgrade_separate:flags.16?true auction_acquired:flags.17?true gift:StarGift message:flags.1?TextWithEntities convert_stars:flags.4?long upgrade_msg_id:flags.5?int upgrade_stars:flags.8?long from_id:flags.11?Peer peer:flags.12?Peer saved_id:flags.12?long prepaid_upgrade_hash:flags.14?string gift_msg_id:flags.15?int to_id:flags.18?Peer gift_num:flags.19?int = MessageAction; -messageActionStarGiftUnique#e6c31522 flags:# upgrade:flags.0?true transferred:flags.1?true saved:flags.2?true refunded:flags.5?true prepaid_upgrade:flags.11?true assigned:flags.13?true from_offer:flags.14?true craft:flags.16?true gift:StarGift can_export_at:flags.3?int transfer_stars:flags.4?long from_id:flags.6?Peer peer:flags.7?Peer saved_id:flags.7?long resale_amount:flags.8?StarsAmount can_transfer_at:flags.9?int can_resell_at:flags.10?int drop_original_details_stars:flags.12?long can_craft_at:flags.15?int = MessageAction; +messageActionStarGiftUnique#7e1c1187 flags:# upgrade:flags.0?true transferred:flags.1?true saved:flags.2?true refunded:flags.5?true prepaid_upgrade:flags.11?true assigned:flags.13?true from_offer:flags.14?true craft:flags.16?true name_hidden:flags.17?true gift:StarGift can_export_at:flags.3?int transfer_stars:flags.4?long from_id:flags.6?Peer peer:flags.7?Peer saved_id:flags.7?long resale_amount:flags.8?StarsAmount can_transfer_at:flags.9?int can_resell_at:flags.10?int drop_original_details_stars:flags.12?long can_craft_at:flags.15?int message:flags.18?TextWithEntities = MessageAction; messageActionPaidMessagesRefunded#ac1f1fcd count:int stars:long = MessageAction; @@ -418,6 +418,8 @@ messageActionManagedBotCreated#16605e3e bot_id:long = MessageAction; messageActionChangeCommunity#5d20bae8 flags:# community_id:flags.0?long = MessageAction; +messageActionChatJoinedViaCommunity#4a8bfe80 community_id:long = MessageAction; + dialog#fc89f7f3 flags:# pinned:flags.2?true unread_mark:flags.3?true view_forum_as_messages:flags.6?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 unread_poll_votes_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; @@ -900,7 +902,7 @@ updateDeleteEphemeralMessages#56dbfcf8 peer:Peer ids:Vector = Update; updateEditEphemeralMessage#4bbb8f01 message:EphemeralMessage = Update; -updateEphemeralBotCallbackQuery#9b380762 query_id:long user_id:long peer:Peer msg_id:int data:bytes message:EphemeralMessage = Update; +updateEphemeralBotCallbackQuery#7c1079d6 flags:# query_id:long user_id:long peer:flags.0?Peer msg_id:int data:bytes chat_instance:flags.1?long message:EphemeralMessage = Update; updateBotStarsSubscription#6c0d8e23 flags:# canceled:flags.0?true payment_failed:flags.1?true restored:flags.2?true user_id:long payload:bytes qts:int = Update; @@ -1044,11 +1046,13 @@ sendMessageEmojiInteraction#25972bcb emoticon:string msg_id:int interaction:Data sendMessageEmojiInteractionSeen#b665902e emoticon:string = SendMessageAction; -sendMessageTextDraftAction#376d975c random_id:long text:TextWithEntities = SendMessageAction; +sendMessageTextDraftAction#3630b85a flags:# can_stop:flags.0?true keep_on_stop:flags.1?true random_id:long text:TextWithEntities = SendMessageAction; + +inputSendMessageRichMessageDraftAction#a937c7be flags:# can_stop:flags.0?true keep_on_stop:flags.1?true random_id:long rich_message:InputRichMessage = SendMessageAction; -inputSendMessageRichMessageDraftAction#e2b23b51 random_id:long rich_message:InputRichMessage = SendMessageAction; +sendMessageRichMessageDraftAction#52564893 flags:# can_stop:flags.0?true keep_on_stop:flags.1?true random_id:long rich_message:RichMessage = SendMessageAction; -sendMessageRichMessageDraftAction#a2cb24f9 random_id:long rich_message:RichMessage = SendMessageAction; +sendMessageStopDraftAction#fbf902b0 random_id:long = SendMessageAction; contacts.found#b3134d9d my_results:Vector results:Vector chats:Vector users:Vector = contacts.Found; @@ -1254,41 +1258,7 @@ botCommand#9852d6d2 flags:# ephemeral:flags.0?true command:string description:st botInfo#4d8a0299 flags:# has_preview_medias:flags.6?true user_id:flags.0?long description:flags.1?string description_photo:flags.4?Photo description_document:flags.5?Document commands:flags.2?Vector menu_button:flags.3?BotMenuButton privacy_policy_url:flags.7?string app_settings:flags.8?BotAppSettings verifier_settings:flags.9?BotVerifierSettings = BotInfo; -keyboardButton#7d170cff flags:# style:flags.10?KeyboardButtonStyle text:string = KeyboardButton; - -keyboardButtonUrl#d80c25ec flags:# style:flags.10?KeyboardButtonStyle text:string url:string = KeyboardButton; - -keyboardButtonCallback#e62bc960 flags:# requires_password:flags.0?true style:flags.10?KeyboardButtonStyle text:string data:bytes = KeyboardButton; - -keyboardButtonRequestPhone#417efd8f flags:# style:flags.10?KeyboardButtonStyle text:string = KeyboardButton; - -keyboardButtonRequestGeoLocation#aa40f94d flags:# style:flags.10?KeyboardButtonStyle text:string = KeyboardButton; - -keyboardButtonSwitchInline#991399fc flags:# same_peer:flags.0?true style:flags.10?KeyboardButtonStyle text:string query:string peer_types:flags.1?Vector = KeyboardButton; - -keyboardButtonGame#89c590f9 flags:# style:flags.10?KeyboardButtonStyle text:string = KeyboardButton; - -keyboardButtonBuy#3fa53905 flags:# style:flags.10?KeyboardButtonStyle text:string = KeyboardButton; - -keyboardButtonUrlAuth#f51006f9 flags:# style:flags.10?KeyboardButtonStyle text:string fwd_text:flags.0?string url:string button_id:int = KeyboardButton; - -inputKeyboardButtonUrlAuth#68013e72 flags:# request_write_access:flags.0?true style:flags.10?KeyboardButtonStyle text:string fwd_text:flags.1?string url:string bot:InputUser = KeyboardButton; - -keyboardButtonRequestPoll#7a11d782 flags:# style:flags.10?KeyboardButtonStyle quiz:flags.0?Bool text:string = KeyboardButton; - -inputKeyboardButtonUserProfile#7d5e07c7 flags:# style:flags.10?KeyboardButtonStyle text:string user_id:InputUser = KeyboardButton; - -keyboardButtonUserProfile#c0fd5d09 flags:# style:flags.10?KeyboardButtonStyle text:string user_id:long = KeyboardButton; - -keyboardButtonWebView#e846b1a0 flags:# style:flags.10?KeyboardButtonStyle text:string url:string = KeyboardButton; - -keyboardButtonSimpleWebView#e15c4370 flags:# style:flags.10?KeyboardButtonStyle text:string url:string = KeyboardButton; - -keyboardButtonRequestPeer#5b0f15f5 flags:# style:flags.10?KeyboardButtonStyle text:string button_id:int peer_type:RequestPeerType max_quantity:int = KeyboardButton; - -inputKeyboardButtonRequestPeer#2b78156 flags:# name_requested:flags.0?true username_requested:flags.1?true photo_requested:flags.2?true style:flags.10?KeyboardButtonStyle text:string button_id:int peer_type:RequestPeerType max_quantity:int = KeyboardButton; - -keyboardButtonCopy#bcc4af10 flags:# style:flags.10?KeyboardButtonStyle text:string copy_text:string = KeyboardButton; +keyboardButton#2f67a72f flags:# style:flags.10?KeyboardButtonStyle text:string type:ButtonType = KeyboardButton; keyboardButtonRow#77608b83 buttons:Vector = KeyboardButtonRow; @@ -1296,9 +1266,9 @@ 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 persistent:flags.4?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 force_reply:flags.5?true rows:Vector placeholder:flags.3?string = ReplyMarkup; -replyInlineMarkup#48a30254 rows:Vector = ReplyMarkup; +replyInlineMarkup#b2b15770 flags:# force_reply:flags.5?true rows:Vector = ReplyMarkup; messageEntityUnknown#bb92ba95 offset:int length:int = MessageEntity; @@ -1638,6 +1608,8 @@ textDate#a5b45e2b flags:# relative:flags.0?true short_time:flags.1?true long_tim textDiff#9686cb50 text:RichText old_text:RichText = RichText; +textButton#afc79cd6 flags:# text:RichText type:InlineButtonType style:flags.0?RichButtonStyle = RichText; + pageBlockUnsupported#13567e8a = PageBlock; pageBlockTitle#70abc3fd text:RichText = PageBlock; @@ -1662,7 +1634,7 @@ pageBlockAnchor#ce0d37b0 name:string = PageBlock; pageBlockList#e4e88011 items:Vector = PageBlock; -pageBlockBlockquote#263d7c26 text:RichText caption:RichText = PageBlock; +pageBlockBlockquote#66d1670b flags:# collapsed:flags.0?true text:RichText caption:RichText = PageBlock; pageBlockPullquote#4f4456d3 text:RichText caption:RichText = PageBlock; @@ -1686,7 +1658,7 @@ pageBlockAudio#804361ea audio_id:long caption:PageCaption = PageBlock; pageBlockKicker#1e148390 text:RichText = PageBlock; -pageBlockTable#bf4dea82 flags:# bordered:flags.0?true striped:flags.1?true title:RichText rows:Vector = PageBlock; +pageBlockTable#bf4dea82 flags:# bordered:flags.0?true striped:flags.1?true compact:flags.2?true title:RichText rows:Vector = PageBlock; pageBlockOrderedList#1fd6f6c1 flags:# reversed:flags.2?true items:Vector start:flags.0?int type:flags.1?string = PageBlock; @@ -1716,6 +1688,10 @@ inputPageBlockMap#574b617f geo:InputGeoPoint zoom:int w:int h:int caption:PageCa pageBlockBlockquoteBlocks#e6e47c4 blocks:Vector caption:RichText = PageBlock; +pageBlockButtonRow#6d640318 flags:# align_left:flags.0?true align_center:flags.1?true align_right:flags.2?true buttons:Vector = PageBlock; + +pageBlockDocument#38fa3ba3 document_id:long caption:PageCaption = PageBlock; + phoneCallDiscardReasonMissed#85e42301 = PhoneCallDiscardReason; phoneCallDiscardReasonDisconnect#e095c1a0 = PhoneCallDiscardReason; @@ -2148,7 +2124,7 @@ chatOnlines#f041e250 onlines:int = ChatOnlines; statsURL#47a971e0 url:string = StatsURL; -chatAdminRights#5fb224d5 flags:# change_info:flags.0?true post_messages:flags.1?true edit_messages:flags.2?true delete_messages:flags.3?true ban_users:flags.4?true invite_users:flags.5?true pin_messages:flags.7?true add_admins:flags.9?true anonymous:flags.10?true manage_call:flags.11?true other:flags.12?true manage_topics:flags.13?true post_stories:flags.14?true edit_stories:flags.15?true delete_stories:flags.16?true manage_direct_messages:flags.17?true manage_ranks:flags.18?true manage_linked_peers:flags.19?true = ChatAdminRights; +chatAdminRights#5fb224d5 flags:# change_info:flags.0?true post_messages:flags.1?true edit_messages:flags.2?true delete_messages:flags.3?true ban_users:flags.4?true invite_users:flags.5?true pin_messages:flags.7?true add_admins:flags.9?true anonymous:flags.10?true manage_call:flags.11?true other:flags.12?true manage_topics:flags.13?true post_stories:flags.14?true edit_stories:flags.15?true delete_stories:flags.16?true manage_direct_messages:flags.17?true manage_ranks:flags.18?true manage_linked_peers:flags.19?true manage_welcome_messages:flags.20?true = ChatAdminRights; chatBannedRights#9f120418 flags:# view_messages:flags.0?true send_messages:flags.1?true send_media:flags.2?true send_stickers:flags.3?true send_gifs:flags.4?true send_games:flags.5?true send_inline:flags.6?true embed_links:flags.7?true send_polls:flags.8?true change_info:flags.10?true invite_users:flags.15?true pin_messages:flags.17?true manage_topics:flags.18?true send_photos:flags.19?true send_videos:flags.20?true send_roundvideos:flags.21?true send_audios:flags.22?true send_voices:flags.23?true send_docs:flags.24?true send_plain:flags.25?true edit_rank:flags.26?true send_reactions:flags.27?true manage_linked_peers:flags.28?true until_date:int = ChatBannedRights; @@ -2522,7 +2498,7 @@ inputInvoicePremiumGiftStars#dabab2ef flags:# user_id:InputUser months:int messa inputInvoiceBusinessBotTransferStars#f4997e42 bot:InputUser stars:long = InputInvoice; -inputInvoiceStarGiftResale#c39f5324 flags:# ton:flags.0?true slug:string to_id:InputPeer = InputInvoice; +inputInvoiceStarGiftResale#e9b0c658 flags:# ton:flags.0?true show_name:flags.2?true slug:string to_id:InputPeer message:flags.1?TextWithEntities = InputInvoice; inputInvoiceStarGiftPrepaidUpgrade#9a0b48b8 peer:InputPeer hash:string = InputInvoice; @@ -3322,7 +3298,7 @@ communityPeerRequest#7beafa85 flags:# visible:flags.0?true peer:Peer requested_b communities.peerLinkRequests#2244afad flags:# total_count:int requests:Vector next_offset:flags.0?string chats:Vector users:Vector = communities.PeerLinkRequests; -ephemeralMessage#d9c6dc1a flags:# out:flags.0?true id:int from_id:Peer peer_id:Peer receiver_id:long top_msg_id:flags.1?int date:int message:string entities:flags.2?Vector media:flags.3?MessageMedia reply_markup:flags.4?ReplyMarkup reply_to:flags.6?MessageReplyHeader = EphemeralMessage; +ephemeralMessage#dd27bee9 flags:# out:flags.0?true welcome_template:flags.5?true invert_media:flags.7?true noforwards:flags.12?true id:int from_id:Peer peer_id:flags.9?Peer receiver_id:long top_msg_id:flags.1?int date:int message:string entities:flags.2?Vector media:flags.3?MessageMedia reply_markup:flags.4?ReplyMarkup reply_to:flags.6?MessageReplyHeader rich_message:flags.8?RichMessage chat_instance:flags.10?long anchor_msg_id:flags.11?int = EphemeralMessage; communities.participantJoinedChats#8d78512a creator_chat_ids:Vector joined_chat_ids:Vector chats:Vector users:Vector = communities.ParticipantJoinedChats; @@ -3330,6 +3306,58 @@ messages.translatedRichMessage#4203998f result:Vector = messages.Tr messages.composedRichMessageWithAI#4c4537c8 result:RichMessage = messages.ComposedRichMessageWithAI; +buttonTypeDefault#c9dd90e9 = ButtonType; + +buttonTypeRequestPhone#df3d36f9 = ButtonType; + +buttonTypeRequestGeoLocation#9beee140 = ButtonType; + +buttonTypeRequestPoll#aacfff84 flags:# quiz:flags.0?Bool = ButtonType; + +buttonTypeRequestPeer#4f58a237 flags:# button_id:int peer_type:RequestPeerType max_quantity:int = ButtonType; + +inputButtonTypeRequestPeer#3fe268fe flags:# name_requested:flags.0?true username_requested:flags.1?true photo_requested:flags.2?true button_id:int peer_type:RequestPeerType max_quantity:int = ButtonType; + +buttonTypeSimpleWebView#c01a597a url:string = ButtonType; + +inlineButtonTypeUrl#eca4f8d4 url:string = InlineButtonType; + +inlineButtonTypeUrlAuth#bfd02da2 flags:# fwd_text:flags.0?string url:string button_id:int = InlineButtonType; + +inputInlineButtonTypeUrlAuth#9961bcb4 flags:# request_write_access:flags.0?true fwd_text:flags.1?string url:string bot:flags.2?InputUser = InlineButtonType; + +inlineButtonTypeWebView#3bcab5b4 url:string = InlineButtonType; + +inlineButtonTypeCallback#2955bc38 flags:# requires_password:flags.0?true data:bytes = InlineButtonType; + +inlineButtonTypeGame#5cd3709d = InlineButtonType; + +inlineButtonTypeBuy#48bad7a5 = InlineButtonType; + +inlineButtonTypeSwitchInline#93773ff5 flags:# same_peer:flags.0?true query:string peer_types:flags.1?Vector = InlineButtonType; + +inlineButtonTypeUserProfile#3fa33fcf user_id:long = InlineButtonType; + +inputInlineButtonTypeUserProfile#53f3ce5a user_id:InputUser = InlineButtonType; + +inlineButtonTypeCopy#b41d3272 copy_text:string = InlineButtonType; + +inlineButtonTypeDisabled#a438619d = InlineButtonType; + +keyboardInlineButton#11c1a322 flags:# style:flags.10?KeyboardButtonStyle text:string type:InlineButtonType = KeyboardInlineButton; + +keyboardInlineButtonRow#19420af6 buttons:Vector = KeyboardInlineButtonRow; + +richButtonStyle#3c610bd flags:# bg_primary:flags.0?true bg_danger:flags.1?true bg_success:flags.2?true link:flags.3?true = RichButtonStyle; + +pageButton#692a5488 flags:# text:RichText type:InlineButtonType style:flags.0?RichButtonStyle = PageButton; + +ephemeral.welcomeMessagesNotModified#59ffdb31 = ephemeral.WelcomeMessages; + +ephemeral.welcomeMessages#104fc872 hash:long messages:Vector = ephemeral.WelcomeMessages; + +auth.firebasePnvIntent#df5ac00c nonce:string digital_credential_payload:string = auth.FirebasePnvIntent; + ---functions--- @@ -3407,6 +3435,12 @@ auth.initPasskeyLogin#518ad0b7 api_id:int api_hash:string = auth.PasskeyLoginOpt auth.finishPasskeyLogin#9857ad07 flags:# credential:InputPasskeyCredential from_dc_id:flags.0?int from_auth_key_id:flags.0?long = auth.Authorization; +auth.initFirebasePnvLogin#777df37a api_id:int api_hash:string = auth.FirebasePnvIntent; + +auth.finishFirebasePnvLogin#2c85094c google_token:string = auth.Authorization; + +auth.firebasePnvSignUp#783f6b56 flags:# no_joined_notifications:flags.0?true first_name:string last_name:string = auth.Authorization; + account.registerDevice#ec86017a flags:# no_muted:flags.0?true token_type:int token:string app_sandbox:Bool secret:bytes other_uids:Vector = Bool; account.unregisterDevice#6a0d3206 token_type:int token:string other_uids:Vector = Bool; @@ -3755,7 +3789,7 @@ messages.sendMessage#fef48f62 flags:# no_webpage:flags.1?true silent:flags.5?tru messages.sendMedia#330e77f flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true allow_paid_floodskip:flags.19?true peer:InputPeer reply_to:flags.0?InputReplyTo media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int schedule_repeat_period:flags.24?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long allow_paid_stars:flags.21?long suggested_post:flags.22?SuggestedPost = Updates; -messages.forwardMessages#13704a7c flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true drop_author:flags.11?true drop_media_captions:flags.12?true noforwards:flags.14?true allow_paid_floodskip:flags.19?true from_peer:InputPeer id:Vector random_id:Vector to_peer:InputPeer top_msg_id:flags.9?int reply_to:flags.22?InputReplyTo schedule_date:flags.10?int schedule_repeat_period:flags.24?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long video_timestamp:flags.20?int allow_paid_stars:flags.21?long suggested_post:flags.23?SuggestedPost = Updates; +messages.forwardMessages#13704a7c flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true drop_author:flags.11?true drop_media_captions:flags.12?true noforwards:flags.14?true allow_paid_floodskip:flags.19?true from_ephemeral:flags.25?true from_peer:InputPeer id:Vector random_id:Vector to_peer:InputPeer top_msg_id:flags.9?int reply_to:flags.22?InputReplyTo schedule_date:flags.10?int schedule_repeat_period:flags.24?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long video_timestamp:flags.20?int allow_paid_stars:flags.21?long suggested_post:flags.23?SuggestedPost = Updates; messages.reportSpam#cf1592db peer:InputPeer = Bool; @@ -4937,14 +4971,20 @@ communities.toggleParticipantBanned#9967ad0f flags:# unban:flags.0?true communit communities.getParticipantJoinedChats#f87eabab community:InputChannel participant:InputPeer = communities.ParticipantJoinedChats; -ephemeral.sendMessage#68cbd09f flags:# peer:InputPeer receiver_id:InputUser query_id:flags.0?long message:string entities:flags.1?Vector media:flags.2?InputMedia reply_markup:flags.3?ReplyMarkup rich_message:flags.4?InputRichMessage random_id:long reply_to:flags.5?InputReplyTo = Updates; +ephemeral.sendMessage#ba8d5f35 flags:# invert_media:flags.6?true welcome:flags.7?true anchor:flags.9?true noforwards:flags.10?true peer:flags.8?InputPeer receiver_id:InputUser query_id:flags.0?long message:string entities:flags.1?Vector media:flags.2?InputMedia reply_markup:flags.3?ReplyMarkup rich_message:flags.4?InputRichMessage random_id:long reply_to:flags.5?InputReplyTo = Updates; -ephemeral.deleteMessage#a3c0d511 peer:InputPeer receiver_id:InputUser id:int = Bool; +ephemeral.deleteMessage#92f6e797 flags:# peer:flags.0?InputPeer receiver_id:InputUser id:int = Bool; ephemeral.reportMessage#8704f2bf peer:InputPeer id:int option:bytes message:string = ReportResult; ephemeral.getCallbackAnswer#3fa464c8 flags:# peer:InputPeer id:int data:flags.1?bytes = messages.BotCallbackAnswer; -ephemeral.editMessage#13f250ee flags:# peer:InputPeer receiver_id:InputUser id:int message:flags.0?string media:flags.3?InputMedia entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup = Updates; +ephemeral.editMessage#cf9c725b flags:# invert_media:flags.5?true welcome:flags.6?true peer:flags.7?InputPeer receiver_id:InputUser id:int message:flags.0?string media:flags.3?InputMedia entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup rich_message:flags.4?InputRichMessage = Updates; + +ephemeral.deleteWelcomeMessage#e882a9e1 peer:InputPeer id:int = Bool; + +ephemeral.deleteAllWelcomeMessages#734f9721 peer:InputPeer = Bool; + +ephemeral.getWelcomeMessages#db9ac18d peer:InputPeer hash:long = ephemeral.WelcomeMessages; -// LAYER 228 +// LAYER 229 diff --git a/_schema/telegram.tl b/_schema/telegram.tl index 827efab12a..b1baa7fdb6 100644 --- a/_schema/telegram.tl +++ b/_schema/telegram.tl @@ -2,8 +2,8 @@ // // Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/SourceFiles/mtproto/scheme/api.tl // Merge: _schema/legacy.tl -// Layer: 228 -// SHA256: bbddd9c4c3f5ff16fd4abbf39f2a864fdac7553e9f05b6bf9ead2aeb9c8eb566 +// Layer: 229 +// SHA256: 7655504c25a5d3a368e7729d3e9e64afffcacbcb54ec85508c60f0472064b617 boolFalse#bc799737 = Bool; @@ -179,9 +179,9 @@ communityForbidden#fd3cdab8 flags:# id:long access_hash:flags.13?long title:stri community#65efe954 flags:# creator:flags.0?true left:flags.2?true min:flags.12?true flags2:# collapsed_in_dialogs:flags2.20?true id:long access_hash:flags.13?long title:string photo:ChatPhoto date:int admin_rights:flags.14?ChatAdminRights default_banned_rights:flags.18?ChatBannedRights = Chat; -chatFull#2633421b flags:# can_set_username:flags.7?true has_scheduled:flags.8?true translations_disabled:flags.19?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector available_reactions:flags.18?ChatReactions reactions_limit:flags.20?int = ChatFull; +chatFull#2633421b flags:# can_set_username:flags.7?true has_scheduled:flags.8?true translations_disabled:flags.19?true has_welcome_messages:flags.21?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector available_reactions:flags.18?ChatReactions reactions_limit:flags.20?int = ChatFull; -channelFull#a04e8d3a flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true antispam:flags2.1?true participants_hidden:flags2.2?true translations_disabled:flags2.3?true stories_pinned_available:flags2.5?true view_forum_as_messages:flags2.6?true restricted_sponsored:flags2.11?true can_view_revenue:flags2.12?true paid_media_allowed:flags2.14?true can_view_stars_revenue:flags2.15?true paid_reactions_available:flags2.16?true stargifts_available:flags2.19?true paid_messages_available:flags2.20?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions reactions_limit:flags2.13?int stories:flags2.4?PeerStories wallpaper:flags2.7?WallPaper boosts_applied:flags2.8?int boosts_unrestrict:flags2.9?int emojiset:flags2.10?StickerSet bot_verification:flags2.17?BotVerification stargifts_count:flags2.18?int send_paid_messages_stars:flags2.21?long main_tab:flags2.22?ProfileTab guard_bot_id:flags2.23?long = ChatFull; +channelFull#a04e8d3a flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true antispam:flags2.1?true participants_hidden:flags2.2?true translations_disabled:flags2.3?true stories_pinned_available:flags2.5?true view_forum_as_messages:flags2.6?true restricted_sponsored:flags2.11?true can_view_revenue:flags2.12?true paid_media_allowed:flags2.14?true can_view_stars_revenue:flags2.15?true paid_reactions_available:flags2.16?true stargifts_available:flags2.19?true paid_messages_available:flags2.20?true has_welcome_messages:flags2.24?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions reactions_limit:flags2.13?int stories:flags2.4?PeerStories wallpaper:flags2.7?WallPaper boosts_applied:flags2.8?int boosts_unrestrict:flags2.9?int emojiset:flags2.10?StickerSet bot_verification:flags2.17?BotVerification stargifts_count:flags2.18?int send_paid_messages_stars:flags2.21?long main_tab:flags2.22?ProfileTab guard_bot_id:flags2.23?long = ChatFull; communityFull#cbb7a507 flags:# id:long about:string chat_photo:Photo linked_peers:Vector admins_count:flags.1?int kicked_count:flags.2?int peer_link_requests_pending:flags.0?int = ChatFull; @@ -337,7 +337,7 @@ messageActionPrizeStars#b00c47a2 flags:# unclaimed:flags.0?true stars:long trans messageActionStarGift#ea2c31d3 flags:# name_hidden:flags.0?true saved:flags.2?true converted:flags.3?true upgraded:flags.5?true refunded:flags.9?true can_upgrade:flags.10?true prepaid_upgrade:flags.13?true upgrade_separate:flags.16?true auction_acquired:flags.17?true gift:StarGift message:flags.1?TextWithEntities convert_stars:flags.4?long upgrade_msg_id:flags.5?int upgrade_stars:flags.8?long from_id:flags.11?Peer peer:flags.12?Peer saved_id:flags.12?long prepaid_upgrade_hash:flags.14?string gift_msg_id:flags.15?int to_id:flags.18?Peer gift_num:flags.19?int = MessageAction; -messageActionStarGiftUnique#e6c31522 flags:# upgrade:flags.0?true transferred:flags.1?true saved:flags.2?true refunded:flags.5?true prepaid_upgrade:flags.11?true assigned:flags.13?true from_offer:flags.14?true craft:flags.16?true gift:StarGift can_export_at:flags.3?int transfer_stars:flags.4?long from_id:flags.6?Peer peer:flags.7?Peer saved_id:flags.7?long resale_amount:flags.8?StarsAmount can_transfer_at:flags.9?int can_resell_at:flags.10?int drop_original_details_stars:flags.12?long can_craft_at:flags.15?int = MessageAction; +messageActionStarGiftUnique#7e1c1187 flags:# upgrade:flags.0?true transferred:flags.1?true saved:flags.2?true refunded:flags.5?true prepaid_upgrade:flags.11?true assigned:flags.13?true from_offer:flags.14?true craft:flags.16?true name_hidden:flags.17?true gift:StarGift can_export_at:flags.3?int transfer_stars:flags.4?long from_id:flags.6?Peer peer:flags.7?Peer saved_id:flags.7?long resale_amount:flags.8?StarsAmount can_transfer_at:flags.9?int can_resell_at:flags.10?int drop_original_details_stars:flags.12?long can_craft_at:flags.15?int message:flags.18?TextWithEntities = MessageAction; messageActionPaidMessagesRefunded#ac1f1fcd count:int stars:long = MessageAction; @@ -379,6 +379,8 @@ messageActionManagedBotCreated#16605e3e bot_id:long = MessageAction; messageActionChangeCommunity#5d20bae8 flags:# community_id:flags.0?long = MessageAction; +messageActionChatJoinedViaCommunity#4a8bfe80 community_id:long = MessageAction; + dialog#fc89f7f3 flags:# pinned:flags.2?true unread_mark:flags.3?true view_forum_as_messages:flags.6?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 unread_poll_votes_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; @@ -861,6 +863,8 @@ updateDeleteEphemeralMessages#56dbfcf8 peer:Peer ids:Vector = Update; updateEditEphemeralMessage#4bbb8f01 message:EphemeralMessage = Update; +updateEphemeralBotCallbackQuery#7c1079d6 flags:# query_id:long user_id:long peer:flags.0?Peer msg_id:int data:bytes chat_instance:flags.1?long message:EphemeralMessage = Update; + updateBotStarsSubscription#6c0d8e23 flags:# canceled:flags.0?true payment_failed:flags.1?true restored:flags.2?true user_id:long payload:bytes qts:int = Update; updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; @@ -1003,11 +1007,13 @@ sendMessageEmojiInteraction#25972bcb emoticon:string msg_id:int interaction:Data sendMessageEmojiInteractionSeen#b665902e emoticon:string = SendMessageAction; -sendMessageTextDraftAction#376d975c random_id:long text:TextWithEntities = SendMessageAction; +sendMessageTextDraftAction#3630b85a flags:# can_stop:flags.0?true keep_on_stop:flags.1?true random_id:long text:TextWithEntities = SendMessageAction; -inputSendMessageRichMessageDraftAction#e2b23b51 random_id:long rich_message:InputRichMessage = SendMessageAction; +inputSendMessageRichMessageDraftAction#a937c7be flags:# can_stop:flags.0?true keep_on_stop:flags.1?true random_id:long rich_message:InputRichMessage = SendMessageAction; -sendMessageRichMessageDraftAction#a2cb24f9 random_id:long rich_message:RichMessage = SendMessageAction; +sendMessageRichMessageDraftAction#52564893 flags:# can_stop:flags.0?true keep_on_stop:flags.1?true random_id:long rich_message:RichMessage = SendMessageAction; + +sendMessageStopDraftAction#fbf902b0 random_id:long = SendMessageAction; contacts.found#b3134d9d my_results:Vector results:Vector chats:Vector users:Vector = contacts.Found; @@ -1213,41 +1219,7 @@ botCommand#9852d6d2 flags:# ephemeral:flags.0?true command:string description:st botInfo#4d8a0299 flags:# has_preview_medias:flags.6?true user_id:flags.0?long description:flags.1?string description_photo:flags.4?Photo description_document:flags.5?Document commands:flags.2?Vector menu_button:flags.3?BotMenuButton privacy_policy_url:flags.7?string app_settings:flags.8?BotAppSettings verifier_settings:flags.9?BotVerifierSettings = BotInfo; -keyboardButton#7d170cff flags:# style:flags.10?KeyboardButtonStyle text:string = KeyboardButton; - -keyboardButtonUrl#d80c25ec flags:# style:flags.10?KeyboardButtonStyle text:string url:string = KeyboardButton; - -keyboardButtonCallback#e62bc960 flags:# requires_password:flags.0?true style:flags.10?KeyboardButtonStyle text:string data:bytes = KeyboardButton; - -keyboardButtonRequestPhone#417efd8f flags:# style:flags.10?KeyboardButtonStyle text:string = KeyboardButton; - -keyboardButtonRequestGeoLocation#aa40f94d flags:# style:flags.10?KeyboardButtonStyle text:string = KeyboardButton; - -keyboardButtonSwitchInline#991399fc flags:# same_peer:flags.0?true style:flags.10?KeyboardButtonStyle text:string query:string peer_types:flags.1?Vector = KeyboardButton; - -keyboardButtonGame#89c590f9 flags:# style:flags.10?KeyboardButtonStyle text:string = KeyboardButton; - -keyboardButtonBuy#3fa53905 flags:# style:flags.10?KeyboardButtonStyle text:string = KeyboardButton; - -keyboardButtonUrlAuth#f51006f9 flags:# style:flags.10?KeyboardButtonStyle text:string fwd_text:flags.0?string url:string button_id:int = KeyboardButton; - -inputKeyboardButtonUrlAuth#68013e72 flags:# request_write_access:flags.0?true style:flags.10?KeyboardButtonStyle text:string fwd_text:flags.1?string url:string bot:InputUser = KeyboardButton; - -keyboardButtonRequestPoll#7a11d782 flags:# style:flags.10?KeyboardButtonStyle quiz:flags.0?Bool text:string = KeyboardButton; - -inputKeyboardButtonUserProfile#7d5e07c7 flags:# style:flags.10?KeyboardButtonStyle text:string user_id:InputUser = KeyboardButton; - -keyboardButtonUserProfile#c0fd5d09 flags:# style:flags.10?KeyboardButtonStyle text:string user_id:long = KeyboardButton; - -keyboardButtonWebView#e846b1a0 flags:# style:flags.10?KeyboardButtonStyle text:string url:string = KeyboardButton; - -keyboardButtonSimpleWebView#e15c4370 flags:# style:flags.10?KeyboardButtonStyle text:string url:string = KeyboardButton; - -keyboardButtonRequestPeer#5b0f15f5 flags:# style:flags.10?KeyboardButtonStyle text:string button_id:int peer_type:RequestPeerType max_quantity:int = KeyboardButton; - -inputKeyboardButtonRequestPeer#2b78156 flags:# name_requested:flags.0?true username_requested:flags.1?true photo_requested:flags.2?true style:flags.10?KeyboardButtonStyle text:string button_id:int peer_type:RequestPeerType max_quantity:int = KeyboardButton; - -keyboardButtonCopy#bcc4af10 flags:# style:flags.10?KeyboardButtonStyle text:string copy_text:string = KeyboardButton; +keyboardButton#2f67a72f flags:# style:flags.10?KeyboardButtonStyle text:string type:ButtonType = KeyboardButton; keyboardButtonRow#77608b83 buttons:Vector = KeyboardButtonRow; @@ -1255,9 +1227,9 @@ 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 persistent:flags.4?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 force_reply:flags.5?true rows:Vector placeholder:flags.3?string = ReplyMarkup; -replyInlineMarkup#48a30254 rows:Vector = ReplyMarkup; +replyInlineMarkup#b2b15770 flags:# force_reply:flags.5?true rows:Vector = ReplyMarkup; messageEntityUnknown#bb92ba95 offset:int length:int = MessageEntity; @@ -1597,6 +1569,8 @@ textDate#a5b45e2b flags:# relative:flags.0?true short_time:flags.1?true long_tim textDiff#9686cb50 text:RichText old_text:RichText = RichText; +textButton#afc79cd6 flags:# text:RichText type:InlineButtonType style:flags.0?RichButtonStyle = RichText; + pageBlockUnsupported#13567e8a = PageBlock; pageBlockTitle#70abc3fd text:RichText = PageBlock; @@ -1621,7 +1595,7 @@ pageBlockAnchor#ce0d37b0 name:string = PageBlock; pageBlockList#e4e88011 items:Vector = PageBlock; -pageBlockBlockquote#263d7c26 text:RichText caption:RichText = PageBlock; +pageBlockBlockquote#66d1670b flags:# collapsed:flags.0?true text:RichText caption:RichText = PageBlock; pageBlockPullquote#4f4456d3 text:RichText caption:RichText = PageBlock; @@ -1645,7 +1619,7 @@ pageBlockAudio#804361ea audio_id:long caption:PageCaption = PageBlock; pageBlockKicker#1e148390 text:RichText = PageBlock; -pageBlockTable#bf4dea82 flags:# bordered:flags.0?true striped:flags.1?true title:RichText rows:Vector = PageBlock; +pageBlockTable#bf4dea82 flags:# bordered:flags.0?true striped:flags.1?true compact:flags.2?true title:RichText rows:Vector = PageBlock; pageBlockOrderedList#1fd6f6c1 flags:# reversed:flags.2?true items:Vector start:flags.0?int type:flags.1?string = PageBlock; @@ -1675,6 +1649,10 @@ inputPageBlockMap#574b617f geo:InputGeoPoint zoom:int w:int h:int caption:PageCa pageBlockBlockquoteBlocks#e6e47c4 blocks:Vector caption:RichText = PageBlock; +pageBlockButtonRow#6d640318 flags:# align_left:flags.0?true align_center:flags.1?true align_right:flags.2?true buttons:Vector = PageBlock; + +pageBlockDocument#38fa3ba3 document_id:long caption:PageCaption = PageBlock; + phoneCallDiscardReasonMissed#85e42301 = PhoneCallDiscardReason; phoneCallDiscardReasonDisconnect#e095c1a0 = PhoneCallDiscardReason; @@ -2107,7 +2085,7 @@ chatOnlines#f041e250 onlines:int = ChatOnlines; statsURL#47a971e0 url:string = StatsURL; -chatAdminRights#5fb224d5 flags:# change_info:flags.0?true post_messages:flags.1?true edit_messages:flags.2?true delete_messages:flags.3?true ban_users:flags.4?true invite_users:flags.5?true pin_messages:flags.7?true add_admins:flags.9?true anonymous:flags.10?true manage_call:flags.11?true other:flags.12?true manage_topics:flags.13?true post_stories:flags.14?true edit_stories:flags.15?true delete_stories:flags.16?true manage_direct_messages:flags.17?true manage_ranks:flags.18?true manage_linked_peers:flags.19?true = ChatAdminRights; +chatAdminRights#5fb224d5 flags:# change_info:flags.0?true post_messages:flags.1?true edit_messages:flags.2?true delete_messages:flags.3?true ban_users:flags.4?true invite_users:flags.5?true pin_messages:flags.7?true add_admins:flags.9?true anonymous:flags.10?true manage_call:flags.11?true other:flags.12?true manage_topics:flags.13?true post_stories:flags.14?true edit_stories:flags.15?true delete_stories:flags.16?true manage_direct_messages:flags.17?true manage_ranks:flags.18?true manage_linked_peers:flags.19?true manage_welcome_messages:flags.20?true = ChatAdminRights; chatBannedRights#9f120418 flags:# view_messages:flags.0?true send_messages:flags.1?true send_media:flags.2?true send_stickers:flags.3?true send_gifs:flags.4?true send_games:flags.5?true send_inline:flags.6?true embed_links:flags.7?true send_polls:flags.8?true change_info:flags.10?true invite_users:flags.15?true pin_messages:flags.17?true manage_topics:flags.18?true send_photos:flags.19?true send_videos:flags.20?true send_roundvideos:flags.21?true send_audios:flags.22?true send_voices:flags.23?true send_docs:flags.24?true send_plain:flags.25?true edit_rank:flags.26?true send_reactions:flags.27?true manage_linked_peers:flags.28?true until_date:int = ChatBannedRights; @@ -2481,7 +2459,7 @@ inputInvoicePremiumGiftStars#dabab2ef flags:# user_id:InputUser months:int messa inputInvoiceBusinessBotTransferStars#f4997e42 bot:InputUser stars:long = InputInvoice; -inputInvoiceStarGiftResale#c39f5324 flags:# ton:flags.0?true slug:string to_id:InputPeer = InputInvoice; +inputInvoiceStarGiftResale#e9b0c658 flags:# ton:flags.0?true show_name:flags.2?true slug:string to_id:InputPeer message:flags.1?TextWithEntities = InputInvoice; inputInvoiceStarGiftPrepaidUpgrade#9a0b48b8 peer:InputPeer hash:string = InputInvoice; @@ -3281,7 +3259,7 @@ communityPeerRequest#7beafa85 flags:# visible:flags.0?true peer:Peer requested_b communities.peerLinkRequests#2244afad flags:# total_count:int requests:Vector next_offset:flags.0?string chats:Vector users:Vector = communities.PeerLinkRequests; -ephemeralMessage#d9c6dc1a flags:# out:flags.0?true id:int from_id:Peer peer_id:Peer receiver_id:long top_msg_id:flags.1?int date:int message:string entities:flags.2?Vector media:flags.3?MessageMedia reply_markup:flags.4?ReplyMarkup reply_to:flags.6?MessageReplyHeader = EphemeralMessage; +ephemeralMessage#dd27bee9 flags:# out:flags.0?true welcome_template:flags.5?true invert_media:flags.7?true noforwards:flags.12?true id:int from_id:Peer peer_id:flags.9?Peer receiver_id:long top_msg_id:flags.1?int date:int message:string entities:flags.2?Vector media:flags.3?MessageMedia reply_markup:flags.4?ReplyMarkup reply_to:flags.6?MessageReplyHeader rich_message:flags.8?RichMessage chat_instance:flags.10?long anchor_msg_id:flags.11?int = EphemeralMessage; communities.participantJoinedChats#8d78512a creator_chat_ids:Vector joined_chat_ids:Vector chats:Vector users:Vector = communities.ParticipantJoinedChats; @@ -3289,6 +3267,58 @@ messages.translatedRichMessage#4203998f result:Vector = messages.Tr messages.composedRichMessageWithAI#4c4537c8 result:RichMessage = messages.ComposedRichMessageWithAI; +buttonTypeDefault#c9dd90e9 = ButtonType; + +buttonTypeRequestPhone#df3d36f9 = ButtonType; + +buttonTypeRequestGeoLocation#9beee140 = ButtonType; + +buttonTypeRequestPoll#aacfff84 flags:# quiz:flags.0?Bool = ButtonType; + +buttonTypeRequestPeer#4f58a237 flags:# button_id:int peer_type:RequestPeerType max_quantity:int = ButtonType; + +inputButtonTypeRequestPeer#3fe268fe flags:# name_requested:flags.0?true username_requested:flags.1?true photo_requested:flags.2?true button_id:int peer_type:RequestPeerType max_quantity:int = ButtonType; + +buttonTypeSimpleWebView#c01a597a url:string = ButtonType; + +inlineButtonTypeUrl#eca4f8d4 url:string = InlineButtonType; + +inlineButtonTypeUrlAuth#bfd02da2 flags:# fwd_text:flags.0?string url:string button_id:int = InlineButtonType; + +inputInlineButtonTypeUrlAuth#9961bcb4 flags:# request_write_access:flags.0?true fwd_text:flags.1?string url:string bot:flags.2?InputUser = InlineButtonType; + +inlineButtonTypeWebView#3bcab5b4 url:string = InlineButtonType; + +inlineButtonTypeCallback#2955bc38 flags:# requires_password:flags.0?true data:bytes = InlineButtonType; + +inlineButtonTypeGame#5cd3709d = InlineButtonType; + +inlineButtonTypeBuy#48bad7a5 = InlineButtonType; + +inlineButtonTypeSwitchInline#93773ff5 flags:# same_peer:flags.0?true query:string peer_types:flags.1?Vector = InlineButtonType; + +inlineButtonTypeUserProfile#3fa33fcf user_id:long = InlineButtonType; + +inputInlineButtonTypeUserProfile#53f3ce5a user_id:InputUser = InlineButtonType; + +inlineButtonTypeCopy#b41d3272 copy_text:string = InlineButtonType; + +inlineButtonTypeDisabled#a438619d = InlineButtonType; + +keyboardInlineButton#11c1a322 flags:# style:flags.10?KeyboardButtonStyle text:string type:InlineButtonType = KeyboardInlineButton; + +keyboardInlineButtonRow#19420af6 buttons:Vector = KeyboardInlineButtonRow; + +richButtonStyle#3c610bd flags:# bg_primary:flags.0?true bg_danger:flags.1?true bg_success:flags.2?true link:flags.3?true = RichButtonStyle; + +pageButton#692a5488 flags:# text:RichText type:InlineButtonType style:flags.0?RichButtonStyle = PageButton; + +ephemeral.welcomeMessagesNotModified#59ffdb31 = ephemeral.WelcomeMessages; + +ephemeral.welcomeMessages#104fc872 hash:long messages:Vector = ephemeral.WelcomeMessages; + +auth.firebasePnvIntent#df5ac00c nonce:string digital_credential_payload:string = auth.FirebasePnvIntent; + ---functions--- @@ -3366,6 +3396,12 @@ auth.initPasskeyLogin#518ad0b7 api_id:int api_hash:string = auth.PasskeyLoginOpt auth.finishPasskeyLogin#9857ad07 flags:# credential:InputPasskeyCredential from_dc_id:flags.0?int from_auth_key_id:flags.0?long = auth.Authorization; +auth.initFirebasePnvLogin#777df37a api_id:int api_hash:string = auth.FirebasePnvIntent; + +auth.finishFirebasePnvLogin#2c85094c google_token:string = auth.Authorization; + +auth.firebasePnvSignUp#783f6b56 flags:# no_joined_notifications:flags.0?true first_name:string last_name:string = auth.Authorization; + account.registerDevice#ec86017a flags:# no_muted:flags.0?true token_type:int token:string app_sandbox:Bool secret:bytes other_uids:Vector = Bool; account.unregisterDevice#6a0d3206 token_type:int token:string other_uids:Vector = Bool; @@ -3714,7 +3750,7 @@ messages.sendMessage#fef48f62 flags:# no_webpage:flags.1?true silent:flags.5?tru messages.sendMedia#330e77f flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true allow_paid_floodskip:flags.19?true peer:InputPeer reply_to:flags.0?InputReplyTo media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int schedule_repeat_period:flags.24?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long allow_paid_stars:flags.21?long suggested_post:flags.22?SuggestedPost = Updates; -messages.forwardMessages#13704a7c flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true drop_author:flags.11?true drop_media_captions:flags.12?true noforwards:flags.14?true allow_paid_floodskip:flags.19?true from_peer:InputPeer id:Vector random_id:Vector to_peer:InputPeer top_msg_id:flags.9?int reply_to:flags.22?InputReplyTo schedule_date:flags.10?int schedule_repeat_period:flags.24?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long video_timestamp:flags.20?int allow_paid_stars:flags.21?long suggested_post:flags.23?SuggestedPost = Updates; +messages.forwardMessages#13704a7c flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true drop_author:flags.11?true drop_media_captions:flags.12?true noforwards:flags.14?true allow_paid_floodskip:flags.19?true from_ephemeral:flags.25?true from_peer:InputPeer id:Vector random_id:Vector to_peer:InputPeer top_msg_id:flags.9?int reply_to:flags.22?InputReplyTo schedule_date:flags.10?int schedule_repeat_period:flags.24?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long video_timestamp:flags.20?int allow_paid_stars:flags.21?long suggested_post:flags.23?SuggestedPost = Updates; messages.reportSpam#cf1592db peer:InputPeer = Bool; @@ -4896,14 +4932,22 @@ communities.toggleParticipantBanned#9967ad0f flags:# unban:flags.0?true communit communities.getParticipantJoinedChats#f87eabab community:InputChannel participant:InputPeer = communities.ParticipantJoinedChats; -ephemeral.sendMessage#68cbd09f flags:# peer:InputPeer receiver_id:InputUser query_id:flags.0?long message:string entities:flags.1?Vector media:flags.2?InputMedia reply_markup:flags.3?ReplyMarkup rich_message:flags.4?InputRichMessage random_id:long reply_to:flags.5?InputReplyTo = Updates; +ephemeral.sendMessage#ba8d5f35 flags:# invert_media:flags.6?true welcome:flags.7?true anchor:flags.9?true noforwards:flags.10?true peer:flags.8?InputPeer receiver_id:InputUser query_id:flags.0?long message:string entities:flags.1?Vector media:flags.2?InputMedia reply_markup:flags.3?ReplyMarkup rich_message:flags.4?InputRichMessage random_id:long reply_to:flags.5?InputReplyTo = Updates; -ephemeral.deleteMessage#a3c0d511 peer:InputPeer receiver_id:InputUser id:int = Bool; +ephemeral.deleteMessage#92f6e797 flags:# peer:flags.0?InputPeer receiver_id:InputUser id:int = Bool; ephemeral.reportMessage#8704f2bf peer:InputPeer id:int option:bytes message:string = ReportResult; ephemeral.getCallbackAnswer#3fa464c8 flags:# peer:InputPeer id:int data:flags.1?bytes = messages.BotCallbackAnswer; +ephemeral.editMessage#cf9c725b flags:# invert_media:flags.5?true welcome:flags.6?true peer:flags.7?InputPeer receiver_id:InputUser id:int message:flags.0?string media:flags.3?InputMedia entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup rich_message:flags.4?InputRichMessage = Updates; + +ephemeral.deleteWelcomeMessage#e882a9e1 peer:InputPeer id:int = Bool; + +ephemeral.deleteAllWelcomeMessages#734f9721 peer:InputPeer = Bool; + +ephemeral.getWelcomeMessages#db9ac18d peer:InputPeer hash:long = ephemeral.WelcomeMessages; + ---types--- @@ -4936,4 +4980,4 @@ test.useError#ee75af01 = Error; test.useConfigSimple#f9b7b23d = help.ConfigSimple; -// LAYER 228 +// LAYER 229 diff --git a/telegram/message/typing.gen.go b/telegram/message/typing.gen.go index 9a089455fd..03ef41b12d 100644 --- a/telegram/message/typing.gen.go +++ b/telegram/message/typing.gen.go @@ -121,25 +121,38 @@ func (b *TypingActionBuilder) EmojiInteractionSeen(ctx context.Context, emoticon } // TextDraft sends SendMessageTextDraftAction. -func (b *TypingActionBuilder) TextDraft(ctx context.Context, randomID int64, text tg.TextWithEntities) error { +func (b *TypingActionBuilder) TextDraft(ctx context.Context, canStop bool, keepOnStop bool, randomID int64, text tg.TextWithEntities) error { return b.send(ctx, &tg.SendMessageTextDraftAction{ - RandomID: randomID, - Text: text, + CanStop: canStop, + KeepOnStop: keepOnStop, + RandomID: randomID, + Text: text, }) } // InputSendMessageRichMessageDraft sends InputSendMessageRichMessageDraftAction. -func (b *TypingActionBuilder) InputSendMessageRichMessageDraft(ctx context.Context, randomID int64, richMessage tg.InputRichMessageClass) error { +func (b *TypingActionBuilder) InputSendMessageRichMessageDraft(ctx context.Context, canStop bool, keepOnStop bool, randomID int64, richMessage tg.InputRichMessageClass) error { return b.send(ctx, &tg.InputSendMessageRichMessageDraftAction{ + CanStop: canStop, + KeepOnStop: keepOnStop, RandomID: randomID, RichMessage: richMessage, }) } // RichMessageDraft sends SendMessageRichMessageDraftAction. -func (b *TypingActionBuilder) RichMessageDraft(ctx context.Context, randomID int64, richMessage tg.RichMessage) error { +func (b *TypingActionBuilder) RichMessageDraft(ctx context.Context, canStop bool, keepOnStop bool, randomID int64, richMessage tg.RichMessage) error { return b.send(ctx, &tg.SendMessageRichMessageDraftAction{ + CanStop: canStop, + KeepOnStop: keepOnStop, RandomID: randomID, RichMessage: richMessage, }) } + +// StopDraft sends SendMessageStopDraftAction. +func (b *TypingActionBuilder) StopDraft(ctx context.Context, randomID int64) error { + return b.send(ctx, &tg.SendMessageStopDraftAction{ + RandomID: randomID, + }) +} diff --git a/telegram/query/cached/queries.gen.go b/telegram/query/cached/queries.gen.go index d1c895da4f..16d07caf68 100644 --- a/telegram/query/cached/queries.gen.go +++ b/telegram/query/cached/queries.gen.go @@ -1362,6 +1362,94 @@ func (s *ContactsGetContacts) Fetch(ctx context.Context) (bool, error) { } } +type innerEphemeralGetWelcomeMessages struct { + // Last received hash. + hash int64 + // Last received result. + value *tg.EphemeralWelcomeMessages +} + +type EphemeralGetWelcomeMessages struct { + // Query to send. + req *tg.EphemeralGetWelcomeMessagesRequest + // Result state. + last atomic.Value + + // Reference to RPC client to make requests. + raw *tg.Client +} + +// NewEphemeralGetWelcomeMessages creates new EphemeralGetWelcomeMessages. +func NewEphemeralGetWelcomeMessages(raw *tg.Client, initial *tg.EphemeralGetWelcomeMessagesRequest) *EphemeralGetWelcomeMessages { + q := &EphemeralGetWelcomeMessages{ + req: initial, + raw: raw, + } + + return q +} + +func (s *EphemeralGetWelcomeMessages) store(v innerEphemeralGetWelcomeMessages) { + s.last.Store(v) +} + +func (s *EphemeralGetWelcomeMessages) load() (innerEphemeralGetWelcomeMessages, bool) { + v, ok := s.last.Load().(innerEphemeralGetWelcomeMessages) + return v, ok +} + +// Value returns last received result. +// NB: May be nil. Returned EphemeralWelcomeMessages must not be mutated. +func (s *EphemeralGetWelcomeMessages) Value() *tg.EphemeralWelcomeMessages { + inner, _ := s.load() + return inner.value +} + +// Hash returns last received hash. +func (s *EphemeralGetWelcomeMessages) Hash() int64 { + inner, _ := s.load() + return inner.hash +} + +// Get updates data if needed and returns it. +func (s *EphemeralGetWelcomeMessages) Get(ctx context.Context) (*tg.EphemeralWelcomeMessages, error) { + if _, err := s.Fetch(ctx); err != nil { + return nil, err + } + + return s.Value(), nil +} + +// Fetch updates data if needed and returns true if data was modified. +func (s *EphemeralGetWelcomeMessages) Fetch(ctx context.Context) (bool, error) { + lastHash := s.Hash() + + req := s.req + req.Hash = lastHash + result, err := s.raw.EphemeralGetWelcomeMessages(ctx, req) + if err != nil { + return false, errors.Wrap(err, "execute EphemeralGetWelcomeMessages") + } + + switch variant := result.(type) { + case *tg.EphemeralWelcomeMessages: + hash := variant.Hash + + s.store(innerEphemeralGetWelcomeMessages{ + hash: hash, + value: variant, + }) + return true, nil + case *tg.EphemeralWelcomeMessagesNotModified: + if lastHash == 0 { + return false, errors.Errorf("got unexpected %T result", result) + } + return false, nil + default: + return false, errors.Errorf("unexpected type %T", result) + } +} + type innerMessagesGetAllStickers struct { // Last received hash. hash int64 diff --git a/tg/e2e/tl_registry_gen.go b/tg/e2e/tl_registry_gen.go index a61d6fbf29..bf6e41014c 100644 --- a/tg/e2e/tl_registry_gen.go +++ b/tg/e2e/tl_registry_gen.go @@ -134,26 +134,26 @@ func TypesMap() map[uint32]string { // NamesMap returns mapping from type names to TL type ids. func NamesMap() map[string]uint32 { return map[string]uint32{ - "int": IntTypeID, - "long": LongTypeID, - "double": DoubleTypeID, - "string": StringTypeID, - "bytes": BytesTypeID, - "boolFalse": BoolFalseTypeID, - "boolTrue": BoolTrueTypeID, - "true": TrueTypeID, - "decryptedMessage8": DecryptedMessage8TypeID, - "decryptedMessageService8": DecryptedMessageService8TypeID, - "decryptedMessageMediaEmpty": DecryptedMessageMediaEmptyTypeID, - "decryptedMessageMediaPhoto8": DecryptedMessageMediaPhoto8TypeID, - "decryptedMessageMediaVideo8": DecryptedMessageMediaVideo8TypeID, - "decryptedMessageMediaGeoPoint": DecryptedMessageMediaGeoPointTypeID, - "decryptedMessageMediaContact": DecryptedMessageMediaContactTypeID, - "decryptedMessageActionSetMessageTTL": DecryptedMessageActionSetMessageTTLTypeID, - "decryptedMessageMediaDocument8": DecryptedMessageMediaDocument8TypeID, - "decryptedMessageMediaAudio8": DecryptedMessageMediaAudio8TypeID, - "decryptedMessageActionReadMessages": DecryptedMessageActionReadMessagesTypeID, - "decryptedMessageActionDeleteMessages": DecryptedMessageActionDeleteMessagesTypeID, + "int": IntTypeID, + "long": LongTypeID, + "double": DoubleTypeID, + "string": StringTypeID, + "bytes": BytesTypeID, + "boolFalse": BoolFalseTypeID, + "boolTrue": BoolTrueTypeID, + "true": TrueTypeID, + "decryptedMessage8": DecryptedMessage8TypeID, + "decryptedMessageService8": DecryptedMessageService8TypeID, + "decryptedMessageMediaEmpty": DecryptedMessageMediaEmptyTypeID, + "decryptedMessageMediaPhoto8": DecryptedMessageMediaPhoto8TypeID, + "decryptedMessageMediaVideo8": DecryptedMessageMediaVideo8TypeID, + "decryptedMessageMediaGeoPoint": DecryptedMessageMediaGeoPointTypeID, + "decryptedMessageMediaContact": DecryptedMessageMediaContactTypeID, + "decryptedMessageActionSetMessageTTL": DecryptedMessageActionSetMessageTTLTypeID, + "decryptedMessageMediaDocument8": DecryptedMessageMediaDocument8TypeID, + "decryptedMessageMediaAudio8": DecryptedMessageMediaAudio8TypeID, + "decryptedMessageActionReadMessages": DecryptedMessageActionReadMessagesTypeID, + "decryptedMessageActionDeleteMessages": DecryptedMessageActionDeleteMessagesTypeID, "decryptedMessageActionScreenshotMessages": DecryptedMessageActionScreenshotMessagesTypeID, "decryptedMessageActionFlushHistory": DecryptedMessageActionFlushHistoryTypeID, "decryptedMessage23": DecryptedMessage23TypeID, diff --git a/tg/tl_auth_finish_firebase_pnv_login_gen.go b/tg/tl_auth_finish_firebase_pnv_login_gen.go new file mode 100644 index 0000000000..ae2ae9a77b --- /dev/null +++ b/tg/tl_auth_finish_firebase_pnv_login_gen.go @@ -0,0 +1,176 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// AuthFinishFirebasePnvLoginRequest represents TL type `auth.finishFirebasePnvLogin#2c85094c`. +// +// See https://core.telegram.org/method/auth.finishFirebasePnvLogin for reference. +type AuthFinishFirebasePnvLoginRequest struct { + // GoogleToken field of AuthFinishFirebasePnvLoginRequest. + GoogleToken string +} + +// AuthFinishFirebasePnvLoginRequestTypeID is TL type id of AuthFinishFirebasePnvLoginRequest. +const AuthFinishFirebasePnvLoginRequestTypeID = 0x2c85094c + +// Ensuring interfaces in compile-time for AuthFinishFirebasePnvLoginRequest. +var ( + _ bin.Encoder = &AuthFinishFirebasePnvLoginRequest{} + _ bin.Decoder = &AuthFinishFirebasePnvLoginRequest{} + _ bin.BareEncoder = &AuthFinishFirebasePnvLoginRequest{} + _ bin.BareDecoder = &AuthFinishFirebasePnvLoginRequest{} +) + +func (f *AuthFinishFirebasePnvLoginRequest) Zero() bool { + if f == nil { + return true + } + if !(f.GoogleToken == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (f *AuthFinishFirebasePnvLoginRequest) String() string { + if f == nil { + return "AuthFinishFirebasePnvLoginRequest(nil)" + } + type Alias AuthFinishFirebasePnvLoginRequest + return fmt.Sprintf("AuthFinishFirebasePnvLoginRequest%+v", Alias(*f)) +} + +// FillFrom fills AuthFinishFirebasePnvLoginRequest from given interface. +func (f *AuthFinishFirebasePnvLoginRequest) FillFrom(from interface { + GetGoogleToken() (value string) +}) { + f.GoogleToken = from.GetGoogleToken() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AuthFinishFirebasePnvLoginRequest) TypeID() uint32 { + return AuthFinishFirebasePnvLoginRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*AuthFinishFirebasePnvLoginRequest) TypeName() string { + return "auth.finishFirebasePnvLogin" +} + +// TypeInfo returns info about TL type. +func (f *AuthFinishFirebasePnvLoginRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "auth.finishFirebasePnvLogin", + ID: AuthFinishFirebasePnvLoginRequestTypeID, + } + if f == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "GoogleToken", + SchemaName: "google_token", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (f *AuthFinishFirebasePnvLoginRequest) Encode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode auth.finishFirebasePnvLogin#2c85094c as nil") + } + b.PutID(AuthFinishFirebasePnvLoginRequestTypeID) + return f.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (f *AuthFinishFirebasePnvLoginRequest) EncodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode auth.finishFirebasePnvLogin#2c85094c as nil") + } + b.PutString(f.GoogleToken) + return nil +} + +// Decode implements bin.Decoder. +func (f *AuthFinishFirebasePnvLoginRequest) Decode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode auth.finishFirebasePnvLogin#2c85094c to nil") + } + if err := b.ConsumeID(AuthFinishFirebasePnvLoginRequestTypeID); err != nil { + return fmt.Errorf("unable to decode auth.finishFirebasePnvLogin#2c85094c: %w", err) + } + return f.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (f *AuthFinishFirebasePnvLoginRequest) DecodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode auth.finishFirebasePnvLogin#2c85094c to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode auth.finishFirebasePnvLogin#2c85094c: field google_token: %w", err) + } + f.GoogleToken = value + } + return nil +} + +// GetGoogleToken returns value of GoogleToken field. +func (f *AuthFinishFirebasePnvLoginRequest) GetGoogleToken() (value string) { + if f == nil { + return + } + return f.GoogleToken +} + +// AuthFinishFirebasePnvLogin invokes method auth.finishFirebasePnvLogin#2c85094c returning error if any. +// +// See https://core.telegram.org/method/auth.finishFirebasePnvLogin for reference. +func (c *Client) AuthFinishFirebasePnvLogin(ctx context.Context, googletoken string) (AuthAuthorizationClass, error) { + var result AuthAuthorizationBox + + request := &AuthFinishFirebasePnvLoginRequest{ + GoogleToken: googletoken, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.Authorization, nil +} diff --git a/tg/tl_auth_finish_firebase_pnv_login_slices_gen.go b/tg/tl_auth_finish_firebase_pnv_login_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_auth_finish_firebase_pnv_login_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_auth_firebase_pnv_intent_gen.go b/tg/tl_auth_firebase_pnv_intent_gen.go new file mode 100644 index 0000000000..8e68cbd912 --- /dev/null +++ b/tg/tl_auth_firebase_pnv_intent_gen.go @@ -0,0 +1,188 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// AuthFirebasePnvIntent represents TL type `auth.firebasePnvIntent#df5ac00c`. +// +// See https://core.telegram.org/constructor/auth.firebasePnvIntent for reference. +type AuthFirebasePnvIntent struct { + // Nonce field of AuthFirebasePnvIntent. + Nonce string + // DigitalCredentialPayload field of AuthFirebasePnvIntent. + DigitalCredentialPayload string +} + +// AuthFirebasePnvIntentTypeID is TL type id of AuthFirebasePnvIntent. +const AuthFirebasePnvIntentTypeID = 0xdf5ac00c + +// Ensuring interfaces in compile-time for AuthFirebasePnvIntent. +var ( + _ bin.Encoder = &AuthFirebasePnvIntent{} + _ bin.Decoder = &AuthFirebasePnvIntent{} + _ bin.BareEncoder = &AuthFirebasePnvIntent{} + _ bin.BareDecoder = &AuthFirebasePnvIntent{} +) + +func (f *AuthFirebasePnvIntent) Zero() bool { + if f == nil { + return true + } + if !(f.Nonce == "") { + return false + } + if !(f.DigitalCredentialPayload == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (f *AuthFirebasePnvIntent) String() string { + if f == nil { + return "AuthFirebasePnvIntent(nil)" + } + type Alias AuthFirebasePnvIntent + return fmt.Sprintf("AuthFirebasePnvIntent%+v", Alias(*f)) +} + +// FillFrom fills AuthFirebasePnvIntent from given interface. +func (f *AuthFirebasePnvIntent) FillFrom(from interface { + GetNonce() (value string) + GetDigitalCredentialPayload() (value string) +}) { + f.Nonce = from.GetNonce() + f.DigitalCredentialPayload = from.GetDigitalCredentialPayload() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AuthFirebasePnvIntent) TypeID() uint32 { + return AuthFirebasePnvIntentTypeID +} + +// TypeName returns name of type in TL schema. +func (*AuthFirebasePnvIntent) TypeName() string { + return "auth.firebasePnvIntent" +} + +// TypeInfo returns info about TL type. +func (f *AuthFirebasePnvIntent) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "auth.firebasePnvIntent", + ID: AuthFirebasePnvIntentTypeID, + } + if f == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Nonce", + SchemaName: "nonce", + }, + { + Name: "DigitalCredentialPayload", + SchemaName: "digital_credential_payload", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (f *AuthFirebasePnvIntent) Encode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode auth.firebasePnvIntent#df5ac00c as nil") + } + b.PutID(AuthFirebasePnvIntentTypeID) + return f.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (f *AuthFirebasePnvIntent) EncodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode auth.firebasePnvIntent#df5ac00c as nil") + } + b.PutString(f.Nonce) + b.PutString(f.DigitalCredentialPayload) + return nil +} + +// Decode implements bin.Decoder. +func (f *AuthFirebasePnvIntent) Decode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode auth.firebasePnvIntent#df5ac00c to nil") + } + if err := b.ConsumeID(AuthFirebasePnvIntentTypeID); err != nil { + return fmt.Errorf("unable to decode auth.firebasePnvIntent#df5ac00c: %w", err) + } + return f.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (f *AuthFirebasePnvIntent) DecodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode auth.firebasePnvIntent#df5ac00c to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode auth.firebasePnvIntent#df5ac00c: field nonce: %w", err) + } + f.Nonce = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode auth.firebasePnvIntent#df5ac00c: field digital_credential_payload: %w", err) + } + f.DigitalCredentialPayload = value + } + return nil +} + +// GetNonce returns value of Nonce field. +func (f *AuthFirebasePnvIntent) GetNonce() (value string) { + if f == nil { + return + } + return f.Nonce +} + +// GetDigitalCredentialPayload returns value of DigitalCredentialPayload field. +func (f *AuthFirebasePnvIntent) GetDigitalCredentialPayload() (value string) { + if f == nil { + return + } + return f.DigitalCredentialPayload +} diff --git a/tg/tl_auth_firebase_pnv_intent_slices_gen.go b/tg/tl_auth_firebase_pnv_intent_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_auth_firebase_pnv_intent_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_auth_firebase_pnv_sign_up_gen.go b/tg/tl_auth_firebase_pnv_sign_up_gen.go new file mode 100644 index 0000000000..14b9614bb4 --- /dev/null +++ b/tg/tl_auth_firebase_pnv_sign_up_gen.go @@ -0,0 +1,253 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// AuthFirebasePnvSignUpRequest represents TL type `auth.firebasePnvSignUp#783f6b56`. +// +// See https://core.telegram.org/method/auth.firebasePnvSignUp for reference. +type AuthFirebasePnvSignUpRequest struct { + // Flags field of AuthFirebasePnvSignUpRequest. + Flags bin.Fields + // NoJoinedNotifications field of AuthFirebasePnvSignUpRequest. + NoJoinedNotifications bool + // FirstName field of AuthFirebasePnvSignUpRequest. + FirstName string + // LastName field of AuthFirebasePnvSignUpRequest. + LastName string +} + +// AuthFirebasePnvSignUpRequestTypeID is TL type id of AuthFirebasePnvSignUpRequest. +const AuthFirebasePnvSignUpRequestTypeID = 0x783f6b56 + +// Ensuring interfaces in compile-time for AuthFirebasePnvSignUpRequest. +var ( + _ bin.Encoder = &AuthFirebasePnvSignUpRequest{} + _ bin.Decoder = &AuthFirebasePnvSignUpRequest{} + _ bin.BareEncoder = &AuthFirebasePnvSignUpRequest{} + _ bin.BareDecoder = &AuthFirebasePnvSignUpRequest{} +) + +func (f *AuthFirebasePnvSignUpRequest) Zero() bool { + if f == nil { + return true + } + if !(f.Flags.Zero()) { + return false + } + if !(f.NoJoinedNotifications == false) { + return false + } + if !(f.FirstName == "") { + return false + } + if !(f.LastName == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (f *AuthFirebasePnvSignUpRequest) String() string { + if f == nil { + return "AuthFirebasePnvSignUpRequest(nil)" + } + type Alias AuthFirebasePnvSignUpRequest + return fmt.Sprintf("AuthFirebasePnvSignUpRequest%+v", Alias(*f)) +} + +// FillFrom fills AuthFirebasePnvSignUpRequest from given interface. +func (f *AuthFirebasePnvSignUpRequest) FillFrom(from interface { + GetNoJoinedNotifications() (value bool) + GetFirstName() (value string) + GetLastName() (value string) +}) { + f.NoJoinedNotifications = from.GetNoJoinedNotifications() + f.FirstName = from.GetFirstName() + f.LastName = from.GetLastName() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AuthFirebasePnvSignUpRequest) TypeID() uint32 { + return AuthFirebasePnvSignUpRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*AuthFirebasePnvSignUpRequest) TypeName() string { + return "auth.firebasePnvSignUp" +} + +// TypeInfo returns info about TL type. +func (f *AuthFirebasePnvSignUpRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "auth.firebasePnvSignUp", + ID: AuthFirebasePnvSignUpRequestTypeID, + } + if f == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "NoJoinedNotifications", + SchemaName: "no_joined_notifications", + Null: !f.Flags.Has(0), + }, + { + Name: "FirstName", + SchemaName: "first_name", + }, + { + Name: "LastName", + SchemaName: "last_name", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (f *AuthFirebasePnvSignUpRequest) SetFlags() { + if !(f.NoJoinedNotifications == false) { + f.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (f *AuthFirebasePnvSignUpRequest) Encode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode auth.firebasePnvSignUp#783f6b56 as nil") + } + b.PutID(AuthFirebasePnvSignUpRequestTypeID) + return f.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (f *AuthFirebasePnvSignUpRequest) EncodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode auth.firebasePnvSignUp#783f6b56 as nil") + } + f.SetFlags() + if err := f.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode auth.firebasePnvSignUp#783f6b56: field flags: %w", err) + } + b.PutString(f.FirstName) + b.PutString(f.LastName) + return nil +} + +// Decode implements bin.Decoder. +func (f *AuthFirebasePnvSignUpRequest) Decode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode auth.firebasePnvSignUp#783f6b56 to nil") + } + if err := b.ConsumeID(AuthFirebasePnvSignUpRequestTypeID); err != nil { + return fmt.Errorf("unable to decode auth.firebasePnvSignUp#783f6b56: %w", err) + } + return f.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (f *AuthFirebasePnvSignUpRequest) DecodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode auth.firebasePnvSignUp#783f6b56 to nil") + } + { + if err := f.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode auth.firebasePnvSignUp#783f6b56: field flags: %w", err) + } + } + f.NoJoinedNotifications = f.Flags.Has(0) + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode auth.firebasePnvSignUp#783f6b56: field first_name: %w", err) + } + f.FirstName = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode auth.firebasePnvSignUp#783f6b56: field last_name: %w", err) + } + f.LastName = value + } + return nil +} + +// SetNoJoinedNotifications sets value of NoJoinedNotifications conditional field. +func (f *AuthFirebasePnvSignUpRequest) SetNoJoinedNotifications(value bool) { + if value { + f.Flags.Set(0) + f.NoJoinedNotifications = true + } else { + f.Flags.Unset(0) + f.NoJoinedNotifications = false + } +} + +// GetNoJoinedNotifications returns value of NoJoinedNotifications conditional field. +func (f *AuthFirebasePnvSignUpRequest) GetNoJoinedNotifications() (value bool) { + if f == nil { + return + } + return f.Flags.Has(0) +} + +// GetFirstName returns value of FirstName field. +func (f *AuthFirebasePnvSignUpRequest) GetFirstName() (value string) { + if f == nil { + return + } + return f.FirstName +} + +// GetLastName returns value of LastName field. +func (f *AuthFirebasePnvSignUpRequest) GetLastName() (value string) { + if f == nil { + return + } + return f.LastName +} + +// AuthFirebasePnvSignUp invokes method auth.firebasePnvSignUp#783f6b56 returning error if any. +// +// See https://core.telegram.org/method/auth.firebasePnvSignUp for reference. +func (c *Client) AuthFirebasePnvSignUp(ctx context.Context, request *AuthFirebasePnvSignUpRequest) (AuthAuthorizationClass, error) { + var result AuthAuthorizationBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.Authorization, nil +} diff --git a/tg/tl_auth_firebase_pnv_sign_up_slices_gen.go b/tg/tl_auth_firebase_pnv_sign_up_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_auth_firebase_pnv_sign_up_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_auth_init_firebase_pnv_login_gen.go b/tg/tl_auth_init_firebase_pnv_login_gen.go new file mode 100644 index 0000000000..efbd79a58c --- /dev/null +++ b/tg/tl_auth_init_firebase_pnv_login_gen.go @@ -0,0 +1,200 @@ +// 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{} +) + +// AuthInitFirebasePnvLoginRequest represents TL type `auth.initFirebasePnvLogin#777df37a`. +// +// See https://core.telegram.org/method/auth.initFirebasePnvLogin for reference. +type AuthInitFirebasePnvLoginRequest struct { + // APIID field of AuthInitFirebasePnvLoginRequest. + APIID int + // APIHash field of AuthInitFirebasePnvLoginRequest. + APIHash string +} + +// AuthInitFirebasePnvLoginRequestTypeID is TL type id of AuthInitFirebasePnvLoginRequest. +const AuthInitFirebasePnvLoginRequestTypeID = 0x777df37a + +// Ensuring interfaces in compile-time for AuthInitFirebasePnvLoginRequest. +var ( + _ bin.Encoder = &AuthInitFirebasePnvLoginRequest{} + _ bin.Decoder = &AuthInitFirebasePnvLoginRequest{} + _ bin.BareEncoder = &AuthInitFirebasePnvLoginRequest{} + _ bin.BareDecoder = &AuthInitFirebasePnvLoginRequest{} +) + +func (i *AuthInitFirebasePnvLoginRequest) Zero() bool { + if i == nil { + return true + } + if !(i.APIID == 0) { + return false + } + if !(i.APIHash == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *AuthInitFirebasePnvLoginRequest) String() string { + if i == nil { + return "AuthInitFirebasePnvLoginRequest(nil)" + } + type Alias AuthInitFirebasePnvLoginRequest + return fmt.Sprintf("AuthInitFirebasePnvLoginRequest%+v", Alias(*i)) +} + +// FillFrom fills AuthInitFirebasePnvLoginRequest from given interface. +func (i *AuthInitFirebasePnvLoginRequest) FillFrom(from interface { + GetAPIID() (value int) + GetAPIHash() (value string) +}) { + i.APIID = from.GetAPIID() + i.APIHash = from.GetAPIHash() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AuthInitFirebasePnvLoginRequest) TypeID() uint32 { + return AuthInitFirebasePnvLoginRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*AuthInitFirebasePnvLoginRequest) TypeName() string { + return "auth.initFirebasePnvLogin" +} + +// TypeInfo returns info about TL type. +func (i *AuthInitFirebasePnvLoginRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "auth.initFirebasePnvLogin", + ID: AuthInitFirebasePnvLoginRequestTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "APIID", + SchemaName: "api_id", + }, + { + Name: "APIHash", + SchemaName: "api_hash", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (i *AuthInitFirebasePnvLoginRequest) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode auth.initFirebasePnvLogin#777df37a as nil") + } + b.PutID(AuthInitFirebasePnvLoginRequestTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *AuthInitFirebasePnvLoginRequest) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode auth.initFirebasePnvLogin#777df37a as nil") + } + b.PutInt(i.APIID) + b.PutString(i.APIHash) + return nil +} + +// Decode implements bin.Decoder. +func (i *AuthInitFirebasePnvLoginRequest) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode auth.initFirebasePnvLogin#777df37a to nil") + } + if err := b.ConsumeID(AuthInitFirebasePnvLoginRequestTypeID); err != nil { + return fmt.Errorf("unable to decode auth.initFirebasePnvLogin#777df37a: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *AuthInitFirebasePnvLoginRequest) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode auth.initFirebasePnvLogin#777df37a to nil") + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode auth.initFirebasePnvLogin#777df37a: field api_id: %w", err) + } + i.APIID = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode auth.initFirebasePnvLogin#777df37a: field api_hash: %w", err) + } + i.APIHash = value + } + return nil +} + +// GetAPIID returns value of APIID field. +func (i *AuthInitFirebasePnvLoginRequest) GetAPIID() (value int) { + if i == nil { + return + } + return i.APIID +} + +// GetAPIHash returns value of APIHash field. +func (i *AuthInitFirebasePnvLoginRequest) GetAPIHash() (value string) { + if i == nil { + return + } + return i.APIHash +} + +// AuthInitFirebasePnvLogin invokes method auth.initFirebasePnvLogin#777df37a returning error if any. +// +// See https://core.telegram.org/method/auth.initFirebasePnvLogin for reference. +func (c *Client) AuthInitFirebasePnvLogin(ctx context.Context, request *AuthInitFirebasePnvLoginRequest) (*AuthFirebasePnvIntent, error) { + var result AuthFirebasePnvIntent + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_auth_init_firebase_pnv_login_slices_gen.go b/tg/tl_auth_init_firebase_pnv_login_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_auth_init_firebase_pnv_login_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_bots_get_requested_web_view_button_gen.go b/tg/tl_bots_get_requested_web_view_button_gen.go index 9d87e81ce8..ef9b1398d2 100644 --- a/tg/tl_bots_get_requested_web_view_button_gen.go +++ b/tg/tl_bots_get_requested_web_view_button_gen.go @@ -195,11 +195,11 @@ func (g *BotsGetRequestedWebViewButtonRequest) GetWebappReqID() (value string) { // BotsGetRequestedWebViewButton invokes method bots.getRequestedWebViewButton#bf25b7f3 returning error if any. // // See https://core.telegram.org/method/bots.getRequestedWebViewButton for reference. -func (c *Client) BotsGetRequestedWebViewButton(ctx context.Context, request *BotsGetRequestedWebViewButtonRequest) (KeyboardButtonClass, error) { - var result KeyboardButtonBox +func (c *Client) BotsGetRequestedWebViewButton(ctx context.Context, request *BotsGetRequestedWebViewButtonRequest) (*KeyboardButton, error) { + var result KeyboardButton if err := c.rpc.Invoke(ctx, request, &result); err != nil { return nil, err } - return result.KeyboardButton, nil + return &result, nil } diff --git a/tg/tl_bots_request_web_view_button_gen.go b/tg/tl_bots_request_web_view_button_gen.go index bfc5adf622..b6a891667c 100644 --- a/tg/tl_bots_request_web_view_button_gen.go +++ b/tg/tl_bots_request_web_view_button_gen.go @@ -38,7 +38,7 @@ type BotsRequestWebViewButtonRequest struct { // UserID field of BotsRequestWebViewButtonRequest. UserID InputUserClass // Button field of BotsRequestWebViewButtonRequest. - Button KeyboardButtonClass + Button KeyboardButton } // BotsRequestWebViewButtonRequestTypeID is TL type id of BotsRequestWebViewButtonRequest. @@ -59,7 +59,7 @@ func (r *BotsRequestWebViewButtonRequest) Zero() bool { if !(r.UserID == nil) { return false } - if !(r.Button == nil) { + if !(r.Button.Zero()) { return false } @@ -78,7 +78,7 @@ func (r *BotsRequestWebViewButtonRequest) String() string { // FillFrom fills BotsRequestWebViewButtonRequest from given interface. func (r *BotsRequestWebViewButtonRequest) FillFrom(from interface { GetUserID() (value InputUserClass) - GetButton() (value KeyboardButtonClass) + GetButton() (value KeyboardButton) }) { r.UserID = from.GetUserID() r.Button = from.GetButton() @@ -139,9 +139,6 @@ func (r *BotsRequestWebViewButtonRequest) EncodeBare(b *bin.Buffer) error { if err := r.UserID.Encode(b); err != nil { return fmt.Errorf("unable to encode bots.requestWebViewButton#31a2a35e: field user_id: %w", err) } - if r.Button == nil { - return fmt.Errorf("unable to encode bots.requestWebViewButton#31a2a35e: field button is nil") - } if err := r.Button.Encode(b); err != nil { return fmt.Errorf("unable to encode bots.requestWebViewButton#31a2a35e: field button: %w", err) } @@ -172,11 +169,9 @@ func (r *BotsRequestWebViewButtonRequest) DecodeBare(b *bin.Buffer) error { r.UserID = value } { - value, err := DecodeKeyboardButton(b) - if err != nil { + if err := r.Button.Decode(b); err != nil { return fmt.Errorf("unable to decode bots.requestWebViewButton#31a2a35e: field button: %w", err) } - r.Button = value } return nil } @@ -190,7 +185,7 @@ func (r *BotsRequestWebViewButtonRequest) GetUserID() (value InputUserClass) { } // GetButton returns value of Button field. -func (r *BotsRequestWebViewButtonRequest) GetButton() (value KeyboardButtonClass) { +func (r *BotsRequestWebViewButtonRequest) GetButton() (value KeyboardButton) { if r == nil { return } diff --git a/tg/tl_button_type_gen.go b/tg/tl_button_type_gen.go new file mode 100644 index 0000000000..d62bd24a44 --- /dev/null +++ b/tg/tl_button_type_gen.go @@ -0,0 +1,1307 @@ +// 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{} +) + +// ButtonTypeDefault represents TL type `buttonTypeDefault#c9dd90e9`. +// +// See https://core.telegram.org/constructor/buttonTypeDefault for reference. +type ButtonTypeDefault struct { +} + +// ButtonTypeDefaultTypeID is TL type id of ButtonTypeDefault. +const ButtonTypeDefaultTypeID = 0xc9dd90e9 + +// construct implements constructor of ButtonTypeClass. +func (b ButtonTypeDefault) construct() ButtonTypeClass { return &b } + +// Ensuring interfaces in compile-time for ButtonTypeDefault. +var ( + _ bin.Encoder = &ButtonTypeDefault{} + _ bin.Decoder = &ButtonTypeDefault{} + _ bin.BareEncoder = &ButtonTypeDefault{} + _ bin.BareDecoder = &ButtonTypeDefault{} + + _ ButtonTypeClass = &ButtonTypeDefault{} +) + +func (b *ButtonTypeDefault) Zero() bool { + if b == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (b *ButtonTypeDefault) String() string { + if b == nil { + return "ButtonTypeDefault(nil)" + } + type Alias ButtonTypeDefault + return fmt.Sprintf("ButtonTypeDefault%+v", Alias(*b)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ButtonTypeDefault) TypeID() uint32 { + return ButtonTypeDefaultTypeID +} + +// TypeName returns name of type in TL schema. +func (*ButtonTypeDefault) TypeName() string { + return "buttonTypeDefault" +} + +// TypeInfo returns info about TL type. +func (b *ButtonTypeDefault) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "buttonTypeDefault", + ID: ButtonTypeDefaultTypeID, + } + if b == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (b *ButtonTypeDefault) Encode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode buttonTypeDefault#c9dd90e9 as nil") + } + buf.PutID(ButtonTypeDefaultTypeID) + return b.EncodeBare(buf) +} + +// EncodeBare implements bin.BareEncoder. +func (b *ButtonTypeDefault) EncodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode buttonTypeDefault#c9dd90e9 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (b *ButtonTypeDefault) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode buttonTypeDefault#c9dd90e9 to nil") + } + if err := buf.ConsumeID(ButtonTypeDefaultTypeID); err != nil { + return fmt.Errorf("unable to decode buttonTypeDefault#c9dd90e9: %w", err) + } + return b.DecodeBare(buf) +} + +// DecodeBare implements bin.BareDecoder. +func (b *ButtonTypeDefault) DecodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode buttonTypeDefault#c9dd90e9 to nil") + } + return nil +} + +// ButtonTypeRequestPhone represents TL type `buttonTypeRequestPhone#df3d36f9`. +// +// See https://core.telegram.org/constructor/buttonTypeRequestPhone for reference. +type ButtonTypeRequestPhone struct { +} + +// ButtonTypeRequestPhoneTypeID is TL type id of ButtonTypeRequestPhone. +const ButtonTypeRequestPhoneTypeID = 0xdf3d36f9 + +// construct implements constructor of ButtonTypeClass. +func (b ButtonTypeRequestPhone) construct() ButtonTypeClass { return &b } + +// Ensuring interfaces in compile-time for ButtonTypeRequestPhone. +var ( + _ bin.Encoder = &ButtonTypeRequestPhone{} + _ bin.Decoder = &ButtonTypeRequestPhone{} + _ bin.BareEncoder = &ButtonTypeRequestPhone{} + _ bin.BareDecoder = &ButtonTypeRequestPhone{} + + _ ButtonTypeClass = &ButtonTypeRequestPhone{} +) + +func (b *ButtonTypeRequestPhone) Zero() bool { + if b == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (b *ButtonTypeRequestPhone) String() string { + if b == nil { + return "ButtonTypeRequestPhone(nil)" + } + type Alias ButtonTypeRequestPhone + return fmt.Sprintf("ButtonTypeRequestPhone%+v", Alias(*b)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ButtonTypeRequestPhone) TypeID() uint32 { + return ButtonTypeRequestPhoneTypeID +} + +// TypeName returns name of type in TL schema. +func (*ButtonTypeRequestPhone) TypeName() string { + return "buttonTypeRequestPhone" +} + +// TypeInfo returns info about TL type. +func (b *ButtonTypeRequestPhone) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "buttonTypeRequestPhone", + ID: ButtonTypeRequestPhoneTypeID, + } + if b == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (b *ButtonTypeRequestPhone) Encode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode buttonTypeRequestPhone#df3d36f9 as nil") + } + buf.PutID(ButtonTypeRequestPhoneTypeID) + return b.EncodeBare(buf) +} + +// EncodeBare implements bin.BareEncoder. +func (b *ButtonTypeRequestPhone) EncodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode buttonTypeRequestPhone#df3d36f9 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (b *ButtonTypeRequestPhone) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode buttonTypeRequestPhone#df3d36f9 to nil") + } + if err := buf.ConsumeID(ButtonTypeRequestPhoneTypeID); err != nil { + return fmt.Errorf("unable to decode buttonTypeRequestPhone#df3d36f9: %w", err) + } + return b.DecodeBare(buf) +} + +// DecodeBare implements bin.BareDecoder. +func (b *ButtonTypeRequestPhone) DecodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode buttonTypeRequestPhone#df3d36f9 to nil") + } + return nil +} + +// ButtonTypeRequestGeoLocation represents TL type `buttonTypeRequestGeoLocation#9beee140`. +// +// See https://core.telegram.org/constructor/buttonTypeRequestGeoLocation for reference. +type ButtonTypeRequestGeoLocation struct { +} + +// ButtonTypeRequestGeoLocationTypeID is TL type id of ButtonTypeRequestGeoLocation. +const ButtonTypeRequestGeoLocationTypeID = 0x9beee140 + +// construct implements constructor of ButtonTypeClass. +func (b ButtonTypeRequestGeoLocation) construct() ButtonTypeClass { return &b } + +// Ensuring interfaces in compile-time for ButtonTypeRequestGeoLocation. +var ( + _ bin.Encoder = &ButtonTypeRequestGeoLocation{} + _ bin.Decoder = &ButtonTypeRequestGeoLocation{} + _ bin.BareEncoder = &ButtonTypeRequestGeoLocation{} + _ bin.BareDecoder = &ButtonTypeRequestGeoLocation{} + + _ ButtonTypeClass = &ButtonTypeRequestGeoLocation{} +) + +func (b *ButtonTypeRequestGeoLocation) Zero() bool { + if b == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (b *ButtonTypeRequestGeoLocation) String() string { + if b == nil { + return "ButtonTypeRequestGeoLocation(nil)" + } + type Alias ButtonTypeRequestGeoLocation + return fmt.Sprintf("ButtonTypeRequestGeoLocation%+v", Alias(*b)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ButtonTypeRequestGeoLocation) TypeID() uint32 { + return ButtonTypeRequestGeoLocationTypeID +} + +// TypeName returns name of type in TL schema. +func (*ButtonTypeRequestGeoLocation) TypeName() string { + return "buttonTypeRequestGeoLocation" +} + +// TypeInfo returns info about TL type. +func (b *ButtonTypeRequestGeoLocation) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "buttonTypeRequestGeoLocation", + ID: ButtonTypeRequestGeoLocationTypeID, + } + if b == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (b *ButtonTypeRequestGeoLocation) Encode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode buttonTypeRequestGeoLocation#9beee140 as nil") + } + buf.PutID(ButtonTypeRequestGeoLocationTypeID) + return b.EncodeBare(buf) +} + +// EncodeBare implements bin.BareEncoder. +func (b *ButtonTypeRequestGeoLocation) EncodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode buttonTypeRequestGeoLocation#9beee140 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (b *ButtonTypeRequestGeoLocation) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode buttonTypeRequestGeoLocation#9beee140 to nil") + } + if err := buf.ConsumeID(ButtonTypeRequestGeoLocationTypeID); err != nil { + return fmt.Errorf("unable to decode buttonTypeRequestGeoLocation#9beee140: %w", err) + } + return b.DecodeBare(buf) +} + +// DecodeBare implements bin.BareDecoder. +func (b *ButtonTypeRequestGeoLocation) DecodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode buttonTypeRequestGeoLocation#9beee140 to nil") + } + return nil +} + +// ButtonTypeRequestPoll represents TL type `buttonTypeRequestPoll#aacfff84`. +// +// See https://core.telegram.org/constructor/buttonTypeRequestPoll for reference. +type ButtonTypeRequestPoll struct { + // Flags field of ButtonTypeRequestPoll. + Flags bin.Fields + // Quiz field of ButtonTypeRequestPoll. + // + // Use SetQuiz and GetQuiz helpers. + Quiz bool +} + +// ButtonTypeRequestPollTypeID is TL type id of ButtonTypeRequestPoll. +const ButtonTypeRequestPollTypeID = 0xaacfff84 + +// construct implements constructor of ButtonTypeClass. +func (b ButtonTypeRequestPoll) construct() ButtonTypeClass { return &b } + +// Ensuring interfaces in compile-time for ButtonTypeRequestPoll. +var ( + _ bin.Encoder = &ButtonTypeRequestPoll{} + _ bin.Decoder = &ButtonTypeRequestPoll{} + _ bin.BareEncoder = &ButtonTypeRequestPoll{} + _ bin.BareDecoder = &ButtonTypeRequestPoll{} + + _ ButtonTypeClass = &ButtonTypeRequestPoll{} +) + +func (b *ButtonTypeRequestPoll) Zero() bool { + if b == nil { + return true + } + if !(b.Flags.Zero()) { + return false + } + if !(b.Quiz == false) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (b *ButtonTypeRequestPoll) String() string { + if b == nil { + return "ButtonTypeRequestPoll(nil)" + } + type Alias ButtonTypeRequestPoll + return fmt.Sprintf("ButtonTypeRequestPoll%+v", Alias(*b)) +} + +// FillFrom fills ButtonTypeRequestPoll from given interface. +func (b *ButtonTypeRequestPoll) FillFrom(from interface { + GetQuiz() (value bool, ok bool) +}) { + if val, ok := from.GetQuiz(); ok { + b.Quiz = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ButtonTypeRequestPoll) TypeID() uint32 { + return ButtonTypeRequestPollTypeID +} + +// TypeName returns name of type in TL schema. +func (*ButtonTypeRequestPoll) TypeName() string { + return "buttonTypeRequestPoll" +} + +// TypeInfo returns info about TL type. +func (b *ButtonTypeRequestPoll) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "buttonTypeRequestPoll", + ID: ButtonTypeRequestPollTypeID, + } + if b == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Quiz", + SchemaName: "quiz", + Null: !b.Flags.Has(0), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (b *ButtonTypeRequestPoll) SetFlags() { + if !(b.Quiz == false) { + b.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (b *ButtonTypeRequestPoll) Encode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode buttonTypeRequestPoll#aacfff84 as nil") + } + buf.PutID(ButtonTypeRequestPollTypeID) + return b.EncodeBare(buf) +} + +// EncodeBare implements bin.BareEncoder. +func (b *ButtonTypeRequestPoll) EncodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode buttonTypeRequestPoll#aacfff84 as nil") + } + b.SetFlags() + if err := b.Flags.Encode(buf); err != nil { + return fmt.Errorf("unable to encode buttonTypeRequestPoll#aacfff84: field flags: %w", err) + } + if b.Flags.Has(0) { + buf.PutBool(b.Quiz) + } + return nil +} + +// Decode implements bin.Decoder. +func (b *ButtonTypeRequestPoll) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode buttonTypeRequestPoll#aacfff84 to nil") + } + if err := buf.ConsumeID(ButtonTypeRequestPollTypeID); err != nil { + return fmt.Errorf("unable to decode buttonTypeRequestPoll#aacfff84: %w", err) + } + return b.DecodeBare(buf) +} + +// DecodeBare implements bin.BareDecoder. +func (b *ButtonTypeRequestPoll) DecodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode buttonTypeRequestPoll#aacfff84 to nil") + } + { + if err := b.Flags.Decode(buf); err != nil { + return fmt.Errorf("unable to decode buttonTypeRequestPoll#aacfff84: field flags: %w", err) + } + } + if b.Flags.Has(0) { + value, err := buf.Bool() + if err != nil { + return fmt.Errorf("unable to decode buttonTypeRequestPoll#aacfff84: field quiz: %w", err) + } + b.Quiz = value + } + return nil +} + +// SetQuiz sets value of Quiz conditional field. +func (b *ButtonTypeRequestPoll) SetQuiz(value bool) { + b.Flags.Set(0) + b.Quiz = value +} + +// GetQuiz returns value of Quiz conditional field and +// boolean which is true if field was set. +func (b *ButtonTypeRequestPoll) GetQuiz() (value bool, ok bool) { + if b == nil { + return + } + if !b.Flags.Has(0) { + return value, false + } + return b.Quiz, true +} + +// ButtonTypeRequestPeer represents TL type `buttonTypeRequestPeer#4f58a237`. +// +// See https://core.telegram.org/constructor/buttonTypeRequestPeer for reference. +type ButtonTypeRequestPeer struct { + // Flags field of ButtonTypeRequestPeer. + Flags bin.Fields + // ButtonID field of ButtonTypeRequestPeer. + ButtonID int + // PeerType field of ButtonTypeRequestPeer. + PeerType RequestPeerTypeClass + // MaxQuantity field of ButtonTypeRequestPeer. + MaxQuantity int +} + +// ButtonTypeRequestPeerTypeID is TL type id of ButtonTypeRequestPeer. +const ButtonTypeRequestPeerTypeID = 0x4f58a237 + +// construct implements constructor of ButtonTypeClass. +func (b ButtonTypeRequestPeer) construct() ButtonTypeClass { return &b } + +// Ensuring interfaces in compile-time for ButtonTypeRequestPeer. +var ( + _ bin.Encoder = &ButtonTypeRequestPeer{} + _ bin.Decoder = &ButtonTypeRequestPeer{} + _ bin.BareEncoder = &ButtonTypeRequestPeer{} + _ bin.BareDecoder = &ButtonTypeRequestPeer{} + + _ ButtonTypeClass = &ButtonTypeRequestPeer{} +) + +func (b *ButtonTypeRequestPeer) Zero() bool { + if b == nil { + return true + } + if !(b.Flags.Zero()) { + return false + } + if !(b.ButtonID == 0) { + return false + } + if !(b.PeerType == nil) { + return false + } + if !(b.MaxQuantity == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (b *ButtonTypeRequestPeer) String() string { + if b == nil { + return "ButtonTypeRequestPeer(nil)" + } + type Alias ButtonTypeRequestPeer + return fmt.Sprintf("ButtonTypeRequestPeer%+v", Alias(*b)) +} + +// FillFrom fills ButtonTypeRequestPeer from given interface. +func (b *ButtonTypeRequestPeer) FillFrom(from interface { + GetButtonID() (value int) + GetPeerType() (value RequestPeerTypeClass) + GetMaxQuantity() (value int) +}) { + b.ButtonID = from.GetButtonID() + b.PeerType = from.GetPeerType() + b.MaxQuantity = from.GetMaxQuantity() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ButtonTypeRequestPeer) TypeID() uint32 { + return ButtonTypeRequestPeerTypeID +} + +// TypeName returns name of type in TL schema. +func (*ButtonTypeRequestPeer) TypeName() string { + return "buttonTypeRequestPeer" +} + +// TypeInfo returns info about TL type. +func (b *ButtonTypeRequestPeer) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "buttonTypeRequestPeer", + ID: ButtonTypeRequestPeerTypeID, + } + if b == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ButtonID", + SchemaName: "button_id", + }, + { + Name: "PeerType", + SchemaName: "peer_type", + }, + { + Name: "MaxQuantity", + SchemaName: "max_quantity", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (b *ButtonTypeRequestPeer) SetFlags() { +} + +// Encode implements bin.Encoder. +func (b *ButtonTypeRequestPeer) Encode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode buttonTypeRequestPeer#4f58a237 as nil") + } + buf.PutID(ButtonTypeRequestPeerTypeID) + return b.EncodeBare(buf) +} + +// EncodeBare implements bin.BareEncoder. +func (b *ButtonTypeRequestPeer) EncodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode buttonTypeRequestPeer#4f58a237 as nil") + } + b.SetFlags() + if err := b.Flags.Encode(buf); err != nil { + return fmt.Errorf("unable to encode buttonTypeRequestPeer#4f58a237: field flags: %w", err) + } + buf.PutInt(b.ButtonID) + if b.PeerType == nil { + return fmt.Errorf("unable to encode buttonTypeRequestPeer#4f58a237: field peer_type is nil") + } + if err := b.PeerType.Encode(buf); err != nil { + return fmt.Errorf("unable to encode buttonTypeRequestPeer#4f58a237: field peer_type: %w", err) + } + buf.PutInt(b.MaxQuantity) + return nil +} + +// Decode implements bin.Decoder. +func (b *ButtonTypeRequestPeer) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode buttonTypeRequestPeer#4f58a237 to nil") + } + if err := buf.ConsumeID(ButtonTypeRequestPeerTypeID); err != nil { + return fmt.Errorf("unable to decode buttonTypeRequestPeer#4f58a237: %w", err) + } + return b.DecodeBare(buf) +} + +// DecodeBare implements bin.BareDecoder. +func (b *ButtonTypeRequestPeer) DecodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode buttonTypeRequestPeer#4f58a237 to nil") + } + { + if err := b.Flags.Decode(buf); err != nil { + return fmt.Errorf("unable to decode buttonTypeRequestPeer#4f58a237: field flags: %w", err) + } + } + { + value, err := buf.Int() + if err != nil { + return fmt.Errorf("unable to decode buttonTypeRequestPeer#4f58a237: field button_id: %w", err) + } + b.ButtonID = value + } + { + value, err := DecodeRequestPeerType(buf) + if err != nil { + return fmt.Errorf("unable to decode buttonTypeRequestPeer#4f58a237: field peer_type: %w", err) + } + b.PeerType = value + } + { + value, err := buf.Int() + if err != nil { + return fmt.Errorf("unable to decode buttonTypeRequestPeer#4f58a237: field max_quantity: %w", err) + } + b.MaxQuantity = value + } + return nil +} + +// GetButtonID returns value of ButtonID field. +func (b *ButtonTypeRequestPeer) GetButtonID() (value int) { + if b == nil { + return + } + return b.ButtonID +} + +// GetPeerType returns value of PeerType field. +func (b *ButtonTypeRequestPeer) GetPeerType() (value RequestPeerTypeClass) { + if b == nil { + return + } + return b.PeerType +} + +// GetMaxQuantity returns value of MaxQuantity field. +func (b *ButtonTypeRequestPeer) GetMaxQuantity() (value int) { + if b == nil { + return + } + return b.MaxQuantity +} + +// InputButtonTypeRequestPeer represents TL type `inputButtonTypeRequestPeer#3fe268fe`. +// +// See https://core.telegram.org/constructor/inputButtonTypeRequestPeer for reference. +type InputButtonTypeRequestPeer struct { + // Flags field of InputButtonTypeRequestPeer. + Flags bin.Fields + // NameRequested field of InputButtonTypeRequestPeer. + NameRequested bool + // UsernameRequested field of InputButtonTypeRequestPeer. + UsernameRequested bool + // PhotoRequested field of InputButtonTypeRequestPeer. + PhotoRequested bool + // ButtonID field of InputButtonTypeRequestPeer. + ButtonID int + // PeerType field of InputButtonTypeRequestPeer. + PeerType RequestPeerTypeClass + // MaxQuantity field of InputButtonTypeRequestPeer. + MaxQuantity int +} + +// InputButtonTypeRequestPeerTypeID is TL type id of InputButtonTypeRequestPeer. +const InputButtonTypeRequestPeerTypeID = 0x3fe268fe + +// construct implements constructor of ButtonTypeClass. +func (i InputButtonTypeRequestPeer) construct() ButtonTypeClass { return &i } + +// Ensuring interfaces in compile-time for InputButtonTypeRequestPeer. +var ( + _ bin.Encoder = &InputButtonTypeRequestPeer{} + _ bin.Decoder = &InputButtonTypeRequestPeer{} + _ bin.BareEncoder = &InputButtonTypeRequestPeer{} + _ bin.BareDecoder = &InputButtonTypeRequestPeer{} + + _ ButtonTypeClass = &InputButtonTypeRequestPeer{} +) + +func (i *InputButtonTypeRequestPeer) Zero() bool { + if i == nil { + return true + } + if !(i.Flags.Zero()) { + return false + } + if !(i.NameRequested == false) { + return false + } + if !(i.UsernameRequested == false) { + return false + } + if !(i.PhotoRequested == false) { + return false + } + if !(i.ButtonID == 0) { + return false + } + if !(i.PeerType == nil) { + return false + } + if !(i.MaxQuantity == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InputButtonTypeRequestPeer) String() string { + if i == nil { + return "InputButtonTypeRequestPeer(nil)" + } + type Alias InputButtonTypeRequestPeer + return fmt.Sprintf("InputButtonTypeRequestPeer%+v", Alias(*i)) +} + +// FillFrom fills InputButtonTypeRequestPeer from given interface. +func (i *InputButtonTypeRequestPeer) FillFrom(from interface { + GetNameRequested() (value bool) + GetUsernameRequested() (value bool) + GetPhotoRequested() (value bool) + GetButtonID() (value int) + GetPeerType() (value RequestPeerTypeClass) + GetMaxQuantity() (value int) +}) { + i.NameRequested = from.GetNameRequested() + i.UsernameRequested = from.GetUsernameRequested() + i.PhotoRequested = from.GetPhotoRequested() + i.ButtonID = from.GetButtonID() + i.PeerType = from.GetPeerType() + i.MaxQuantity = from.GetMaxQuantity() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InputButtonTypeRequestPeer) TypeID() uint32 { + return InputButtonTypeRequestPeerTypeID +} + +// TypeName returns name of type in TL schema. +func (*InputButtonTypeRequestPeer) TypeName() string { + return "inputButtonTypeRequestPeer" +} + +// TypeInfo returns info about TL type. +func (i *InputButtonTypeRequestPeer) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inputButtonTypeRequestPeer", + ID: InputButtonTypeRequestPeerTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "NameRequested", + SchemaName: "name_requested", + Null: !i.Flags.Has(0), + }, + { + Name: "UsernameRequested", + SchemaName: "username_requested", + Null: !i.Flags.Has(1), + }, + { + Name: "PhotoRequested", + SchemaName: "photo_requested", + Null: !i.Flags.Has(2), + }, + { + Name: "ButtonID", + SchemaName: "button_id", + }, + { + Name: "PeerType", + SchemaName: "peer_type", + }, + { + Name: "MaxQuantity", + SchemaName: "max_quantity", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (i *InputButtonTypeRequestPeer) SetFlags() { + if !(i.NameRequested == false) { + i.Flags.Set(0) + } + if !(i.UsernameRequested == false) { + i.Flags.Set(1) + } + if !(i.PhotoRequested == false) { + i.Flags.Set(2) + } +} + +// Encode implements bin.Encoder. +func (i *InputButtonTypeRequestPeer) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputButtonTypeRequestPeer#3fe268fe as nil") + } + b.PutID(InputButtonTypeRequestPeerTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InputButtonTypeRequestPeer) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputButtonTypeRequestPeer#3fe268fe as nil") + } + i.SetFlags() + if err := i.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputButtonTypeRequestPeer#3fe268fe: field flags: %w", err) + } + b.PutInt(i.ButtonID) + if i.PeerType == nil { + return fmt.Errorf("unable to encode inputButtonTypeRequestPeer#3fe268fe: field peer_type is nil") + } + if err := i.PeerType.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputButtonTypeRequestPeer#3fe268fe: field peer_type: %w", err) + } + b.PutInt(i.MaxQuantity) + return nil +} + +// Decode implements bin.Decoder. +func (i *InputButtonTypeRequestPeer) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputButtonTypeRequestPeer#3fe268fe to nil") + } + if err := b.ConsumeID(InputButtonTypeRequestPeerTypeID); err != nil { + return fmt.Errorf("unable to decode inputButtonTypeRequestPeer#3fe268fe: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InputButtonTypeRequestPeer) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputButtonTypeRequestPeer#3fe268fe to nil") + } + { + if err := i.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode inputButtonTypeRequestPeer#3fe268fe: field flags: %w", err) + } + } + i.NameRequested = i.Flags.Has(0) + i.UsernameRequested = i.Flags.Has(1) + i.PhotoRequested = i.Flags.Has(2) + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode inputButtonTypeRequestPeer#3fe268fe: field button_id: %w", err) + } + i.ButtonID = value + } + { + value, err := DecodeRequestPeerType(b) + if err != nil { + return fmt.Errorf("unable to decode inputButtonTypeRequestPeer#3fe268fe: field peer_type: %w", err) + } + i.PeerType = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode inputButtonTypeRequestPeer#3fe268fe: field max_quantity: %w", err) + } + i.MaxQuantity = value + } + return nil +} + +// SetNameRequested sets value of NameRequested conditional field. +func (i *InputButtonTypeRequestPeer) SetNameRequested(value bool) { + if value { + i.Flags.Set(0) + i.NameRequested = true + } else { + i.Flags.Unset(0) + i.NameRequested = false + } +} + +// GetNameRequested returns value of NameRequested conditional field. +func (i *InputButtonTypeRequestPeer) GetNameRequested() (value bool) { + if i == nil { + return + } + return i.Flags.Has(0) +} + +// SetUsernameRequested sets value of UsernameRequested conditional field. +func (i *InputButtonTypeRequestPeer) SetUsernameRequested(value bool) { + if value { + i.Flags.Set(1) + i.UsernameRequested = true + } else { + i.Flags.Unset(1) + i.UsernameRequested = false + } +} + +// GetUsernameRequested returns value of UsernameRequested conditional field. +func (i *InputButtonTypeRequestPeer) GetUsernameRequested() (value bool) { + if i == nil { + return + } + return i.Flags.Has(1) +} + +// SetPhotoRequested sets value of PhotoRequested conditional field. +func (i *InputButtonTypeRequestPeer) SetPhotoRequested(value bool) { + if value { + i.Flags.Set(2) + i.PhotoRequested = true + } else { + i.Flags.Unset(2) + i.PhotoRequested = false + } +} + +// GetPhotoRequested returns value of PhotoRequested conditional field. +func (i *InputButtonTypeRequestPeer) GetPhotoRequested() (value bool) { + if i == nil { + return + } + return i.Flags.Has(2) +} + +// GetButtonID returns value of ButtonID field. +func (i *InputButtonTypeRequestPeer) GetButtonID() (value int) { + if i == nil { + return + } + return i.ButtonID +} + +// GetPeerType returns value of PeerType field. +func (i *InputButtonTypeRequestPeer) GetPeerType() (value RequestPeerTypeClass) { + if i == nil { + return + } + return i.PeerType +} + +// GetMaxQuantity returns value of MaxQuantity field. +func (i *InputButtonTypeRequestPeer) GetMaxQuantity() (value int) { + if i == nil { + return + } + return i.MaxQuantity +} + +// ButtonTypeSimpleWebView represents TL type `buttonTypeSimpleWebView#c01a597a`. +// +// See https://core.telegram.org/constructor/buttonTypeSimpleWebView for reference. +type ButtonTypeSimpleWebView struct { + // URL field of ButtonTypeSimpleWebView. + URL string +} + +// ButtonTypeSimpleWebViewTypeID is TL type id of ButtonTypeSimpleWebView. +const ButtonTypeSimpleWebViewTypeID = 0xc01a597a + +// construct implements constructor of ButtonTypeClass. +func (b ButtonTypeSimpleWebView) construct() ButtonTypeClass { return &b } + +// Ensuring interfaces in compile-time for ButtonTypeSimpleWebView. +var ( + _ bin.Encoder = &ButtonTypeSimpleWebView{} + _ bin.Decoder = &ButtonTypeSimpleWebView{} + _ bin.BareEncoder = &ButtonTypeSimpleWebView{} + _ bin.BareDecoder = &ButtonTypeSimpleWebView{} + + _ ButtonTypeClass = &ButtonTypeSimpleWebView{} +) + +func (b *ButtonTypeSimpleWebView) Zero() bool { + if b == nil { + return true + } + if !(b.URL == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (b *ButtonTypeSimpleWebView) String() string { + if b == nil { + return "ButtonTypeSimpleWebView(nil)" + } + type Alias ButtonTypeSimpleWebView + return fmt.Sprintf("ButtonTypeSimpleWebView%+v", Alias(*b)) +} + +// FillFrom fills ButtonTypeSimpleWebView from given interface. +func (b *ButtonTypeSimpleWebView) FillFrom(from interface { + GetURL() (value string) +}) { + b.URL = from.GetURL() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ButtonTypeSimpleWebView) TypeID() uint32 { + return ButtonTypeSimpleWebViewTypeID +} + +// TypeName returns name of type in TL schema. +func (*ButtonTypeSimpleWebView) TypeName() string { + return "buttonTypeSimpleWebView" +} + +// TypeInfo returns info about TL type. +func (b *ButtonTypeSimpleWebView) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "buttonTypeSimpleWebView", + ID: ButtonTypeSimpleWebViewTypeID, + } + if b == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "URL", + SchemaName: "url", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (b *ButtonTypeSimpleWebView) Encode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode buttonTypeSimpleWebView#c01a597a as nil") + } + buf.PutID(ButtonTypeSimpleWebViewTypeID) + return b.EncodeBare(buf) +} + +// EncodeBare implements bin.BareEncoder. +func (b *ButtonTypeSimpleWebView) EncodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode buttonTypeSimpleWebView#c01a597a as nil") + } + buf.PutString(b.URL) + return nil +} + +// Decode implements bin.Decoder. +func (b *ButtonTypeSimpleWebView) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode buttonTypeSimpleWebView#c01a597a to nil") + } + if err := buf.ConsumeID(ButtonTypeSimpleWebViewTypeID); err != nil { + return fmt.Errorf("unable to decode buttonTypeSimpleWebView#c01a597a: %w", err) + } + return b.DecodeBare(buf) +} + +// DecodeBare implements bin.BareDecoder. +func (b *ButtonTypeSimpleWebView) DecodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode buttonTypeSimpleWebView#c01a597a to nil") + } + { + value, err := buf.String() + if err != nil { + return fmt.Errorf("unable to decode buttonTypeSimpleWebView#c01a597a: field url: %w", err) + } + b.URL = value + } + return nil +} + +// GetURL returns value of URL field. +func (b *ButtonTypeSimpleWebView) GetURL() (value string) { + if b == nil { + return + } + return b.URL +} + +// ButtonTypeClassName is schema name of ButtonTypeClass. +const ButtonTypeClassName = "ButtonType" + +// ButtonTypeClass represents ButtonType generic type. +// +// See https://core.telegram.org/type/ButtonType for reference. +// +// Constructors: +// - [ButtonTypeDefault] +// - [ButtonTypeRequestPhone] +// - [ButtonTypeRequestGeoLocation] +// - [ButtonTypeRequestPoll] +// - [ButtonTypeRequestPeer] +// - [InputButtonTypeRequestPeer] +// - [ButtonTypeSimpleWebView] +// +// Example: +// +// g, err := tg.DecodeButtonType(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.ButtonTypeDefault: // buttonTypeDefault#c9dd90e9 +// case *tg.ButtonTypeRequestPhone: // buttonTypeRequestPhone#df3d36f9 +// case *tg.ButtonTypeRequestGeoLocation: // buttonTypeRequestGeoLocation#9beee140 +// case *tg.ButtonTypeRequestPoll: // buttonTypeRequestPoll#aacfff84 +// case *tg.ButtonTypeRequestPeer: // buttonTypeRequestPeer#4f58a237 +// case *tg.InputButtonTypeRequestPeer: // inputButtonTypeRequestPeer#3fe268fe +// case *tg.ButtonTypeSimpleWebView: // buttonTypeSimpleWebView#c01a597a +// default: panic(v) +// } +type ButtonTypeClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() ButtonTypeClass + + // TypeID returns type id in TL schema. + // + // See https://core.telegram.org/mtproto/TL-tl#remarks. + TypeID() uint32 + // TypeName returns name of type in TL schema. + TypeName() string + // String implements fmt.Stringer. + String() string + // Zero returns true if current object has a zero value. + Zero() bool +} + +// DecodeButtonType implements binary de-serialization for ButtonTypeClass. +func DecodeButtonType(buf *bin.Buffer) (ButtonTypeClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case ButtonTypeDefaultTypeID: + // Decoding buttonTypeDefault#c9dd90e9. + v := ButtonTypeDefault{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ButtonTypeClass: %w", err) + } + return &v, nil + case ButtonTypeRequestPhoneTypeID: + // Decoding buttonTypeRequestPhone#df3d36f9. + v := ButtonTypeRequestPhone{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ButtonTypeClass: %w", err) + } + return &v, nil + case ButtonTypeRequestGeoLocationTypeID: + // Decoding buttonTypeRequestGeoLocation#9beee140. + v := ButtonTypeRequestGeoLocation{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ButtonTypeClass: %w", err) + } + return &v, nil + case ButtonTypeRequestPollTypeID: + // Decoding buttonTypeRequestPoll#aacfff84. + v := ButtonTypeRequestPoll{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ButtonTypeClass: %w", err) + } + return &v, nil + case ButtonTypeRequestPeerTypeID: + // Decoding buttonTypeRequestPeer#4f58a237. + v := ButtonTypeRequestPeer{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ButtonTypeClass: %w", err) + } + return &v, nil + case InputButtonTypeRequestPeerTypeID: + // Decoding inputButtonTypeRequestPeer#3fe268fe. + v := InputButtonTypeRequestPeer{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ButtonTypeClass: %w", err) + } + return &v, nil + case ButtonTypeSimpleWebViewTypeID: + // Decoding buttonTypeSimpleWebView#c01a597a. + v := ButtonTypeSimpleWebView{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode ButtonTypeClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode ButtonTypeClass: %w", bin.NewUnexpectedID(id)) + } +} + +// ButtonType boxes the ButtonTypeClass providing a helper. +type ButtonTypeBox struct { + ButtonType ButtonTypeClass +} + +// Decode implements bin.Decoder for ButtonTypeBox. +func (b *ButtonTypeBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode ButtonTypeBox to nil") + } + v, err := DecodeButtonType(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.ButtonType = v + return nil +} + +// Encode implements bin.Encode for ButtonTypeBox. +func (b *ButtonTypeBox) Encode(buf *bin.Buffer) error { + if b == nil || b.ButtonType == nil { + return fmt.Errorf("unable to encode ButtonTypeClass as nil") + } + return b.ButtonType.Encode(buf) +} diff --git a/tg/tl_button_type_slices_gen.go b/tg/tl_button_type_slices_gen.go new file mode 100644 index 0000000000..c9729f6db7 --- /dev/null +++ b/tg/tl_button_type_slices_gen.go @@ -0,0 +1,497 @@ +//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{} +) + +// ButtonTypeClassArray is adapter for slice of ButtonTypeClass. +type ButtonTypeClassArray []ButtonTypeClass + +// Sort sorts slice of ButtonTypeClass. +func (s ButtonTypeClassArray) Sort(less func(a, b ButtonTypeClass) bool) ButtonTypeClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ButtonTypeClass. +func (s ButtonTypeClassArray) SortStable(less func(a, b ButtonTypeClass) bool) ButtonTypeClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ButtonTypeClass. +func (s ButtonTypeClassArray) Retain(keep func(x ButtonTypeClass) bool) ButtonTypeClassArray { + 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 ButtonTypeClassArray) First() (v ButtonTypeClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ButtonTypeClassArray) Last() (v ButtonTypeClass, 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 *ButtonTypeClassArray) PopFirst() (v ButtonTypeClass, 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 ButtonTypeClass + 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 *ButtonTypeClassArray) Pop() (v ButtonTypeClass, 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 +} + +// AsButtonTypeRequestPoll returns copy with only ButtonTypeRequestPoll constructors. +func (s ButtonTypeClassArray) AsButtonTypeRequestPoll() (to ButtonTypeRequestPollArray) { + for _, elem := range s { + value, ok := elem.(*ButtonTypeRequestPoll) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsButtonTypeRequestPeer returns copy with only ButtonTypeRequestPeer constructors. +func (s ButtonTypeClassArray) AsButtonTypeRequestPeer() (to ButtonTypeRequestPeerArray) { + for _, elem := range s { + value, ok := elem.(*ButtonTypeRequestPeer) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsInputButtonTypeRequestPeer returns copy with only InputButtonTypeRequestPeer constructors. +func (s ButtonTypeClassArray) AsInputButtonTypeRequestPeer() (to InputButtonTypeRequestPeerArray) { + for _, elem := range s { + value, ok := elem.(*InputButtonTypeRequestPeer) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsButtonTypeSimpleWebView returns copy with only ButtonTypeSimpleWebView constructors. +func (s ButtonTypeClassArray) AsButtonTypeSimpleWebView() (to ButtonTypeSimpleWebViewArray) { + for _, elem := range s { + value, ok := elem.(*ButtonTypeSimpleWebView) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// ButtonTypeRequestPollArray is adapter for slice of ButtonTypeRequestPoll. +type ButtonTypeRequestPollArray []ButtonTypeRequestPoll + +// Sort sorts slice of ButtonTypeRequestPoll. +func (s ButtonTypeRequestPollArray) Sort(less func(a, b ButtonTypeRequestPoll) bool) ButtonTypeRequestPollArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ButtonTypeRequestPoll. +func (s ButtonTypeRequestPollArray) SortStable(less func(a, b ButtonTypeRequestPoll) bool) ButtonTypeRequestPollArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ButtonTypeRequestPoll. +func (s ButtonTypeRequestPollArray) Retain(keep func(x ButtonTypeRequestPoll) bool) ButtonTypeRequestPollArray { + 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 ButtonTypeRequestPollArray) First() (v ButtonTypeRequestPoll, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ButtonTypeRequestPollArray) Last() (v ButtonTypeRequestPoll, 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 *ButtonTypeRequestPollArray) PopFirst() (v ButtonTypeRequestPoll, 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 ButtonTypeRequestPoll + 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 *ButtonTypeRequestPollArray) Pop() (v ButtonTypeRequestPoll, 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 +} + +// ButtonTypeRequestPeerArray is adapter for slice of ButtonTypeRequestPeer. +type ButtonTypeRequestPeerArray []ButtonTypeRequestPeer + +// Sort sorts slice of ButtonTypeRequestPeer. +func (s ButtonTypeRequestPeerArray) Sort(less func(a, b ButtonTypeRequestPeer) bool) ButtonTypeRequestPeerArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ButtonTypeRequestPeer. +func (s ButtonTypeRequestPeerArray) SortStable(less func(a, b ButtonTypeRequestPeer) bool) ButtonTypeRequestPeerArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ButtonTypeRequestPeer. +func (s ButtonTypeRequestPeerArray) Retain(keep func(x ButtonTypeRequestPeer) bool) ButtonTypeRequestPeerArray { + 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 ButtonTypeRequestPeerArray) First() (v ButtonTypeRequestPeer, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ButtonTypeRequestPeerArray) Last() (v ButtonTypeRequestPeer, 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 *ButtonTypeRequestPeerArray) PopFirst() (v ButtonTypeRequestPeer, 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 ButtonTypeRequestPeer + 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 *ButtonTypeRequestPeerArray) Pop() (v ButtonTypeRequestPeer, 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 +} + +// InputButtonTypeRequestPeerArray is adapter for slice of InputButtonTypeRequestPeer. +type InputButtonTypeRequestPeerArray []InputButtonTypeRequestPeer + +// Sort sorts slice of InputButtonTypeRequestPeer. +func (s InputButtonTypeRequestPeerArray) Sort(less func(a, b InputButtonTypeRequestPeer) bool) InputButtonTypeRequestPeerArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of InputButtonTypeRequestPeer. +func (s InputButtonTypeRequestPeerArray) SortStable(less func(a, b InputButtonTypeRequestPeer) bool) InputButtonTypeRequestPeerArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of InputButtonTypeRequestPeer. +func (s InputButtonTypeRequestPeerArray) Retain(keep func(x InputButtonTypeRequestPeer) bool) InputButtonTypeRequestPeerArray { + 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 InputButtonTypeRequestPeerArray) First() (v InputButtonTypeRequestPeer, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s InputButtonTypeRequestPeerArray) Last() (v InputButtonTypeRequestPeer, 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 *InputButtonTypeRequestPeerArray) PopFirst() (v InputButtonTypeRequestPeer, 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 InputButtonTypeRequestPeer + 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 *InputButtonTypeRequestPeerArray) Pop() (v InputButtonTypeRequestPeer, 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 +} + +// ButtonTypeSimpleWebViewArray is adapter for slice of ButtonTypeSimpleWebView. +type ButtonTypeSimpleWebViewArray []ButtonTypeSimpleWebView + +// Sort sorts slice of ButtonTypeSimpleWebView. +func (s ButtonTypeSimpleWebViewArray) Sort(less func(a, b ButtonTypeSimpleWebView) bool) ButtonTypeSimpleWebViewArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of ButtonTypeSimpleWebView. +func (s ButtonTypeSimpleWebViewArray) SortStable(less func(a, b ButtonTypeSimpleWebView) bool) ButtonTypeSimpleWebViewArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of ButtonTypeSimpleWebView. +func (s ButtonTypeSimpleWebViewArray) Retain(keep func(x ButtonTypeSimpleWebView) bool) ButtonTypeSimpleWebViewArray { + 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 ButtonTypeSimpleWebViewArray) First() (v ButtonTypeSimpleWebView, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s ButtonTypeSimpleWebViewArray) Last() (v ButtonTypeSimpleWebView, 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 *ButtonTypeSimpleWebViewArray) PopFirst() (v ButtonTypeSimpleWebView, 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 ButtonTypeSimpleWebView + 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 *ButtonTypeSimpleWebViewArray) Pop() (v ButtonTypeSimpleWebView, 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_chat_admin_rights_gen.go b/tg/tl_chat_admin_rights_gen.go index c6ad22b46e..5cd0ab09c4 100644 --- a/tg/tl_chat_admin_rights_gen.go +++ b/tg/tl_chat_admin_rights_gen.go @@ -134,6 +134,8 @@ type ChatAdminRights struct { ManageRanks bool // ManageLinkedPeers field of ChatAdminRights. ManageLinkedPeers bool + // ManageWelcomeMessages field of ChatAdminRights. + ManageWelcomeMessages bool } // ChatAdminRightsTypeID is TL type id of ChatAdminRights. @@ -208,6 +210,9 @@ func (c *ChatAdminRights) Zero() bool { if !(c.ManageLinkedPeers == false) { return false } + if !(c.ManageWelcomeMessages == false) { + return false + } return true } @@ -241,6 +246,7 @@ func (c *ChatAdminRights) FillFrom(from interface { GetManageDirectMessages() (value bool) GetManageRanks() (value bool) GetManageLinkedPeers() (value bool) + GetManageWelcomeMessages() (value bool) }) { c.ChangeInfo = from.GetChangeInfo() c.PostMessages = from.GetPostMessages() @@ -260,6 +266,7 @@ func (c *ChatAdminRights) FillFrom(from interface { c.ManageDirectMessages = from.GetManageDirectMessages() c.ManageRanks = from.GetManageRanks() c.ManageLinkedPeers = from.GetManageLinkedPeers() + c.ManageWelcomeMessages = from.GetManageWelcomeMessages() } // TypeID returns type id in TL schema. @@ -375,6 +382,11 @@ func (c *ChatAdminRights) TypeInfo() tdp.Type { SchemaName: "manage_linked_peers", Null: !c.Flags.Has(19), }, + { + Name: "ManageWelcomeMessages", + SchemaName: "manage_welcome_messages", + Null: !c.Flags.Has(20), + }, } return typ } @@ -435,6 +447,9 @@ func (c *ChatAdminRights) SetFlags() { if !(c.ManageLinkedPeers == false) { c.Flags.Set(19) } + if !(c.ManageWelcomeMessages == false) { + c.Flags.Set(20) + } } // Encode implements bin.Encoder. @@ -497,6 +512,7 @@ func (c *ChatAdminRights) DecodeBare(b *bin.Buffer) error { c.ManageDirectMessages = c.Flags.Has(17) c.ManageRanks = c.Flags.Has(18) c.ManageLinkedPeers = c.Flags.Has(19) + c.ManageWelcomeMessages = c.Flags.Has(20) return nil } @@ -841,3 +857,22 @@ func (c *ChatAdminRights) GetManageLinkedPeers() (value bool) { } return c.Flags.Has(19) } + +// SetManageWelcomeMessages sets value of ManageWelcomeMessages conditional field. +func (c *ChatAdminRights) SetManageWelcomeMessages(value bool) { + if value { + c.Flags.Set(20) + c.ManageWelcomeMessages = true + } else { + c.Flags.Unset(20) + c.ManageWelcomeMessages = false + } +} + +// GetManageWelcomeMessages returns value of ManageWelcomeMessages conditional field. +func (c *ChatAdminRights) GetManageWelcomeMessages() (value bool) { + if c == nil { + return + } + return c.Flags.Has(20) +} diff --git a/tg/tl_chat_full_gen.go b/tg/tl_chat_full_gen.go index e7baf0744e..e274ef58e5 100644 --- a/tg/tl_chat_full_gen.go +++ b/tg/tl_chat_full_gen.go @@ -60,6 +60,8 @@ type ChatFull struct { // Links: // 1) https://core.telegram.org/api/translation TranslationsDisabled bool + // HasWelcomeMessages field of ChatFull. + HasWelcomeMessages bool // ID of the chat ID int64 // About string for this chat @@ -174,6 +176,9 @@ func (c *ChatFull) Zero() bool { if !(c.TranslationsDisabled == false) { return false } + if !(c.HasWelcomeMessages == false) { + return false + } if !(c.ID == 0) { return false } @@ -243,6 +248,7 @@ func (c *ChatFull) FillFrom(from interface { GetCanSetUsername() (value bool) GetHasScheduled() (value bool) GetTranslationsDisabled() (value bool) + GetHasWelcomeMessages() (value bool) GetID() (value int64) GetAbout() (value string) GetParticipants() (value ChatParticipantsClass) @@ -264,6 +270,7 @@ func (c *ChatFull) FillFrom(from interface { c.CanSetUsername = from.GetCanSetUsername() c.HasScheduled = from.GetHasScheduled() c.TranslationsDisabled = from.GetTranslationsDisabled() + c.HasWelcomeMessages = from.GetHasWelcomeMessages() c.ID = from.GetID() c.About = from.GetAbout() c.Participants = from.GetParticipants() @@ -360,6 +367,11 @@ func (c *ChatFull) TypeInfo() tdp.Type { SchemaName: "translations_disabled", Null: !c.Flags.Has(19), }, + { + Name: "HasWelcomeMessages", + SchemaName: "has_welcome_messages", + Null: !c.Flags.Has(21), + }, { Name: "ID", SchemaName: "id", @@ -456,6 +468,9 @@ func (c *ChatFull) SetFlags() { if !(c.TranslationsDisabled == false) { c.Flags.Set(19) } + if !(c.HasWelcomeMessages == false) { + c.Flags.Set(21) + } if !(c.ChatPhoto == nil) { c.Flags.Set(2) } @@ -625,6 +640,7 @@ func (c *ChatFull) DecodeBare(b *bin.Buffer) error { c.CanSetUsername = c.Flags.Has(7) c.HasScheduled = c.Flags.Has(8) c.TranslationsDisabled = c.Flags.Has(19) + c.HasWelcomeMessages = c.Flags.Has(21) { value, err := b.Long() if err != nil { @@ -822,6 +838,25 @@ func (c *ChatFull) GetTranslationsDisabled() (value bool) { return c.Flags.Has(19) } +// SetHasWelcomeMessages sets value of HasWelcomeMessages conditional field. +func (c *ChatFull) SetHasWelcomeMessages(value bool) { + if value { + c.Flags.Set(21) + c.HasWelcomeMessages = true + } else { + c.Flags.Unset(21) + c.HasWelcomeMessages = false + } +} + +// GetHasWelcomeMessages returns value of HasWelcomeMessages conditional field. +func (c *ChatFull) GetHasWelcomeMessages() (value bool) { + if c == nil { + return + } + return c.Flags.Has(21) +} + // GetID returns value of ID field. func (c *ChatFull) GetID() (value int64) { if c == nil { @@ -1204,6 +1239,8 @@ type ChannelFull struct { // Links: // 1) https://core.telegram.org/api/paid-messages PaidMessagesAvailable bool + // HasWelcomeMessages field of ChannelFull. + HasWelcomeMessages bool // ID of the channel ID int64 // Info about the channel @@ -1550,6 +1587,9 @@ func (c *ChannelFull) Zero() bool { if !(c.PaidMessagesAvailable == false) { return false } + if !(c.HasWelcomeMessages == false) { + return false + } if !(c.ID == 0) { return false } @@ -1724,6 +1764,7 @@ func (c *ChannelFull) FillFrom(from interface { GetPaidReactionsAvailable() (value bool) GetStargiftsAvailable() (value bool) GetPaidMessagesAvailable() (value bool) + GetHasWelcomeMessages() (value bool) GetID() (value int64) GetAbout() (value string) GetParticipantsCount() (value int, ok bool) @@ -1792,6 +1833,7 @@ func (c *ChannelFull) FillFrom(from interface { c.PaidReactionsAvailable = from.GetPaidReactionsAvailable() c.StargiftsAvailable = from.GetStargiftsAvailable() c.PaidMessagesAvailable = from.GetPaidMessagesAvailable() + c.HasWelcomeMessages = from.GetHasWelcomeMessages() c.ID = from.GetID() c.About = from.GetAbout() if val, ok := from.GetParticipantsCount(); ok { @@ -2079,6 +2121,11 @@ func (c *ChannelFull) TypeInfo() tdp.Type { SchemaName: "paid_messages_available", Null: !c.Flags2.Has(20), }, + { + Name: "HasWelcomeMessages", + SchemaName: "has_welcome_messages", + Null: !c.Flags2.Has(24), + }, { Name: "ID", SchemaName: "id", @@ -2369,6 +2416,9 @@ func (c *ChannelFull) SetFlags() { if !(c.PaidMessagesAvailable == false) { c.Flags2.Set(20) } + if !(c.HasWelcomeMessages == false) { + c.Flags2.Set(24) + } if !(c.ParticipantsCount == 0) { c.Flags.Set(0) } @@ -2739,6 +2789,7 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { c.PaidReactionsAvailable = c.Flags2.Has(16) c.StargiftsAvailable = c.Flags2.Has(19) c.PaidMessagesAvailable = c.Flags2.Has(20) + c.HasWelcomeMessages = c.Flags2.Has(24) { value, err := b.Long() if err != nil { @@ -3483,6 +3534,25 @@ func (c *ChannelFull) GetPaidMessagesAvailable() (value bool) { return c.Flags2.Has(20) } +// SetHasWelcomeMessages sets value of HasWelcomeMessages conditional field. +func (c *ChannelFull) SetHasWelcomeMessages(value bool) { + if value { + c.Flags2.Set(24) + c.HasWelcomeMessages = true + } else { + c.Flags2.Unset(24) + c.HasWelcomeMessages = false + } +} + +// GetHasWelcomeMessages returns value of HasWelcomeMessages conditional field. +func (c *ChannelFull) GetHasWelcomeMessages() (value bool) { + if c == nil { + return + } + return c.Flags2.Has(24) +} + // GetID returns value of ID field. func (c *ChannelFull) GetID() (value int64) { if c == nil { diff --git a/tg/tl_ephemeral_delete_all_welcome_messages_gen.go b/tg/tl_ephemeral_delete_all_welcome_messages_gen.go new file mode 100644 index 0000000000..9b4cbed273 --- /dev/null +++ b/tg/tl_ephemeral_delete_all_welcome_messages_gen.go @@ -0,0 +1,182 @@ +// 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{} +) + +// EphemeralDeleteAllWelcomeMessagesRequest represents TL type `ephemeral.deleteAllWelcomeMessages#734f9721`. +// +// See https://core.telegram.org/method/ephemeral.deleteAllWelcomeMessages for reference. +type EphemeralDeleteAllWelcomeMessagesRequest struct { + // Peer field of EphemeralDeleteAllWelcomeMessagesRequest. + Peer InputPeerClass +} + +// EphemeralDeleteAllWelcomeMessagesRequestTypeID is TL type id of EphemeralDeleteAllWelcomeMessagesRequest. +const EphemeralDeleteAllWelcomeMessagesRequestTypeID = 0x734f9721 + +// Ensuring interfaces in compile-time for EphemeralDeleteAllWelcomeMessagesRequest. +var ( + _ bin.Encoder = &EphemeralDeleteAllWelcomeMessagesRequest{} + _ bin.Decoder = &EphemeralDeleteAllWelcomeMessagesRequest{} + _ bin.BareEncoder = &EphemeralDeleteAllWelcomeMessagesRequest{} + _ bin.BareDecoder = &EphemeralDeleteAllWelcomeMessagesRequest{} +) + +func (d *EphemeralDeleteAllWelcomeMessagesRequest) Zero() bool { + if d == nil { + return true + } + if !(d.Peer == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (d *EphemeralDeleteAllWelcomeMessagesRequest) String() string { + if d == nil { + return "EphemeralDeleteAllWelcomeMessagesRequest(nil)" + } + type Alias EphemeralDeleteAllWelcomeMessagesRequest + return fmt.Sprintf("EphemeralDeleteAllWelcomeMessagesRequest%+v", Alias(*d)) +} + +// FillFrom fills EphemeralDeleteAllWelcomeMessagesRequest from given interface. +func (d *EphemeralDeleteAllWelcomeMessagesRequest) FillFrom(from interface { + GetPeer() (value InputPeerClass) +}) { + d.Peer = from.GetPeer() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*EphemeralDeleteAllWelcomeMessagesRequest) TypeID() uint32 { + return EphemeralDeleteAllWelcomeMessagesRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*EphemeralDeleteAllWelcomeMessagesRequest) TypeName() string { + return "ephemeral.deleteAllWelcomeMessages" +} + +// TypeInfo returns info about TL type. +func (d *EphemeralDeleteAllWelcomeMessagesRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "ephemeral.deleteAllWelcomeMessages", + ID: EphemeralDeleteAllWelcomeMessagesRequestTypeID, + } + if d == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Peer", + SchemaName: "peer", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (d *EphemeralDeleteAllWelcomeMessagesRequest) Encode(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't encode ephemeral.deleteAllWelcomeMessages#734f9721 as nil") + } + b.PutID(EphemeralDeleteAllWelcomeMessagesRequestTypeID) + return d.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (d *EphemeralDeleteAllWelcomeMessagesRequest) EncodeBare(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't encode ephemeral.deleteAllWelcomeMessages#734f9721 as nil") + } + if d.Peer == nil { + return fmt.Errorf("unable to encode ephemeral.deleteAllWelcomeMessages#734f9721: field peer is nil") + } + if err := d.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode ephemeral.deleteAllWelcomeMessages#734f9721: field peer: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (d *EphemeralDeleteAllWelcomeMessagesRequest) Decode(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't decode ephemeral.deleteAllWelcomeMessages#734f9721 to nil") + } + if err := b.ConsumeID(EphemeralDeleteAllWelcomeMessagesRequestTypeID); err != nil { + return fmt.Errorf("unable to decode ephemeral.deleteAllWelcomeMessages#734f9721: %w", err) + } + return d.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (d *EphemeralDeleteAllWelcomeMessagesRequest) DecodeBare(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't decode ephemeral.deleteAllWelcomeMessages#734f9721 to nil") + } + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode ephemeral.deleteAllWelcomeMessages#734f9721: field peer: %w", err) + } + d.Peer = value + } + return nil +} + +// GetPeer returns value of Peer field. +func (d *EphemeralDeleteAllWelcomeMessagesRequest) GetPeer() (value InputPeerClass) { + if d == nil { + return + } + return d.Peer +} + +// EphemeralDeleteAllWelcomeMessages invokes method ephemeral.deleteAllWelcomeMessages#734f9721 returning error if any. +// +// See https://core.telegram.org/method/ephemeral.deleteAllWelcomeMessages for reference. +func (c *Client) EphemeralDeleteAllWelcomeMessages(ctx context.Context, peer InputPeerClass) (bool, error) { + var result BoolBox + + request := &EphemeralDeleteAllWelcomeMessagesRequest{ + Peer: peer, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return false, err + } + _, ok := result.Bool.(*BoolTrue) + return ok, nil +} diff --git a/tg/tl_ephemeral_delete_all_welcome_messages_slices_gen.go b/tg/tl_ephemeral_delete_all_welcome_messages_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_ephemeral_delete_all_welcome_messages_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_ephemeral_delete_message_gen.go b/tg/tl_ephemeral_delete_message_gen.go index 57c24cc153..1a1fb8f22c 100644 --- a/tg/tl_ephemeral_delete_message_gen.go +++ b/tg/tl_ephemeral_delete_message_gen.go @@ -31,11 +31,15 @@ var ( _ = tdjson.Encoder{} ) -// EphemeralDeleteMessageRequest represents TL type `ephemeral.deleteMessage#a3c0d511`. +// EphemeralDeleteMessageRequest represents TL type `ephemeral.deleteMessage#92f6e797`. // // See https://core.telegram.org/method/ephemeral.deleteMessage for reference. type EphemeralDeleteMessageRequest struct { + // Flags field of EphemeralDeleteMessageRequest. + Flags bin.Fields // Peer field of EphemeralDeleteMessageRequest. + // + // Use SetPeer and GetPeer helpers. Peer InputPeerClass // ReceiverID field of EphemeralDeleteMessageRequest. ReceiverID InputUserClass @@ -44,7 +48,7 @@ type EphemeralDeleteMessageRequest struct { } // EphemeralDeleteMessageRequestTypeID is TL type id of EphemeralDeleteMessageRequest. -const EphemeralDeleteMessageRequestTypeID = 0xa3c0d511 +const EphemeralDeleteMessageRequestTypeID = 0x92f6e797 // Ensuring interfaces in compile-time for EphemeralDeleteMessageRequest. var ( @@ -58,6 +62,9 @@ func (d *EphemeralDeleteMessageRequest) Zero() bool { if d == nil { return true } + if !(d.Flags.Zero()) { + return false + } if !(d.Peer == nil) { return false } @@ -82,11 +89,14 @@ func (d *EphemeralDeleteMessageRequest) String() string { // FillFrom fills EphemeralDeleteMessageRequest from given interface. func (d *EphemeralDeleteMessageRequest) FillFrom(from interface { - GetPeer() (value InputPeerClass) + GetPeer() (value InputPeerClass, ok bool) GetReceiverID() (value InputUserClass) GetID() (value int) }) { - d.Peer = from.GetPeer() + if val, ok := from.GetPeer(); ok { + d.Peer = val + } + d.ReceiverID = from.GetReceiverID() d.ID = from.GetID() } @@ -117,6 +127,7 @@ func (d *EphemeralDeleteMessageRequest) TypeInfo() tdp.Type { { Name: "Peer", SchemaName: "peer", + Null: !d.Flags.Has(0), }, { Name: "ReceiverID", @@ -130,10 +141,17 @@ func (d *EphemeralDeleteMessageRequest) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (d *EphemeralDeleteMessageRequest) SetFlags() { + if !(d.Peer == nil) { + d.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (d *EphemeralDeleteMessageRequest) Encode(b *bin.Buffer) error { if d == nil { - return fmt.Errorf("can't encode ephemeral.deleteMessage#a3c0d511 as nil") + return fmt.Errorf("can't encode ephemeral.deleteMessage#92f6e797 as nil") } b.PutID(EphemeralDeleteMessageRequestTypeID) return d.EncodeBare(b) @@ -142,19 +160,25 @@ func (d *EphemeralDeleteMessageRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (d *EphemeralDeleteMessageRequest) EncodeBare(b *bin.Buffer) error { if d == nil { - return fmt.Errorf("can't encode ephemeral.deleteMessage#a3c0d511 as nil") + return fmt.Errorf("can't encode ephemeral.deleteMessage#92f6e797 as nil") } - if d.Peer == nil { - return fmt.Errorf("unable to encode ephemeral.deleteMessage#a3c0d511: field peer is nil") + d.SetFlags() + if err := d.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode ephemeral.deleteMessage#92f6e797: field flags: %w", err) } - if err := d.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode ephemeral.deleteMessage#a3c0d511: field peer: %w", err) + if d.Flags.Has(0) { + if d.Peer == nil { + return fmt.Errorf("unable to encode ephemeral.deleteMessage#92f6e797: field peer is nil") + } + if err := d.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode ephemeral.deleteMessage#92f6e797: field peer: %w", err) + } } if d.ReceiverID == nil { - return fmt.Errorf("unable to encode ephemeral.deleteMessage#a3c0d511: field receiver_id is nil") + return fmt.Errorf("unable to encode ephemeral.deleteMessage#92f6e797: field receiver_id is nil") } if err := d.ReceiverID.Encode(b); err != nil { - return fmt.Errorf("unable to encode ephemeral.deleteMessage#a3c0d511: field receiver_id: %w", err) + return fmt.Errorf("unable to encode ephemeral.deleteMessage#92f6e797: field receiver_id: %w", err) } b.PutInt(d.ID) return nil @@ -163,10 +187,10 @@ func (d *EphemeralDeleteMessageRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (d *EphemeralDeleteMessageRequest) Decode(b *bin.Buffer) error { if d == nil { - return fmt.Errorf("can't decode ephemeral.deleteMessage#a3c0d511 to nil") + return fmt.Errorf("can't decode ephemeral.deleteMessage#92f6e797 to nil") } if err := b.ConsumeID(EphemeralDeleteMessageRequestTypeID); err != nil { - return fmt.Errorf("unable to decode ephemeral.deleteMessage#a3c0d511: %w", err) + return fmt.Errorf("unable to decode ephemeral.deleteMessage#92f6e797: %w", err) } return d.DecodeBare(b) } @@ -174,38 +198,53 @@ func (d *EphemeralDeleteMessageRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (d *EphemeralDeleteMessageRequest) DecodeBare(b *bin.Buffer) error { if d == nil { - return fmt.Errorf("can't decode ephemeral.deleteMessage#a3c0d511 to nil") + return fmt.Errorf("can't decode ephemeral.deleteMessage#92f6e797 to nil") } { + if err := d.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode ephemeral.deleteMessage#92f6e797: field flags: %w", err) + } + } + if d.Flags.Has(0) { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode ephemeral.deleteMessage#a3c0d511: field peer: %w", err) + return fmt.Errorf("unable to decode ephemeral.deleteMessage#92f6e797: field peer: %w", err) } d.Peer = value } { value, err := DecodeInputUser(b) if err != nil { - return fmt.Errorf("unable to decode ephemeral.deleteMessage#a3c0d511: field receiver_id: %w", err) + return fmt.Errorf("unable to decode ephemeral.deleteMessage#92f6e797: field receiver_id: %w", err) } d.ReceiverID = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode ephemeral.deleteMessage#a3c0d511: field id: %w", err) + return fmt.Errorf("unable to decode ephemeral.deleteMessage#92f6e797: field id: %w", err) } d.ID = value } return nil } -// GetPeer returns value of Peer field. -func (d *EphemeralDeleteMessageRequest) GetPeer() (value InputPeerClass) { +// SetPeer sets value of Peer conditional field. +func (d *EphemeralDeleteMessageRequest) SetPeer(value InputPeerClass) { + d.Flags.Set(0) + d.Peer = value +} + +// GetPeer returns value of Peer conditional field and +// boolean which is true if field was set. +func (d *EphemeralDeleteMessageRequest) GetPeer() (value InputPeerClass, ok bool) { if d == nil { return } - return d.Peer + if !d.Flags.Has(0) { + return value, false + } + return d.Peer, true } // GetReceiverID returns value of ReceiverID field. @@ -224,7 +263,7 @@ func (d *EphemeralDeleteMessageRequest) GetID() (value int) { return d.ID } -// EphemeralDeleteMessage invokes method ephemeral.deleteMessage#a3c0d511 returning error if any. +// EphemeralDeleteMessage invokes method ephemeral.deleteMessage#92f6e797 returning error if any. // // See https://core.telegram.org/method/ephemeral.deleteMessage for reference. func (c *Client) EphemeralDeleteMessage(ctx context.Context, request *EphemeralDeleteMessageRequest) (bool, error) { diff --git a/tg/tl_ephemeral_delete_welcome_message_gen.go b/tg/tl_ephemeral_delete_welcome_message_gen.go new file mode 100644 index 0000000000..862dc452ca --- /dev/null +++ b/tg/tl_ephemeral_delete_welcome_message_gen.go @@ -0,0 +1,206 @@ +// 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{} +) + +// EphemeralDeleteWelcomeMessageRequest represents TL type `ephemeral.deleteWelcomeMessage#e882a9e1`. +// +// See https://core.telegram.org/method/ephemeral.deleteWelcomeMessage for reference. +type EphemeralDeleteWelcomeMessageRequest struct { + // Peer field of EphemeralDeleteWelcomeMessageRequest. + Peer InputPeerClass + // ID field of EphemeralDeleteWelcomeMessageRequest. + ID int +} + +// EphemeralDeleteWelcomeMessageRequestTypeID is TL type id of EphemeralDeleteWelcomeMessageRequest. +const EphemeralDeleteWelcomeMessageRequestTypeID = 0xe882a9e1 + +// Ensuring interfaces in compile-time for EphemeralDeleteWelcomeMessageRequest. +var ( + _ bin.Encoder = &EphemeralDeleteWelcomeMessageRequest{} + _ bin.Decoder = &EphemeralDeleteWelcomeMessageRequest{} + _ bin.BareEncoder = &EphemeralDeleteWelcomeMessageRequest{} + _ bin.BareDecoder = &EphemeralDeleteWelcomeMessageRequest{} +) + +func (d *EphemeralDeleteWelcomeMessageRequest) Zero() bool { + if d == nil { + return true + } + if !(d.Peer == nil) { + return false + } + if !(d.ID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (d *EphemeralDeleteWelcomeMessageRequest) String() string { + if d == nil { + return "EphemeralDeleteWelcomeMessageRequest(nil)" + } + type Alias EphemeralDeleteWelcomeMessageRequest + return fmt.Sprintf("EphemeralDeleteWelcomeMessageRequest%+v", Alias(*d)) +} + +// FillFrom fills EphemeralDeleteWelcomeMessageRequest from given interface. +func (d *EphemeralDeleteWelcomeMessageRequest) FillFrom(from interface { + GetPeer() (value InputPeerClass) + GetID() (value int) +}) { + d.Peer = from.GetPeer() + d.ID = from.GetID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*EphemeralDeleteWelcomeMessageRequest) TypeID() uint32 { + return EphemeralDeleteWelcomeMessageRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*EphemeralDeleteWelcomeMessageRequest) TypeName() string { + return "ephemeral.deleteWelcomeMessage" +} + +// TypeInfo returns info about TL type. +func (d *EphemeralDeleteWelcomeMessageRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "ephemeral.deleteWelcomeMessage", + ID: EphemeralDeleteWelcomeMessageRequestTypeID, + } + if d == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "ID", + SchemaName: "id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (d *EphemeralDeleteWelcomeMessageRequest) Encode(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't encode ephemeral.deleteWelcomeMessage#e882a9e1 as nil") + } + b.PutID(EphemeralDeleteWelcomeMessageRequestTypeID) + return d.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (d *EphemeralDeleteWelcomeMessageRequest) EncodeBare(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't encode ephemeral.deleteWelcomeMessage#e882a9e1 as nil") + } + if d.Peer == nil { + return fmt.Errorf("unable to encode ephemeral.deleteWelcomeMessage#e882a9e1: field peer is nil") + } + if err := d.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode ephemeral.deleteWelcomeMessage#e882a9e1: field peer: %w", err) + } + b.PutInt(d.ID) + return nil +} + +// Decode implements bin.Decoder. +func (d *EphemeralDeleteWelcomeMessageRequest) Decode(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't decode ephemeral.deleteWelcomeMessage#e882a9e1 to nil") + } + if err := b.ConsumeID(EphemeralDeleteWelcomeMessageRequestTypeID); err != nil { + return fmt.Errorf("unable to decode ephemeral.deleteWelcomeMessage#e882a9e1: %w", err) + } + return d.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (d *EphemeralDeleteWelcomeMessageRequest) DecodeBare(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't decode ephemeral.deleteWelcomeMessage#e882a9e1 to nil") + } + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode ephemeral.deleteWelcomeMessage#e882a9e1: field peer: %w", err) + } + d.Peer = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode ephemeral.deleteWelcomeMessage#e882a9e1: field id: %w", err) + } + d.ID = value + } + return nil +} + +// GetPeer returns value of Peer field. +func (d *EphemeralDeleteWelcomeMessageRequest) GetPeer() (value InputPeerClass) { + if d == nil { + return + } + return d.Peer +} + +// GetID returns value of ID field. +func (d *EphemeralDeleteWelcomeMessageRequest) GetID() (value int) { + if d == nil { + return + } + return d.ID +} + +// EphemeralDeleteWelcomeMessage invokes method ephemeral.deleteWelcomeMessage#e882a9e1 returning error if any. +// +// See https://core.telegram.org/method/ephemeral.deleteWelcomeMessage for reference. +func (c *Client) EphemeralDeleteWelcomeMessage(ctx context.Context, request *EphemeralDeleteWelcomeMessageRequest) (bool, error) { + var result BoolBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return false, err + } + _, ok := result.Bool.(*BoolTrue) + return ok, nil +} diff --git a/tg/tl_ephemeral_delete_welcome_message_slices_gen.go b/tg/tl_ephemeral_delete_welcome_message_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_ephemeral_delete_welcome_message_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_ephemeral_edit_message_gen.go b/tg/tl_ephemeral_edit_message_gen.go new file mode 100644 index 0000000000..211421059f --- /dev/null +++ b/tg/tl_ephemeral_edit_message_gen.go @@ -0,0 +1,627 @@ +// 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{} +) + +// EphemeralEditMessageRequest represents TL type `ephemeral.editMessage#cf9c725b`. +// +// See https://core.telegram.org/method/ephemeral.editMessage for reference. +type EphemeralEditMessageRequest struct { + // Flags field of EphemeralEditMessageRequest. + Flags bin.Fields + // InvertMedia field of EphemeralEditMessageRequest. + InvertMedia bool + // Welcome field of EphemeralEditMessageRequest. + Welcome bool + // Peer field of EphemeralEditMessageRequest. + // + // Use SetPeer and GetPeer helpers. + Peer InputPeerClass + // ReceiverID field of EphemeralEditMessageRequest. + ReceiverID InputUserClass + // ID field of EphemeralEditMessageRequest. + ID int + // Message field of EphemeralEditMessageRequest. + // + // Use SetMessage and GetMessage helpers. + Message string + // Media field of EphemeralEditMessageRequest. + // + // Use SetMedia and GetMedia helpers. + Media InputMediaClass + // Entities field of EphemeralEditMessageRequest. + // + // Use SetEntities and GetEntities helpers. + Entities []MessageEntityClass + // ReplyMarkup field of EphemeralEditMessageRequest. + // + // Use SetReplyMarkup and GetReplyMarkup helpers. + ReplyMarkup ReplyMarkupClass + // RichMessage field of EphemeralEditMessageRequest. + // + // Use SetRichMessage and GetRichMessage helpers. + RichMessage InputRichMessageClass +} + +// EphemeralEditMessageRequestTypeID is TL type id of EphemeralEditMessageRequest. +const EphemeralEditMessageRequestTypeID = 0xcf9c725b + +// Ensuring interfaces in compile-time for EphemeralEditMessageRequest. +var ( + _ bin.Encoder = &EphemeralEditMessageRequest{} + _ bin.Decoder = &EphemeralEditMessageRequest{} + _ bin.BareEncoder = &EphemeralEditMessageRequest{} + _ bin.BareDecoder = &EphemeralEditMessageRequest{} +) + +func (e *EphemeralEditMessageRequest) Zero() bool { + if e == nil { + return true + } + if !(e.Flags.Zero()) { + return false + } + if !(e.InvertMedia == false) { + return false + } + if !(e.Welcome == false) { + return false + } + if !(e.Peer == nil) { + return false + } + if !(e.ReceiverID == nil) { + return false + } + if !(e.ID == 0) { + return false + } + if !(e.Message == "") { + return false + } + if !(e.Media == nil) { + return false + } + if !(e.Entities == nil) { + return false + } + if !(e.ReplyMarkup == nil) { + return false + } + if !(e.RichMessage == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (e *EphemeralEditMessageRequest) String() string { + if e == nil { + return "EphemeralEditMessageRequest(nil)" + } + type Alias EphemeralEditMessageRequest + return fmt.Sprintf("EphemeralEditMessageRequest%+v", Alias(*e)) +} + +// FillFrom fills EphemeralEditMessageRequest from given interface. +func (e *EphemeralEditMessageRequest) FillFrom(from interface { + GetInvertMedia() (value bool) + GetWelcome() (value bool) + GetPeer() (value InputPeerClass, ok bool) + GetReceiverID() (value InputUserClass) + GetID() (value int) + GetMessage() (value string, ok bool) + GetMedia() (value InputMediaClass, ok bool) + GetEntities() (value []MessageEntityClass, ok bool) + GetReplyMarkup() (value ReplyMarkupClass, ok bool) + GetRichMessage() (value InputRichMessageClass, ok bool) +}) { + e.InvertMedia = from.GetInvertMedia() + e.Welcome = from.GetWelcome() + if val, ok := from.GetPeer(); ok { + e.Peer = val + } + + e.ReceiverID = from.GetReceiverID() + e.ID = from.GetID() + if val, ok := from.GetMessage(); ok { + e.Message = val + } + + if val, ok := from.GetMedia(); ok { + e.Media = val + } + + if val, ok := from.GetEntities(); ok { + e.Entities = val + } + + if val, ok := from.GetReplyMarkup(); ok { + e.ReplyMarkup = val + } + + if val, ok := from.GetRichMessage(); ok { + e.RichMessage = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*EphemeralEditMessageRequest) TypeID() uint32 { + return EphemeralEditMessageRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*EphemeralEditMessageRequest) TypeName() string { + return "ephemeral.editMessage" +} + +// TypeInfo returns info about TL type. +func (e *EphemeralEditMessageRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "ephemeral.editMessage", + ID: EphemeralEditMessageRequestTypeID, + } + if e == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "InvertMedia", + SchemaName: "invert_media", + Null: !e.Flags.Has(5), + }, + { + Name: "Welcome", + SchemaName: "welcome", + Null: !e.Flags.Has(6), + }, + { + Name: "Peer", + SchemaName: "peer", + Null: !e.Flags.Has(7), + }, + { + Name: "ReceiverID", + SchemaName: "receiver_id", + }, + { + Name: "ID", + SchemaName: "id", + }, + { + Name: "Message", + SchemaName: "message", + Null: !e.Flags.Has(0), + }, + { + Name: "Media", + SchemaName: "media", + Null: !e.Flags.Has(3), + }, + { + Name: "Entities", + SchemaName: "entities", + Null: !e.Flags.Has(1), + }, + { + Name: "ReplyMarkup", + SchemaName: "reply_markup", + Null: !e.Flags.Has(2), + }, + { + Name: "RichMessage", + SchemaName: "rich_message", + Null: !e.Flags.Has(4), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (e *EphemeralEditMessageRequest) SetFlags() { + if !(e.InvertMedia == false) { + e.Flags.Set(5) + } + if !(e.Welcome == false) { + e.Flags.Set(6) + } + if !(e.Peer == nil) { + e.Flags.Set(7) + } + if !(e.Message == "") { + e.Flags.Set(0) + } + if !(e.Media == nil) { + e.Flags.Set(3) + } + if !(e.Entities == nil) { + e.Flags.Set(1) + } + if !(e.ReplyMarkup == nil) { + e.Flags.Set(2) + } + if !(e.RichMessage == nil) { + e.Flags.Set(4) + } +} + +// Encode implements bin.Encoder. +func (e *EphemeralEditMessageRequest) Encode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode ephemeral.editMessage#cf9c725b as nil") + } + b.PutID(EphemeralEditMessageRequestTypeID) + return e.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (e *EphemeralEditMessageRequest) EncodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't encode ephemeral.editMessage#cf9c725b as nil") + } + e.SetFlags() + if err := e.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode ephemeral.editMessage#cf9c725b: field flags: %w", err) + } + if e.Flags.Has(7) { + if e.Peer == nil { + return fmt.Errorf("unable to encode ephemeral.editMessage#cf9c725b: field peer is nil") + } + if err := e.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode ephemeral.editMessage#cf9c725b: field peer: %w", err) + } + } + if e.ReceiverID == nil { + return fmt.Errorf("unable to encode ephemeral.editMessage#cf9c725b: field receiver_id is nil") + } + if err := e.ReceiverID.Encode(b); err != nil { + return fmt.Errorf("unable to encode ephemeral.editMessage#cf9c725b: field receiver_id: %w", err) + } + b.PutInt(e.ID) + if e.Flags.Has(0) { + b.PutString(e.Message) + } + if e.Flags.Has(3) { + if e.Media == nil { + return fmt.Errorf("unable to encode ephemeral.editMessage#cf9c725b: field media is nil") + } + if err := e.Media.Encode(b); err != nil { + return fmt.Errorf("unable to encode ephemeral.editMessage#cf9c725b: field media: %w", err) + } + } + if e.Flags.Has(1) { + b.PutVectorHeader(len(e.Entities)) + for idx, v := range e.Entities { + if v == nil { + return fmt.Errorf("unable to encode ephemeral.editMessage#cf9c725b: field entities element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode ephemeral.editMessage#cf9c725b: field entities element with index %d: %w", idx, err) + } + } + } + if e.Flags.Has(2) { + if e.ReplyMarkup == nil { + return fmt.Errorf("unable to encode ephemeral.editMessage#cf9c725b: field reply_markup is nil") + } + if err := e.ReplyMarkup.Encode(b); err != nil { + return fmt.Errorf("unable to encode ephemeral.editMessage#cf9c725b: field reply_markup: %w", err) + } + } + if e.Flags.Has(4) { + if e.RichMessage == nil { + return fmt.Errorf("unable to encode ephemeral.editMessage#cf9c725b: field rich_message is nil") + } + if err := e.RichMessage.Encode(b); err != nil { + return fmt.Errorf("unable to encode ephemeral.editMessage#cf9c725b: field rich_message: %w", err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (e *EphemeralEditMessageRequest) Decode(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode ephemeral.editMessage#cf9c725b to nil") + } + if err := b.ConsumeID(EphemeralEditMessageRequestTypeID); err != nil { + return fmt.Errorf("unable to decode ephemeral.editMessage#cf9c725b: %w", err) + } + return e.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (e *EphemeralEditMessageRequest) DecodeBare(b *bin.Buffer) error { + if e == nil { + return fmt.Errorf("can't decode ephemeral.editMessage#cf9c725b to nil") + } + { + if err := e.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode ephemeral.editMessage#cf9c725b: field flags: %w", err) + } + } + e.InvertMedia = e.Flags.Has(5) + e.Welcome = e.Flags.Has(6) + if e.Flags.Has(7) { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode ephemeral.editMessage#cf9c725b: field peer: %w", err) + } + e.Peer = value + } + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode ephemeral.editMessage#cf9c725b: field receiver_id: %w", err) + } + e.ReceiverID = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode ephemeral.editMessage#cf9c725b: field id: %w", err) + } + e.ID = value + } + if e.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode ephemeral.editMessage#cf9c725b: field message: %w", err) + } + e.Message = value + } + if e.Flags.Has(3) { + value, err := DecodeInputMedia(b) + if err != nil { + return fmt.Errorf("unable to decode ephemeral.editMessage#cf9c725b: field media: %w", err) + } + e.Media = value + } + if e.Flags.Has(1) { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode ephemeral.editMessage#cf9c725b: field entities: %w", err) + } + + if headerLen > 0 { + e.Entities = make([]MessageEntityClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeMessageEntity(b) + if err != nil { + return fmt.Errorf("unable to decode ephemeral.editMessage#cf9c725b: field entities: %w", err) + } + e.Entities = append(e.Entities, value) + } + } + if e.Flags.Has(2) { + value, err := DecodeReplyMarkup(b) + if err != nil { + return fmt.Errorf("unable to decode ephemeral.editMessage#cf9c725b: field reply_markup: %w", err) + } + e.ReplyMarkup = value + } + if e.Flags.Has(4) { + value, err := DecodeInputRichMessage(b) + if err != nil { + return fmt.Errorf("unable to decode ephemeral.editMessage#cf9c725b: field rich_message: %w", err) + } + e.RichMessage = value + } + return nil +} + +// SetInvertMedia sets value of InvertMedia conditional field. +func (e *EphemeralEditMessageRequest) SetInvertMedia(value bool) { + if value { + e.Flags.Set(5) + e.InvertMedia = true + } else { + e.Flags.Unset(5) + e.InvertMedia = false + } +} + +// GetInvertMedia returns value of InvertMedia conditional field. +func (e *EphemeralEditMessageRequest) GetInvertMedia() (value bool) { + if e == nil { + return + } + return e.Flags.Has(5) +} + +// SetWelcome sets value of Welcome conditional field. +func (e *EphemeralEditMessageRequest) SetWelcome(value bool) { + if value { + e.Flags.Set(6) + e.Welcome = true + } else { + e.Flags.Unset(6) + e.Welcome = false + } +} + +// GetWelcome returns value of Welcome conditional field. +func (e *EphemeralEditMessageRequest) GetWelcome() (value bool) { + if e == nil { + return + } + return e.Flags.Has(6) +} + +// SetPeer sets value of Peer conditional field. +func (e *EphemeralEditMessageRequest) SetPeer(value InputPeerClass) { + e.Flags.Set(7) + e.Peer = value +} + +// GetPeer returns value of Peer conditional field and +// boolean which is true if field was set. +func (e *EphemeralEditMessageRequest) GetPeer() (value InputPeerClass, ok bool) { + if e == nil { + return + } + if !e.Flags.Has(7) { + return value, false + } + return e.Peer, true +} + +// GetReceiverID returns value of ReceiverID field. +func (e *EphemeralEditMessageRequest) GetReceiverID() (value InputUserClass) { + if e == nil { + return + } + return e.ReceiverID +} + +// GetID returns value of ID field. +func (e *EphemeralEditMessageRequest) GetID() (value int) { + if e == nil { + return + } + return e.ID +} + +// SetMessage sets value of Message conditional field. +func (e *EphemeralEditMessageRequest) SetMessage(value string) { + e.Flags.Set(0) + e.Message = value +} + +// GetMessage returns value of Message conditional field and +// boolean which is true if field was set. +func (e *EphemeralEditMessageRequest) GetMessage() (value string, ok bool) { + if e == nil { + return + } + if !e.Flags.Has(0) { + return value, false + } + return e.Message, true +} + +// SetMedia sets value of Media conditional field. +func (e *EphemeralEditMessageRequest) SetMedia(value InputMediaClass) { + e.Flags.Set(3) + e.Media = value +} + +// GetMedia returns value of Media conditional field and +// boolean which is true if field was set. +func (e *EphemeralEditMessageRequest) GetMedia() (value InputMediaClass, ok bool) { + if e == nil { + return + } + if !e.Flags.Has(3) { + return value, false + } + return e.Media, true +} + +// SetEntities sets value of Entities conditional field. +func (e *EphemeralEditMessageRequest) SetEntities(value []MessageEntityClass) { + e.Flags.Set(1) + e.Entities = value +} + +// GetEntities returns value of Entities conditional field and +// boolean which is true if field was set. +func (e *EphemeralEditMessageRequest) GetEntities() (value []MessageEntityClass, ok bool) { + if e == nil { + return + } + if !e.Flags.Has(1) { + return value, false + } + return e.Entities, true +} + +// SetReplyMarkup sets value of ReplyMarkup conditional field. +func (e *EphemeralEditMessageRequest) SetReplyMarkup(value ReplyMarkupClass) { + e.Flags.Set(2) + e.ReplyMarkup = value +} + +// GetReplyMarkup returns value of ReplyMarkup conditional field and +// boolean which is true if field was set. +func (e *EphemeralEditMessageRequest) GetReplyMarkup() (value ReplyMarkupClass, ok bool) { + if e == nil { + return + } + if !e.Flags.Has(2) { + return value, false + } + return e.ReplyMarkup, true +} + +// SetRichMessage sets value of RichMessage conditional field. +func (e *EphemeralEditMessageRequest) SetRichMessage(value InputRichMessageClass) { + e.Flags.Set(4) + e.RichMessage = value +} + +// GetRichMessage returns value of RichMessage conditional field and +// boolean which is true if field was set. +func (e *EphemeralEditMessageRequest) GetRichMessage() (value InputRichMessageClass, ok bool) { + if e == nil { + return + } + if !e.Flags.Has(4) { + return value, false + } + return e.RichMessage, true +} + +// MapEntities returns field Entities wrapped in MessageEntityClassArray helper. +func (e *EphemeralEditMessageRequest) MapEntities() (value MessageEntityClassArray, ok bool) { + if !e.Flags.Has(1) { + return value, false + } + return MessageEntityClassArray(e.Entities), true +} + +// EphemeralEditMessage invokes method ephemeral.editMessage#cf9c725b returning error if any. +// +// See https://core.telegram.org/method/ephemeral.editMessage for reference. +func (c *Client) EphemeralEditMessage(ctx context.Context, request *EphemeralEditMessageRequest) (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_ephemeral_edit_message_slices_gen.go b/tg/tl_ephemeral_edit_message_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_ephemeral_edit_message_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_ephemeral_get_welcome_messages_gen.go b/tg/tl_ephemeral_get_welcome_messages_gen.go new file mode 100644 index 0000000000..092120cb95 --- /dev/null +++ b/tg/tl_ephemeral_get_welcome_messages_gen.go @@ -0,0 +1,205 @@ +// 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{} +) + +// EphemeralGetWelcomeMessagesRequest represents TL type `ephemeral.getWelcomeMessages#db9ac18d`. +// +// See https://core.telegram.org/method/ephemeral.getWelcomeMessages for reference. +type EphemeralGetWelcomeMessagesRequest struct { + // Peer field of EphemeralGetWelcomeMessagesRequest. + Peer InputPeerClass + // Hash field of EphemeralGetWelcomeMessagesRequest. + Hash int64 +} + +// EphemeralGetWelcomeMessagesRequestTypeID is TL type id of EphemeralGetWelcomeMessagesRequest. +const EphemeralGetWelcomeMessagesRequestTypeID = 0xdb9ac18d + +// Ensuring interfaces in compile-time for EphemeralGetWelcomeMessagesRequest. +var ( + _ bin.Encoder = &EphemeralGetWelcomeMessagesRequest{} + _ bin.Decoder = &EphemeralGetWelcomeMessagesRequest{} + _ bin.BareEncoder = &EphemeralGetWelcomeMessagesRequest{} + _ bin.BareDecoder = &EphemeralGetWelcomeMessagesRequest{} +) + +func (g *EphemeralGetWelcomeMessagesRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Peer == nil) { + return false + } + if !(g.Hash == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *EphemeralGetWelcomeMessagesRequest) String() string { + if g == nil { + return "EphemeralGetWelcomeMessagesRequest(nil)" + } + type Alias EphemeralGetWelcomeMessagesRequest + return fmt.Sprintf("EphemeralGetWelcomeMessagesRequest%+v", Alias(*g)) +} + +// FillFrom fills EphemeralGetWelcomeMessagesRequest from given interface. +func (g *EphemeralGetWelcomeMessagesRequest) FillFrom(from interface { + GetPeer() (value InputPeerClass) + GetHash() (value int64) +}) { + g.Peer = from.GetPeer() + g.Hash = from.GetHash() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*EphemeralGetWelcomeMessagesRequest) TypeID() uint32 { + return EphemeralGetWelcomeMessagesRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*EphemeralGetWelcomeMessagesRequest) TypeName() string { + return "ephemeral.getWelcomeMessages" +} + +// TypeInfo returns info about TL type. +func (g *EphemeralGetWelcomeMessagesRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "ephemeral.getWelcomeMessages", + ID: EphemeralGetWelcomeMessagesRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "Hash", + SchemaName: "hash", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *EphemeralGetWelcomeMessagesRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode ephemeral.getWelcomeMessages#db9ac18d as nil") + } + b.PutID(EphemeralGetWelcomeMessagesRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *EphemeralGetWelcomeMessagesRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode ephemeral.getWelcomeMessages#db9ac18d as nil") + } + if g.Peer == nil { + return fmt.Errorf("unable to encode ephemeral.getWelcomeMessages#db9ac18d: field peer is nil") + } + if err := g.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode ephemeral.getWelcomeMessages#db9ac18d: field peer: %w", err) + } + b.PutLong(g.Hash) + return nil +} + +// Decode implements bin.Decoder. +func (g *EphemeralGetWelcomeMessagesRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode ephemeral.getWelcomeMessages#db9ac18d to nil") + } + if err := b.ConsumeID(EphemeralGetWelcomeMessagesRequestTypeID); err != nil { + return fmt.Errorf("unable to decode ephemeral.getWelcomeMessages#db9ac18d: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *EphemeralGetWelcomeMessagesRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode ephemeral.getWelcomeMessages#db9ac18d to nil") + } + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode ephemeral.getWelcomeMessages#db9ac18d: field peer: %w", err) + } + g.Peer = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode ephemeral.getWelcomeMessages#db9ac18d: field hash: %w", err) + } + g.Hash = value + } + return nil +} + +// GetPeer returns value of Peer field. +func (g *EphemeralGetWelcomeMessagesRequest) GetPeer() (value InputPeerClass) { + if g == nil { + return + } + return g.Peer +} + +// GetHash returns value of Hash field. +func (g *EphemeralGetWelcomeMessagesRequest) GetHash() (value int64) { + if g == nil { + return + } + return g.Hash +} + +// EphemeralGetWelcomeMessages invokes method ephemeral.getWelcomeMessages#db9ac18d returning error if any. +// +// See https://core.telegram.org/method/ephemeral.getWelcomeMessages for reference. +func (c *Client) EphemeralGetWelcomeMessages(ctx context.Context, request *EphemeralGetWelcomeMessagesRequest) (EphemeralWelcomeMessagesClass, error) { + var result EphemeralWelcomeMessagesBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.WelcomeMessages, nil +} diff --git a/tg/tl_ephemeral_get_welcome_messages_slices_gen.go b/tg/tl_ephemeral_get_welcome_messages_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_ephemeral_get_welcome_messages_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_ephemeral_message_gen.go b/tg/tl_ephemeral_message_gen.go index 5bb87ed561..5c60786e6d 100644 --- a/tg/tl_ephemeral_message_gen.go +++ b/tg/tl_ephemeral_message_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// EphemeralMessage represents TL type `ephemeralMessage#d9c6dc1a`. +// EphemeralMessage represents TL type `ephemeralMessage#dd27bee9`. // // See https://core.telegram.org/constructor/ephemeralMessage for reference. type EphemeralMessage struct { @@ -39,11 +39,19 @@ type EphemeralMessage struct { Flags bin.Fields // Out field of EphemeralMessage. Out bool + // WelcomeTemplate field of EphemeralMessage. + WelcomeTemplate bool + // InvertMedia field of EphemeralMessage. + InvertMedia bool + // Noforwards field of EphemeralMessage. + Noforwards bool // ID field of EphemeralMessage. ID int // FromID field of EphemeralMessage. FromID PeerClass // PeerID field of EphemeralMessage. + // + // Use SetPeerID and GetPeerID helpers. PeerID PeerClass // ReceiverID field of EphemeralMessage. ReceiverID int64 @@ -71,10 +79,22 @@ type EphemeralMessage struct { // // Use SetReplyTo and GetReplyTo helpers. ReplyTo MessageReplyHeaderClass + // RichMessage field of EphemeralMessage. + // + // Use SetRichMessage and GetRichMessage helpers. + RichMessage RichMessage + // ChatInstance field of EphemeralMessage. + // + // Use SetChatInstance and GetChatInstance helpers. + ChatInstance int64 + // AnchorMsgID field of EphemeralMessage. + // + // Use SetAnchorMsgID and GetAnchorMsgID helpers. + AnchorMsgID int } // EphemeralMessageTypeID is TL type id of EphemeralMessage. -const EphemeralMessageTypeID = 0xd9c6dc1a +const EphemeralMessageTypeID = 0xdd27bee9 // Ensuring interfaces in compile-time for EphemeralMessage. var ( @@ -94,6 +114,15 @@ func (e *EphemeralMessage) Zero() bool { if !(e.Out == false) { return false } + if !(e.WelcomeTemplate == false) { + return false + } + if !(e.InvertMedia == false) { + return false + } + if !(e.Noforwards == false) { + return false + } if !(e.ID == 0) { return false } @@ -127,6 +156,15 @@ func (e *EphemeralMessage) Zero() bool { if !(e.ReplyTo == nil) { return false } + if !(e.RichMessage.Zero()) { + return false + } + if !(e.ChatInstance == 0) { + return false + } + if !(e.AnchorMsgID == 0) { + return false + } return true } @@ -143,9 +181,12 @@ func (e *EphemeralMessage) String() string { // FillFrom fills EphemeralMessage from given interface. func (e *EphemeralMessage) FillFrom(from interface { GetOut() (value bool) + GetWelcomeTemplate() (value bool) + GetInvertMedia() (value bool) + GetNoforwards() (value bool) GetID() (value int) GetFromID() (value PeerClass) - GetPeerID() (value PeerClass) + GetPeerID() (value PeerClass, ok bool) GetReceiverID() (value int64) GetTopMsgID() (value int, ok bool) GetDate() (value int) @@ -154,11 +195,20 @@ func (e *EphemeralMessage) FillFrom(from interface { GetMedia() (value MessageMediaClass, ok bool) GetReplyMarkup() (value ReplyMarkupClass, ok bool) GetReplyTo() (value MessageReplyHeaderClass, ok bool) + GetRichMessage() (value RichMessage, ok bool) + GetChatInstance() (value int64, ok bool) + GetAnchorMsgID() (value int, ok bool) }) { e.Out = from.GetOut() + e.WelcomeTemplate = from.GetWelcomeTemplate() + e.InvertMedia = from.GetInvertMedia() + e.Noforwards = from.GetNoforwards() e.ID = from.GetID() e.FromID = from.GetFromID() - e.PeerID = from.GetPeerID() + if val, ok := from.GetPeerID(); ok { + e.PeerID = val + } + e.ReceiverID = from.GetReceiverID() if val, ok := from.GetTopMsgID(); ok { e.TopMsgID = val @@ -182,6 +232,18 @@ func (e *EphemeralMessage) FillFrom(from interface { e.ReplyTo = val } + if val, ok := from.GetRichMessage(); ok { + e.RichMessage = val + } + + if val, ok := from.GetChatInstance(); ok { + e.ChatInstance = val + } + + if val, ok := from.GetAnchorMsgID(); ok { + e.AnchorMsgID = val + } + } // TypeID returns type id in TL schema. @@ -212,6 +274,21 @@ func (e *EphemeralMessage) TypeInfo() tdp.Type { SchemaName: "out", Null: !e.Flags.Has(0), }, + { + Name: "WelcomeTemplate", + SchemaName: "welcome_template", + Null: !e.Flags.Has(5), + }, + { + Name: "InvertMedia", + SchemaName: "invert_media", + Null: !e.Flags.Has(7), + }, + { + Name: "Noforwards", + SchemaName: "noforwards", + Null: !e.Flags.Has(12), + }, { Name: "ID", SchemaName: "id", @@ -223,6 +300,7 @@ func (e *EphemeralMessage) TypeInfo() tdp.Type { { Name: "PeerID", SchemaName: "peer_id", + Null: !e.Flags.Has(9), }, { Name: "ReceiverID", @@ -261,6 +339,21 @@ func (e *EphemeralMessage) TypeInfo() tdp.Type { SchemaName: "reply_to", Null: !e.Flags.Has(6), }, + { + Name: "RichMessage", + SchemaName: "rich_message", + Null: !e.Flags.Has(8), + }, + { + Name: "ChatInstance", + SchemaName: "chat_instance", + Null: !e.Flags.Has(10), + }, + { + Name: "AnchorMsgID", + SchemaName: "anchor_msg_id", + Null: !e.Flags.Has(11), + }, } return typ } @@ -270,6 +363,18 @@ func (e *EphemeralMessage) SetFlags() { if !(e.Out == false) { e.Flags.Set(0) } + if !(e.WelcomeTemplate == false) { + e.Flags.Set(5) + } + if !(e.InvertMedia == false) { + e.Flags.Set(7) + } + if !(e.Noforwards == false) { + e.Flags.Set(12) + } + if !(e.PeerID == nil) { + e.Flags.Set(9) + } if !(e.TopMsgID == 0) { e.Flags.Set(1) } @@ -285,12 +390,21 @@ func (e *EphemeralMessage) SetFlags() { if !(e.ReplyTo == nil) { e.Flags.Set(6) } + if !(e.RichMessage.Zero()) { + e.Flags.Set(8) + } + if !(e.ChatInstance == 0) { + e.Flags.Set(10) + } + if !(e.AnchorMsgID == 0) { + e.Flags.Set(11) + } } // Encode implements bin.Encoder. func (e *EphemeralMessage) Encode(b *bin.Buffer) error { if e == nil { - return fmt.Errorf("can't encode ephemeralMessage#d9c6dc1a as nil") + return fmt.Errorf("can't encode ephemeralMessage#dd27bee9 as nil") } b.PutID(EphemeralMessageTypeID) return e.EncodeBare(b) @@ -299,24 +413,26 @@ func (e *EphemeralMessage) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (e *EphemeralMessage) EncodeBare(b *bin.Buffer) error { if e == nil { - return fmt.Errorf("can't encode ephemeralMessage#d9c6dc1a as nil") + return fmt.Errorf("can't encode ephemeralMessage#dd27bee9 as nil") } e.SetFlags() if err := e.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode ephemeralMessage#d9c6dc1a: field flags: %w", err) + return fmt.Errorf("unable to encode ephemeralMessage#dd27bee9: field flags: %w", err) } b.PutInt(e.ID) if e.FromID == nil { - return fmt.Errorf("unable to encode ephemeralMessage#d9c6dc1a: field from_id is nil") + return fmt.Errorf("unable to encode ephemeralMessage#dd27bee9: field from_id is nil") } if err := e.FromID.Encode(b); err != nil { - return fmt.Errorf("unable to encode ephemeralMessage#d9c6dc1a: field from_id: %w", err) + return fmt.Errorf("unable to encode ephemeralMessage#dd27bee9: field from_id: %w", err) } - if e.PeerID == nil { - return fmt.Errorf("unable to encode ephemeralMessage#d9c6dc1a: field peer_id is nil") - } - if err := e.PeerID.Encode(b); err != nil { - return fmt.Errorf("unable to encode ephemeralMessage#d9c6dc1a: field peer_id: %w", err) + if e.Flags.Has(9) { + if e.PeerID == nil { + return fmt.Errorf("unable to encode ephemeralMessage#dd27bee9: field peer_id is nil") + } + if err := e.PeerID.Encode(b); err != nil { + return fmt.Errorf("unable to encode ephemeralMessage#dd27bee9: field peer_id: %w", err) + } } b.PutLong(e.ReceiverID) if e.Flags.Has(1) { @@ -328,47 +444,58 @@ func (e *EphemeralMessage) EncodeBare(b *bin.Buffer) error { b.PutVectorHeader(len(e.Entities)) for idx, v := range e.Entities { if v == nil { - return fmt.Errorf("unable to encode ephemeralMessage#d9c6dc1a: field entities element with index %d is nil", idx) + return fmt.Errorf("unable to encode ephemeralMessage#dd27bee9: field entities element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode ephemeralMessage#d9c6dc1a: field entities element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode ephemeralMessage#dd27bee9: field entities element with index %d: %w", idx, err) } } } if e.Flags.Has(3) { if e.Media == nil { - return fmt.Errorf("unable to encode ephemeralMessage#d9c6dc1a: field media is nil") + return fmt.Errorf("unable to encode ephemeralMessage#dd27bee9: field media is nil") } if err := e.Media.Encode(b); err != nil { - return fmt.Errorf("unable to encode ephemeralMessage#d9c6dc1a: field media: %w", err) + return fmt.Errorf("unable to encode ephemeralMessage#dd27bee9: field media: %w", err) } } if e.Flags.Has(4) { if e.ReplyMarkup == nil { - return fmt.Errorf("unable to encode ephemeralMessage#d9c6dc1a: field reply_markup is nil") + return fmt.Errorf("unable to encode ephemeralMessage#dd27bee9: field reply_markup is nil") } if err := e.ReplyMarkup.Encode(b); err != nil { - return fmt.Errorf("unable to encode ephemeralMessage#d9c6dc1a: field reply_markup: %w", err) + return fmt.Errorf("unable to encode ephemeralMessage#dd27bee9: field reply_markup: %w", err) } } if e.Flags.Has(6) { if e.ReplyTo == nil { - return fmt.Errorf("unable to encode ephemeralMessage#d9c6dc1a: field reply_to is nil") + return fmt.Errorf("unable to encode ephemeralMessage#dd27bee9: field reply_to is nil") } if err := e.ReplyTo.Encode(b); err != nil { - return fmt.Errorf("unable to encode ephemeralMessage#d9c6dc1a: field reply_to: %w", err) + return fmt.Errorf("unable to encode ephemeralMessage#dd27bee9: field reply_to: %w", err) + } + } + if e.Flags.Has(8) { + if err := e.RichMessage.Encode(b); err != nil { + return fmt.Errorf("unable to encode ephemeralMessage#dd27bee9: field rich_message: %w", err) } } + if e.Flags.Has(10) { + b.PutLong(e.ChatInstance) + } + if e.Flags.Has(11) { + b.PutInt(e.AnchorMsgID) + } return nil } // Decode implements bin.Decoder. func (e *EphemeralMessage) Decode(b *bin.Buffer) error { if e == nil { - return fmt.Errorf("can't decode ephemeralMessage#d9c6dc1a to nil") + return fmt.Errorf("can't decode ephemeralMessage#dd27bee9 to nil") } if err := b.ConsumeID(EphemeralMessageTypeID); err != nil { - return fmt.Errorf("unable to decode ephemeralMessage#d9c6dc1a: %w", err) + return fmt.Errorf("unable to decode ephemeralMessage#dd27bee9: %w", err) } return e.DecodeBare(b) } @@ -376,67 +503,70 @@ func (e *EphemeralMessage) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (e *EphemeralMessage) DecodeBare(b *bin.Buffer) error { if e == nil { - return fmt.Errorf("can't decode ephemeralMessage#d9c6dc1a to nil") + return fmt.Errorf("can't decode ephemeralMessage#dd27bee9 to nil") } { if err := e.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode ephemeralMessage#d9c6dc1a: field flags: %w", err) + return fmt.Errorf("unable to decode ephemeralMessage#dd27bee9: field flags: %w", err) } } e.Out = e.Flags.Has(0) + e.WelcomeTemplate = e.Flags.Has(5) + e.InvertMedia = e.Flags.Has(7) + e.Noforwards = e.Flags.Has(12) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode ephemeralMessage#d9c6dc1a: field id: %w", err) + return fmt.Errorf("unable to decode ephemeralMessage#dd27bee9: field id: %w", err) } e.ID = value } { value, err := DecodePeer(b) if err != nil { - return fmt.Errorf("unable to decode ephemeralMessage#d9c6dc1a: field from_id: %w", err) + return fmt.Errorf("unable to decode ephemeralMessage#dd27bee9: field from_id: %w", err) } e.FromID = value } - { + if e.Flags.Has(9) { value, err := DecodePeer(b) if err != nil { - return fmt.Errorf("unable to decode ephemeralMessage#d9c6dc1a: field peer_id: %w", err) + return fmt.Errorf("unable to decode ephemeralMessage#dd27bee9: field peer_id: %w", err) } e.PeerID = value } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode ephemeralMessage#d9c6dc1a: field receiver_id: %w", err) + return fmt.Errorf("unable to decode ephemeralMessage#dd27bee9: field receiver_id: %w", err) } e.ReceiverID = value } if e.Flags.Has(1) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode ephemeralMessage#d9c6dc1a: field top_msg_id: %w", err) + return fmt.Errorf("unable to decode ephemeralMessage#dd27bee9: field top_msg_id: %w", err) } e.TopMsgID = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode ephemeralMessage#d9c6dc1a: field date: %w", err) + return fmt.Errorf("unable to decode ephemeralMessage#dd27bee9: field date: %w", err) } e.Date = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode ephemeralMessage#d9c6dc1a: field message: %w", err) + return fmt.Errorf("unable to decode ephemeralMessage#dd27bee9: field message: %w", err) } e.Message = value } if e.Flags.Has(2) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode ephemeralMessage#d9c6dc1a: field entities: %w", err) + return fmt.Errorf("unable to decode ephemeralMessage#dd27bee9: field entities: %w", err) } if headerLen > 0 { @@ -445,7 +575,7 @@ func (e *EphemeralMessage) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeMessageEntity(b) if err != nil { - return fmt.Errorf("unable to decode ephemeralMessage#d9c6dc1a: field entities: %w", err) + return fmt.Errorf("unable to decode ephemeralMessage#dd27bee9: field entities: %w", err) } e.Entities = append(e.Entities, value) } @@ -453,24 +583,43 @@ func (e *EphemeralMessage) DecodeBare(b *bin.Buffer) error { if e.Flags.Has(3) { value, err := DecodeMessageMedia(b) if err != nil { - return fmt.Errorf("unable to decode ephemeralMessage#d9c6dc1a: field media: %w", err) + return fmt.Errorf("unable to decode ephemeralMessage#dd27bee9: field media: %w", err) } e.Media = value } if e.Flags.Has(4) { value, err := DecodeReplyMarkup(b) if err != nil { - return fmt.Errorf("unable to decode ephemeralMessage#d9c6dc1a: field reply_markup: %w", err) + return fmt.Errorf("unable to decode ephemeralMessage#dd27bee9: field reply_markup: %w", err) } e.ReplyMarkup = value } if e.Flags.Has(6) { value, err := DecodeMessageReplyHeader(b) if err != nil { - return fmt.Errorf("unable to decode ephemeralMessage#d9c6dc1a: field reply_to: %w", err) + return fmt.Errorf("unable to decode ephemeralMessage#dd27bee9: field reply_to: %w", err) } e.ReplyTo = value } + if e.Flags.Has(8) { + if err := e.RichMessage.Decode(b); err != nil { + return fmt.Errorf("unable to decode ephemeralMessage#dd27bee9: field rich_message: %w", err) + } + } + if e.Flags.Has(10) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode ephemeralMessage#dd27bee9: field chat_instance: %w", err) + } + e.ChatInstance = value + } + if e.Flags.Has(11) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode ephemeralMessage#dd27bee9: field anchor_msg_id: %w", err) + } + e.AnchorMsgID = value + } return nil } @@ -493,6 +642,63 @@ func (e *EphemeralMessage) GetOut() (value bool) { return e.Flags.Has(0) } +// SetWelcomeTemplate sets value of WelcomeTemplate conditional field. +func (e *EphemeralMessage) SetWelcomeTemplate(value bool) { + if value { + e.Flags.Set(5) + e.WelcomeTemplate = true + } else { + e.Flags.Unset(5) + e.WelcomeTemplate = false + } +} + +// GetWelcomeTemplate returns value of WelcomeTemplate conditional field. +func (e *EphemeralMessage) GetWelcomeTemplate() (value bool) { + if e == nil { + return + } + return e.Flags.Has(5) +} + +// SetInvertMedia sets value of InvertMedia conditional field. +func (e *EphemeralMessage) SetInvertMedia(value bool) { + if value { + e.Flags.Set(7) + e.InvertMedia = true + } else { + e.Flags.Unset(7) + e.InvertMedia = false + } +} + +// GetInvertMedia returns value of InvertMedia conditional field. +func (e *EphemeralMessage) GetInvertMedia() (value bool) { + if e == nil { + return + } + return e.Flags.Has(7) +} + +// SetNoforwards sets value of Noforwards conditional field. +func (e *EphemeralMessage) SetNoforwards(value bool) { + if value { + e.Flags.Set(12) + e.Noforwards = true + } else { + e.Flags.Unset(12) + e.Noforwards = false + } +} + +// GetNoforwards returns value of Noforwards conditional field. +func (e *EphemeralMessage) GetNoforwards() (value bool) { + if e == nil { + return + } + return e.Flags.Has(12) +} + // GetID returns value of ID field. func (e *EphemeralMessage) GetID() (value int) { if e == nil { @@ -509,12 +715,22 @@ func (e *EphemeralMessage) GetFromID() (value PeerClass) { return e.FromID } -// GetPeerID returns value of PeerID field. -func (e *EphemeralMessage) GetPeerID() (value PeerClass) { +// SetPeerID sets value of PeerID conditional field. +func (e *EphemeralMessage) SetPeerID(value PeerClass) { + e.Flags.Set(9) + e.PeerID = value +} + +// GetPeerID returns value of PeerID conditional field and +// boolean which is true if field was set. +func (e *EphemeralMessage) GetPeerID() (value PeerClass, ok bool) { if e == nil { return } - return e.PeerID + if !e.Flags.Has(9) { + return value, false + } + return e.PeerID, true } // GetReceiverID returns value of ReceiverID field. @@ -631,6 +847,60 @@ func (e *EphemeralMessage) GetReplyTo() (value MessageReplyHeaderClass, ok bool) return e.ReplyTo, true } +// SetRichMessage sets value of RichMessage conditional field. +func (e *EphemeralMessage) SetRichMessage(value RichMessage) { + e.Flags.Set(8) + e.RichMessage = value +} + +// GetRichMessage returns value of RichMessage conditional field and +// boolean which is true if field was set. +func (e *EphemeralMessage) GetRichMessage() (value RichMessage, ok bool) { + if e == nil { + return + } + if !e.Flags.Has(8) { + return value, false + } + return e.RichMessage, true +} + +// SetChatInstance sets value of ChatInstance conditional field. +func (e *EphemeralMessage) SetChatInstance(value int64) { + e.Flags.Set(10) + e.ChatInstance = value +} + +// GetChatInstance returns value of ChatInstance conditional field and +// boolean which is true if field was set. +func (e *EphemeralMessage) GetChatInstance() (value int64, ok bool) { + if e == nil { + return + } + if !e.Flags.Has(10) { + return value, false + } + return e.ChatInstance, true +} + +// SetAnchorMsgID sets value of AnchorMsgID conditional field. +func (e *EphemeralMessage) SetAnchorMsgID(value int) { + e.Flags.Set(11) + e.AnchorMsgID = value +} + +// GetAnchorMsgID returns value of AnchorMsgID conditional field and +// boolean which is true if field was set. +func (e *EphemeralMessage) GetAnchorMsgID() (value int, ok bool) { + if e == nil { + return + } + if !e.Flags.Has(11) { + return value, false + } + return e.AnchorMsgID, true +} + // MapEntities returns field Entities wrapped in MessageEntityClassArray helper. func (e *EphemeralMessage) MapEntities() (value MessageEntityClassArray, ok bool) { if !e.Flags.Has(2) { diff --git a/tg/tl_ephemeral_send_message_gen.go b/tg/tl_ephemeral_send_message_gen.go index ab2a3c594b..5ce1f3ba44 100644 --- a/tg/tl_ephemeral_send_message_gen.go +++ b/tg/tl_ephemeral_send_message_gen.go @@ -31,13 +31,23 @@ var ( _ = tdjson.Encoder{} ) -// EphemeralSendMessageRequest represents TL type `ephemeral.sendMessage#68cbd09f`. +// EphemeralSendMessageRequest represents TL type `ephemeral.sendMessage#ba8d5f35`. // // See https://core.telegram.org/method/ephemeral.sendMessage for reference. type EphemeralSendMessageRequest struct { // Flags field of EphemeralSendMessageRequest. Flags bin.Fields + // InvertMedia field of EphemeralSendMessageRequest. + InvertMedia bool + // Welcome field of EphemeralSendMessageRequest. + Welcome bool + // Anchor field of EphemeralSendMessageRequest. + Anchor bool + // Noforwards field of EphemeralSendMessageRequest. + Noforwards bool // Peer field of EphemeralSendMessageRequest. + // + // Use SetPeer and GetPeer helpers. Peer InputPeerClass // ReceiverID field of EphemeralSendMessageRequest. ReceiverID InputUserClass @@ -72,7 +82,7 @@ type EphemeralSendMessageRequest struct { } // EphemeralSendMessageRequestTypeID is TL type id of EphemeralSendMessageRequest. -const EphemeralSendMessageRequestTypeID = 0x68cbd09f +const EphemeralSendMessageRequestTypeID = 0xba8d5f35 // Ensuring interfaces in compile-time for EphemeralSendMessageRequest. var ( @@ -89,6 +99,18 @@ func (s *EphemeralSendMessageRequest) Zero() bool { if !(s.Flags.Zero()) { return false } + if !(s.InvertMedia == false) { + return false + } + if !(s.Welcome == false) { + return false + } + if !(s.Anchor == false) { + return false + } + if !(s.Noforwards == false) { + return false + } if !(s.Peer == nil) { return false } @@ -134,7 +156,11 @@ func (s *EphemeralSendMessageRequest) String() string { // FillFrom fills EphemeralSendMessageRequest from given interface. func (s *EphemeralSendMessageRequest) FillFrom(from interface { - GetPeer() (value InputPeerClass) + GetInvertMedia() (value bool) + GetWelcome() (value bool) + GetAnchor() (value bool) + GetNoforwards() (value bool) + GetPeer() (value InputPeerClass, ok bool) GetReceiverID() (value InputUserClass) GetQueryID() (value int64, ok bool) GetMessage() (value string) @@ -145,7 +171,14 @@ func (s *EphemeralSendMessageRequest) FillFrom(from interface { GetRandomID() (value int64) GetReplyTo() (value InputReplyToClass, ok bool) }) { - s.Peer = from.GetPeer() + s.InvertMedia = from.GetInvertMedia() + s.Welcome = from.GetWelcome() + s.Anchor = from.GetAnchor() + s.Noforwards = from.GetNoforwards() + if val, ok := from.GetPeer(); ok { + s.Peer = val + } + s.ReceiverID = from.GetReceiverID() if val, ok := from.GetQueryID(); ok { s.QueryID = val @@ -198,9 +231,30 @@ func (s *EphemeralSendMessageRequest) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "InvertMedia", + SchemaName: "invert_media", + Null: !s.Flags.Has(6), + }, + { + Name: "Welcome", + SchemaName: "welcome", + Null: !s.Flags.Has(7), + }, + { + Name: "Anchor", + SchemaName: "anchor", + Null: !s.Flags.Has(9), + }, + { + Name: "Noforwards", + SchemaName: "noforwards", + Null: !s.Flags.Has(10), + }, { Name: "Peer", SchemaName: "peer", + Null: !s.Flags.Has(8), }, { Name: "ReceiverID", @@ -250,6 +304,21 @@ func (s *EphemeralSendMessageRequest) TypeInfo() tdp.Type { // SetFlags sets flags for non-zero fields. func (s *EphemeralSendMessageRequest) SetFlags() { + if !(s.InvertMedia == false) { + s.Flags.Set(6) + } + if !(s.Welcome == false) { + s.Flags.Set(7) + } + if !(s.Anchor == false) { + s.Flags.Set(9) + } + if !(s.Noforwards == false) { + s.Flags.Set(10) + } + if !(s.Peer == nil) { + s.Flags.Set(8) + } if !(s.QueryID == 0) { s.Flags.Set(0) } @@ -273,7 +342,7 @@ func (s *EphemeralSendMessageRequest) SetFlags() { // Encode implements bin.Encoder. func (s *EphemeralSendMessageRequest) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode ephemeral.sendMessage#68cbd09f as nil") + return fmt.Errorf("can't encode ephemeral.sendMessage#ba8d5f35 as nil") } b.PutID(EphemeralSendMessageRequestTypeID) return s.EncodeBare(b) @@ -282,23 +351,25 @@ func (s *EphemeralSendMessageRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *EphemeralSendMessageRequest) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode ephemeral.sendMessage#68cbd09f as nil") + return fmt.Errorf("can't encode ephemeral.sendMessage#ba8d5f35 as nil") } s.SetFlags() if err := s.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode ephemeral.sendMessage#68cbd09f: field flags: %w", err) + return fmt.Errorf("unable to encode ephemeral.sendMessage#ba8d5f35: field flags: %w", err) } - if s.Peer == nil { - return fmt.Errorf("unable to encode ephemeral.sendMessage#68cbd09f: field peer is nil") - } - if err := s.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode ephemeral.sendMessage#68cbd09f: field peer: %w", err) + if s.Flags.Has(8) { + if s.Peer == nil { + return fmt.Errorf("unable to encode ephemeral.sendMessage#ba8d5f35: field peer is nil") + } + if err := s.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode ephemeral.sendMessage#ba8d5f35: field peer: %w", err) + } } if s.ReceiverID == nil { - return fmt.Errorf("unable to encode ephemeral.sendMessage#68cbd09f: field receiver_id is nil") + return fmt.Errorf("unable to encode ephemeral.sendMessage#ba8d5f35: field receiver_id is nil") } if err := s.ReceiverID.Encode(b); err != nil { - return fmt.Errorf("unable to encode ephemeral.sendMessage#68cbd09f: field receiver_id: %w", err) + return fmt.Errorf("unable to encode ephemeral.sendMessage#ba8d5f35: field receiver_id: %w", err) } if s.Flags.Has(0) { b.PutLong(s.QueryID) @@ -308,44 +379,44 @@ func (s *EphemeralSendMessageRequest) EncodeBare(b *bin.Buffer) error { b.PutVectorHeader(len(s.Entities)) for idx, v := range s.Entities { if v == nil { - return fmt.Errorf("unable to encode ephemeral.sendMessage#68cbd09f: field entities element with index %d is nil", idx) + return fmt.Errorf("unable to encode ephemeral.sendMessage#ba8d5f35: field entities element with index %d is nil", idx) } if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode ephemeral.sendMessage#68cbd09f: field entities element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode ephemeral.sendMessage#ba8d5f35: field entities element with index %d: %w", idx, err) } } } if s.Flags.Has(2) { if s.Media == nil { - return fmt.Errorf("unable to encode ephemeral.sendMessage#68cbd09f: field media is nil") + return fmt.Errorf("unable to encode ephemeral.sendMessage#ba8d5f35: field media is nil") } if err := s.Media.Encode(b); err != nil { - return fmt.Errorf("unable to encode ephemeral.sendMessage#68cbd09f: field media: %w", err) + return fmt.Errorf("unable to encode ephemeral.sendMessage#ba8d5f35: field media: %w", err) } } if s.Flags.Has(3) { if s.ReplyMarkup == nil { - return fmt.Errorf("unable to encode ephemeral.sendMessage#68cbd09f: field reply_markup is nil") + return fmt.Errorf("unable to encode ephemeral.sendMessage#ba8d5f35: field reply_markup is nil") } if err := s.ReplyMarkup.Encode(b); err != nil { - return fmt.Errorf("unable to encode ephemeral.sendMessage#68cbd09f: field reply_markup: %w", err) + return fmt.Errorf("unable to encode ephemeral.sendMessage#ba8d5f35: field reply_markup: %w", err) } } if s.Flags.Has(4) { if s.RichMessage == nil { - return fmt.Errorf("unable to encode ephemeral.sendMessage#68cbd09f: field rich_message is nil") + return fmt.Errorf("unable to encode ephemeral.sendMessage#ba8d5f35: field rich_message is nil") } if err := s.RichMessage.Encode(b); err != nil { - return fmt.Errorf("unable to encode ephemeral.sendMessage#68cbd09f: field rich_message: %w", err) + return fmt.Errorf("unable to encode ephemeral.sendMessage#ba8d5f35: field rich_message: %w", err) } } b.PutLong(s.RandomID) if s.Flags.Has(5) { if s.ReplyTo == nil { - return fmt.Errorf("unable to encode ephemeral.sendMessage#68cbd09f: field reply_to is nil") + return fmt.Errorf("unable to encode ephemeral.sendMessage#ba8d5f35: field reply_to is nil") } if err := s.ReplyTo.Encode(b); err != nil { - return fmt.Errorf("unable to encode ephemeral.sendMessage#68cbd09f: field reply_to: %w", err) + return fmt.Errorf("unable to encode ephemeral.sendMessage#ba8d5f35: field reply_to: %w", err) } } return nil @@ -354,10 +425,10 @@ func (s *EphemeralSendMessageRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *EphemeralSendMessageRequest) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode ephemeral.sendMessage#68cbd09f to nil") + return fmt.Errorf("can't decode ephemeral.sendMessage#ba8d5f35 to nil") } if err := b.ConsumeID(EphemeralSendMessageRequestTypeID); err != nil { - return fmt.Errorf("unable to decode ephemeral.sendMessage#68cbd09f: %w", err) + return fmt.Errorf("unable to decode ephemeral.sendMessage#ba8d5f35: %w", err) } return s.DecodeBare(b) } @@ -365,45 +436,49 @@ func (s *EphemeralSendMessageRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *EphemeralSendMessageRequest) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode ephemeral.sendMessage#68cbd09f to nil") + return fmt.Errorf("can't decode ephemeral.sendMessage#ba8d5f35 to nil") } { if err := s.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode ephemeral.sendMessage#68cbd09f: field flags: %w", err) + return fmt.Errorf("unable to decode ephemeral.sendMessage#ba8d5f35: field flags: %w", err) } } - { + s.InvertMedia = s.Flags.Has(6) + s.Welcome = s.Flags.Has(7) + s.Anchor = s.Flags.Has(9) + s.Noforwards = s.Flags.Has(10) + if s.Flags.Has(8) { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode ephemeral.sendMessage#68cbd09f: field peer: %w", err) + return fmt.Errorf("unable to decode ephemeral.sendMessage#ba8d5f35: field peer: %w", err) } s.Peer = value } { value, err := DecodeInputUser(b) if err != nil { - return fmt.Errorf("unable to decode ephemeral.sendMessage#68cbd09f: field receiver_id: %w", err) + return fmt.Errorf("unable to decode ephemeral.sendMessage#ba8d5f35: field receiver_id: %w", err) } s.ReceiverID = value } if s.Flags.Has(0) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode ephemeral.sendMessage#68cbd09f: field query_id: %w", err) + return fmt.Errorf("unable to decode ephemeral.sendMessage#ba8d5f35: field query_id: %w", err) } s.QueryID = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode ephemeral.sendMessage#68cbd09f: field message: %w", err) + return fmt.Errorf("unable to decode ephemeral.sendMessage#ba8d5f35: field message: %w", err) } s.Message = value } if s.Flags.Has(1) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode ephemeral.sendMessage#68cbd09f: field entities: %w", err) + return fmt.Errorf("unable to decode ephemeral.sendMessage#ba8d5f35: field entities: %w", err) } if headerLen > 0 { @@ -412,7 +487,7 @@ func (s *EphemeralSendMessageRequest) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := DecodeMessageEntity(b) if err != nil { - return fmt.Errorf("unable to decode ephemeral.sendMessage#68cbd09f: field entities: %w", err) + return fmt.Errorf("unable to decode ephemeral.sendMessage#ba8d5f35: field entities: %w", err) } s.Entities = append(s.Entities, value) } @@ -420,47 +495,133 @@ func (s *EphemeralSendMessageRequest) DecodeBare(b *bin.Buffer) error { if s.Flags.Has(2) { value, err := DecodeInputMedia(b) if err != nil { - return fmt.Errorf("unable to decode ephemeral.sendMessage#68cbd09f: field media: %w", err) + return fmt.Errorf("unable to decode ephemeral.sendMessage#ba8d5f35: field media: %w", err) } s.Media = value } if s.Flags.Has(3) { value, err := DecodeReplyMarkup(b) if err != nil { - return fmt.Errorf("unable to decode ephemeral.sendMessage#68cbd09f: field reply_markup: %w", err) + return fmt.Errorf("unable to decode ephemeral.sendMessage#ba8d5f35: field reply_markup: %w", err) } s.ReplyMarkup = value } if s.Flags.Has(4) { value, err := DecodeInputRichMessage(b) if err != nil { - return fmt.Errorf("unable to decode ephemeral.sendMessage#68cbd09f: field rich_message: %w", err) + return fmt.Errorf("unable to decode ephemeral.sendMessage#ba8d5f35: field rich_message: %w", err) } s.RichMessage = value } { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode ephemeral.sendMessage#68cbd09f: field random_id: %w", err) + return fmt.Errorf("unable to decode ephemeral.sendMessage#ba8d5f35: field random_id: %w", err) } s.RandomID = value } if s.Flags.Has(5) { value, err := DecodeInputReplyTo(b) if err != nil { - return fmt.Errorf("unable to decode ephemeral.sendMessage#68cbd09f: field reply_to: %w", err) + return fmt.Errorf("unable to decode ephemeral.sendMessage#ba8d5f35: field reply_to: %w", err) } s.ReplyTo = value } return nil } -// GetPeer returns value of Peer field. -func (s *EphemeralSendMessageRequest) GetPeer() (value InputPeerClass) { +// SetInvertMedia sets value of InvertMedia conditional field. +func (s *EphemeralSendMessageRequest) SetInvertMedia(value bool) { + if value { + s.Flags.Set(6) + s.InvertMedia = true + } else { + s.Flags.Unset(6) + s.InvertMedia = false + } +} + +// GetInvertMedia returns value of InvertMedia conditional field. +func (s *EphemeralSendMessageRequest) GetInvertMedia() (value bool) { + if s == nil { + return + } + return s.Flags.Has(6) +} + +// SetWelcome sets value of Welcome conditional field. +func (s *EphemeralSendMessageRequest) SetWelcome(value bool) { + if value { + s.Flags.Set(7) + s.Welcome = true + } else { + s.Flags.Unset(7) + s.Welcome = false + } +} + +// GetWelcome returns value of Welcome conditional field. +func (s *EphemeralSendMessageRequest) GetWelcome() (value bool) { if s == nil { return } - return s.Peer + return s.Flags.Has(7) +} + +// SetAnchor sets value of Anchor conditional field. +func (s *EphemeralSendMessageRequest) SetAnchor(value bool) { + if value { + s.Flags.Set(9) + s.Anchor = true + } else { + s.Flags.Unset(9) + s.Anchor = false + } +} + +// GetAnchor returns value of Anchor conditional field. +func (s *EphemeralSendMessageRequest) GetAnchor() (value bool) { + if s == nil { + return + } + return s.Flags.Has(9) +} + +// SetNoforwards sets value of Noforwards conditional field. +func (s *EphemeralSendMessageRequest) SetNoforwards(value bool) { + if value { + s.Flags.Set(10) + s.Noforwards = true + } else { + s.Flags.Unset(10) + s.Noforwards = false + } +} + +// GetNoforwards returns value of Noforwards conditional field. +func (s *EphemeralSendMessageRequest) GetNoforwards() (value bool) { + if s == nil { + return + } + return s.Flags.Has(10) +} + +// SetPeer sets value of Peer conditional field. +func (s *EphemeralSendMessageRequest) SetPeer(value InputPeerClass) { + s.Flags.Set(8) + s.Peer = value +} + +// GetPeer returns value of Peer conditional field and +// boolean which is true if field was set. +func (s *EphemeralSendMessageRequest) GetPeer() (value InputPeerClass, ok bool) { + if s == nil { + return + } + if !s.Flags.Has(8) { + return value, false + } + return s.Peer, true } // GetReceiverID returns value of ReceiverID field. @@ -603,7 +764,7 @@ func (s *EphemeralSendMessageRequest) MapEntities() (value MessageEntityClassArr return MessageEntityClassArray(s.Entities), true } -// EphemeralSendMessage invokes method ephemeral.sendMessage#68cbd09f returning error if any. +// EphemeralSendMessage invokes method ephemeral.sendMessage#ba8d5f35 returning error if any. // // See https://core.telegram.org/method/ephemeral.sendMessage for reference. func (c *Client) EphemeralSendMessage(ctx context.Context, request *EphemeralSendMessageRequest) (UpdatesClass, error) { diff --git a/tg/tl_ephemeral_welcome_messages_gen.go b/tg/tl_ephemeral_welcome_messages_gen.go new file mode 100644 index 0000000000..5b6c3f7008 --- /dev/null +++ b/tg/tl_ephemeral_welcome_messages_gen.go @@ -0,0 +1,415 @@ +// 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{} +) + +// EphemeralWelcomeMessagesNotModified represents TL type `ephemeral.welcomeMessagesNotModified#59ffdb31`. +// +// See https://core.telegram.org/constructor/ephemeral.welcomeMessagesNotModified for reference. +type EphemeralWelcomeMessagesNotModified struct { +} + +// EphemeralWelcomeMessagesNotModifiedTypeID is TL type id of EphemeralWelcomeMessagesNotModified. +const EphemeralWelcomeMessagesNotModifiedTypeID = 0x59ffdb31 + +// construct implements constructor of EphemeralWelcomeMessagesClass. +func (w EphemeralWelcomeMessagesNotModified) construct() EphemeralWelcomeMessagesClass { return &w } + +// Ensuring interfaces in compile-time for EphemeralWelcomeMessagesNotModified. +var ( + _ bin.Encoder = &EphemeralWelcomeMessagesNotModified{} + _ bin.Decoder = &EphemeralWelcomeMessagesNotModified{} + _ bin.BareEncoder = &EphemeralWelcomeMessagesNotModified{} + _ bin.BareDecoder = &EphemeralWelcomeMessagesNotModified{} + + _ EphemeralWelcomeMessagesClass = &EphemeralWelcomeMessagesNotModified{} +) + +func (w *EphemeralWelcomeMessagesNotModified) Zero() bool { + if w == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (w *EphemeralWelcomeMessagesNotModified) String() string { + if w == nil { + return "EphemeralWelcomeMessagesNotModified(nil)" + } + type Alias EphemeralWelcomeMessagesNotModified + return fmt.Sprintf("EphemeralWelcomeMessagesNotModified%+v", Alias(*w)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*EphemeralWelcomeMessagesNotModified) TypeID() uint32 { + return EphemeralWelcomeMessagesNotModifiedTypeID +} + +// TypeName returns name of type in TL schema. +func (*EphemeralWelcomeMessagesNotModified) TypeName() string { + return "ephemeral.welcomeMessagesNotModified" +} + +// TypeInfo returns info about TL type. +func (w *EphemeralWelcomeMessagesNotModified) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "ephemeral.welcomeMessagesNotModified", + ID: EphemeralWelcomeMessagesNotModifiedTypeID, + } + if w == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (w *EphemeralWelcomeMessagesNotModified) Encode(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't encode ephemeral.welcomeMessagesNotModified#59ffdb31 as nil") + } + b.PutID(EphemeralWelcomeMessagesNotModifiedTypeID) + return w.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (w *EphemeralWelcomeMessagesNotModified) EncodeBare(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't encode ephemeral.welcomeMessagesNotModified#59ffdb31 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (w *EphemeralWelcomeMessagesNotModified) Decode(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't decode ephemeral.welcomeMessagesNotModified#59ffdb31 to nil") + } + if err := b.ConsumeID(EphemeralWelcomeMessagesNotModifiedTypeID); err != nil { + return fmt.Errorf("unable to decode ephemeral.welcomeMessagesNotModified#59ffdb31: %w", err) + } + return w.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (w *EphemeralWelcomeMessagesNotModified) DecodeBare(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't decode ephemeral.welcomeMessagesNotModified#59ffdb31 to nil") + } + return nil +} + +// EphemeralWelcomeMessages represents TL type `ephemeral.welcomeMessages#104fc872`. +// +// See https://core.telegram.org/constructor/ephemeral.welcomeMessages for reference. +type EphemeralWelcomeMessages struct { + // Hash field of EphemeralWelcomeMessages. + Hash int64 + // Messages field of EphemeralWelcomeMessages. + Messages []EphemeralMessage +} + +// EphemeralWelcomeMessagesTypeID is TL type id of EphemeralWelcomeMessages. +const EphemeralWelcomeMessagesTypeID = 0x104fc872 + +// construct implements constructor of EphemeralWelcomeMessagesClass. +func (w EphemeralWelcomeMessages) construct() EphemeralWelcomeMessagesClass { return &w } + +// Ensuring interfaces in compile-time for EphemeralWelcomeMessages. +var ( + _ bin.Encoder = &EphemeralWelcomeMessages{} + _ bin.Decoder = &EphemeralWelcomeMessages{} + _ bin.BareEncoder = &EphemeralWelcomeMessages{} + _ bin.BareDecoder = &EphemeralWelcomeMessages{} + + _ EphemeralWelcomeMessagesClass = &EphemeralWelcomeMessages{} +) + +func (w *EphemeralWelcomeMessages) Zero() bool { + if w == nil { + return true + } + if !(w.Hash == 0) { + return false + } + if !(w.Messages == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (w *EphemeralWelcomeMessages) String() string { + if w == nil { + return "EphemeralWelcomeMessages(nil)" + } + type Alias EphemeralWelcomeMessages + return fmt.Sprintf("EphemeralWelcomeMessages%+v", Alias(*w)) +} + +// FillFrom fills EphemeralWelcomeMessages from given interface. +func (w *EphemeralWelcomeMessages) FillFrom(from interface { + GetHash() (value int64) + GetMessages() (value []EphemeralMessage) +}) { + w.Hash = from.GetHash() + w.Messages = from.GetMessages() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*EphemeralWelcomeMessages) TypeID() uint32 { + return EphemeralWelcomeMessagesTypeID +} + +// TypeName returns name of type in TL schema. +func (*EphemeralWelcomeMessages) TypeName() string { + return "ephemeral.welcomeMessages" +} + +// TypeInfo returns info about TL type. +func (w *EphemeralWelcomeMessages) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "ephemeral.welcomeMessages", + ID: EphemeralWelcomeMessagesTypeID, + } + if w == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Hash", + SchemaName: "hash", + }, + { + Name: "Messages", + SchemaName: "messages", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (w *EphemeralWelcomeMessages) Encode(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't encode ephemeral.welcomeMessages#104fc872 as nil") + } + b.PutID(EphemeralWelcomeMessagesTypeID) + return w.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (w *EphemeralWelcomeMessages) EncodeBare(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't encode ephemeral.welcomeMessages#104fc872 as nil") + } + b.PutLong(w.Hash) + b.PutVectorHeader(len(w.Messages)) + for idx, v := range w.Messages { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode ephemeral.welcomeMessages#104fc872: field messages element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (w *EphemeralWelcomeMessages) Decode(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't decode ephemeral.welcomeMessages#104fc872 to nil") + } + if err := b.ConsumeID(EphemeralWelcomeMessagesTypeID); err != nil { + return fmt.Errorf("unable to decode ephemeral.welcomeMessages#104fc872: %w", err) + } + return w.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (w *EphemeralWelcomeMessages) DecodeBare(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't decode ephemeral.welcomeMessages#104fc872 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode ephemeral.welcomeMessages#104fc872: field hash: %w", err) + } + w.Hash = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode ephemeral.welcomeMessages#104fc872: field messages: %w", err) + } + + if headerLen > 0 { + w.Messages = make([]EphemeralMessage, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value EphemeralMessage + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode ephemeral.welcomeMessages#104fc872: field messages: %w", err) + } + w.Messages = append(w.Messages, value) + } + } + return nil +} + +// GetHash returns value of Hash field. +func (w *EphemeralWelcomeMessages) GetHash() (value int64) { + if w == nil { + return + } + return w.Hash +} + +// GetMessages returns value of Messages field. +func (w *EphemeralWelcomeMessages) GetMessages() (value []EphemeralMessage) { + if w == nil { + return + } + return w.Messages +} + +// EphemeralWelcomeMessagesClassName is schema name of EphemeralWelcomeMessagesClass. +const EphemeralWelcomeMessagesClassName = "ephemeral.WelcomeMessages" + +// EphemeralWelcomeMessagesClass represents ephemeral.WelcomeMessages generic type. +// +// See https://core.telegram.org/type/ephemeral.WelcomeMessages for reference. +// +// Constructors: +// - [EphemeralWelcomeMessagesNotModified] +// - [EphemeralWelcomeMessages] +// +// Example: +// +// g, err := tg.DecodeEphemeralWelcomeMessages(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.EphemeralWelcomeMessagesNotModified: // ephemeral.welcomeMessagesNotModified#59ffdb31 +// case *tg.EphemeralWelcomeMessages: // ephemeral.welcomeMessages#104fc872 +// default: panic(v) +// } +type EphemeralWelcomeMessagesClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() EphemeralWelcomeMessagesClass + + // TypeID returns type id in TL schema. + // + // See https://core.telegram.org/mtproto/TL-tl#remarks. + TypeID() uint32 + // TypeName returns name of type in TL schema. + TypeName() string + // String implements fmt.Stringer. + String() string + // Zero returns true if current object has a zero value. + Zero() bool + + // AsModified tries to map EphemeralWelcomeMessagesClass to EphemeralWelcomeMessages. + AsModified() (*EphemeralWelcomeMessages, bool) +} + +// AsModified tries to map EphemeralWelcomeMessagesNotModified to EphemeralWelcomeMessages. +func (w *EphemeralWelcomeMessagesNotModified) AsModified() (*EphemeralWelcomeMessages, bool) { + return nil, false +} + +// AsModified tries to map EphemeralWelcomeMessages to EphemeralWelcomeMessages. +func (w *EphemeralWelcomeMessages) AsModified() (*EphemeralWelcomeMessages, bool) { + return w, true +} + +// DecodeEphemeralWelcomeMessages implements binary de-serialization for EphemeralWelcomeMessagesClass. +func DecodeEphemeralWelcomeMessages(buf *bin.Buffer) (EphemeralWelcomeMessagesClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case EphemeralWelcomeMessagesNotModifiedTypeID: + // Decoding ephemeral.welcomeMessagesNotModified#59ffdb31. + v := EphemeralWelcomeMessagesNotModified{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode EphemeralWelcomeMessagesClass: %w", err) + } + return &v, nil + case EphemeralWelcomeMessagesTypeID: + // Decoding ephemeral.welcomeMessages#104fc872. + v := EphemeralWelcomeMessages{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode EphemeralWelcomeMessagesClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode EphemeralWelcomeMessagesClass: %w", bin.NewUnexpectedID(id)) + } +} + +// EphemeralWelcomeMessages boxes the EphemeralWelcomeMessagesClass providing a helper. +type EphemeralWelcomeMessagesBox struct { + WelcomeMessages EphemeralWelcomeMessagesClass +} + +// Decode implements bin.Decoder for EphemeralWelcomeMessagesBox. +func (b *EphemeralWelcomeMessagesBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode EphemeralWelcomeMessagesBox to nil") + } + v, err := DecodeEphemeralWelcomeMessages(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.WelcomeMessages = v + return nil +} + +// Encode implements bin.Encode for EphemeralWelcomeMessagesBox. +func (b *EphemeralWelcomeMessagesBox) Encode(buf *bin.Buffer) error { + if b == nil || b.WelcomeMessages == nil { + return fmt.Errorf("unable to encode EphemeralWelcomeMessagesClass as nil") + } + return b.WelcomeMessages.Encode(buf) +} diff --git a/tg/tl_ephemeral_welcome_messages_slices_gen.go b/tg/tl_ephemeral_welcome_messages_slices_gen.go new file mode 100644 index 0000000000..1cd103e9ee --- /dev/null +++ b/tg/tl_ephemeral_welcome_messages_slices_gen.go @@ -0,0 +1,267 @@ +//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{} +) + +// EphemeralWelcomeMessagesClassArray is adapter for slice of EphemeralWelcomeMessagesClass. +type EphemeralWelcomeMessagesClassArray []EphemeralWelcomeMessagesClass + +// Sort sorts slice of EphemeralWelcomeMessagesClass. +func (s EphemeralWelcomeMessagesClassArray) Sort(less func(a, b EphemeralWelcomeMessagesClass) bool) EphemeralWelcomeMessagesClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of EphemeralWelcomeMessagesClass. +func (s EphemeralWelcomeMessagesClassArray) SortStable(less func(a, b EphemeralWelcomeMessagesClass) bool) EphemeralWelcomeMessagesClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of EphemeralWelcomeMessagesClass. +func (s EphemeralWelcomeMessagesClassArray) Retain(keep func(x EphemeralWelcomeMessagesClass) bool) EphemeralWelcomeMessagesClassArray { + 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 EphemeralWelcomeMessagesClassArray) First() (v EphemeralWelcomeMessagesClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s EphemeralWelcomeMessagesClassArray) Last() (v EphemeralWelcomeMessagesClass, 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 *EphemeralWelcomeMessagesClassArray) PopFirst() (v EphemeralWelcomeMessagesClass, 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 EphemeralWelcomeMessagesClass + 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 *EphemeralWelcomeMessagesClassArray) Pop() (v EphemeralWelcomeMessagesClass, 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 +} + +// AsEphemeralWelcomeMessages returns copy with only EphemeralWelcomeMessages constructors. +func (s EphemeralWelcomeMessagesClassArray) AsEphemeralWelcomeMessages() (to EphemeralWelcomeMessagesArray) { + for _, elem := range s { + value, ok := elem.(*EphemeralWelcomeMessages) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AppendOnlyModified appends only Modified constructors to +// given slice. +func (s EphemeralWelcomeMessagesClassArray) AppendOnlyModified(to []*EphemeralWelcomeMessages) []*EphemeralWelcomeMessages { + for _, elem := range s { + value, ok := elem.AsModified() + if !ok { + continue + } + to = append(to, value) + } + + return to +} + +// AsModified returns copy with only Modified constructors. +func (s EphemeralWelcomeMessagesClassArray) AsModified() (to []*EphemeralWelcomeMessages) { + return s.AppendOnlyModified(to) +} + +// FirstAsModified returns first element of slice (if exists). +func (s EphemeralWelcomeMessagesClassArray) FirstAsModified() (v *EphemeralWelcomeMessages, ok bool) { + value, ok := s.First() + if !ok { + return + } + return value.AsModified() +} + +// LastAsModified returns last element of slice (if exists). +func (s EphemeralWelcomeMessagesClassArray) LastAsModified() (v *EphemeralWelcomeMessages, ok bool) { + value, ok := s.Last() + if !ok { + return + } + return value.AsModified() +} + +// PopFirstAsModified returns element of slice (if exists). +func (s *EphemeralWelcomeMessagesClassArray) PopFirstAsModified() (v *EphemeralWelcomeMessages, ok bool) { + value, ok := s.PopFirst() + if !ok { + return + } + return value.AsModified() +} + +// PopAsModified returns element of slice (if exists). +func (s *EphemeralWelcomeMessagesClassArray) PopAsModified() (v *EphemeralWelcomeMessages, ok bool) { + value, ok := s.Pop() + if !ok { + return + } + return value.AsModified() +} + +// EphemeralWelcomeMessagesArray is adapter for slice of EphemeralWelcomeMessages. +type EphemeralWelcomeMessagesArray []EphemeralWelcomeMessages + +// Sort sorts slice of EphemeralWelcomeMessages. +func (s EphemeralWelcomeMessagesArray) Sort(less func(a, b EphemeralWelcomeMessages) bool) EphemeralWelcomeMessagesArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of EphemeralWelcomeMessages. +func (s EphemeralWelcomeMessagesArray) SortStable(less func(a, b EphemeralWelcomeMessages) bool) EphemeralWelcomeMessagesArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of EphemeralWelcomeMessages. +func (s EphemeralWelcomeMessagesArray) Retain(keep func(x EphemeralWelcomeMessages) bool) EphemeralWelcomeMessagesArray { + 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 EphemeralWelcomeMessagesArray) First() (v EphemeralWelcomeMessages, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s EphemeralWelcomeMessagesArray) Last() (v EphemeralWelcomeMessages, 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 *EphemeralWelcomeMessagesArray) PopFirst() (v EphemeralWelcomeMessages, 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 EphemeralWelcomeMessages + 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 *EphemeralWelcomeMessagesArray) Pop() (v EphemeralWelcomeMessages, 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_handlers_gen.go b/tg/tl_handlers_gen.go index 1cfb6c6b79..1ec71ca598 100644 --- a/tg/tl_handlers_gen.go +++ b/tg/tl_handlers_gen.go @@ -1740,6 +1740,16 @@ func (u UpdateDispatcher) OnEditEphemeralMessage(handler EditEphemeralMessageHan } } +// EphemeralBotCallbackQueryHandler is a EphemeralBotCallbackQuery event handler. +type EphemeralBotCallbackQueryHandler func(ctx context.Context, e Entities, update *UpdateEphemeralBotCallbackQuery) error + +// OnEphemeralBotCallbackQuery sets EphemeralBotCallbackQuery handler. +func (u UpdateDispatcher) OnEphemeralBotCallbackQuery(handler EphemeralBotCallbackQueryHandler) { + u.handlers[UpdateEphemeralBotCallbackQueryTypeID] = func(ctx context.Context, e Entities, update UpdateClass) error { + return handler(ctx, e, update.(*UpdateEphemeralBotCallbackQuery)) + } +} + // BotStarsSubscriptionHandler is a BotStarsSubscription event handler. type BotStarsSubscriptionHandler func(ctx context.Context, e Entities, update *UpdateBotStarsSubscription) error diff --git a/tg/tl_inline_button_type_gen.go b/tg/tl_inline_button_type_gen.go new file mode 100644 index 0000000000..43159ed065 --- /dev/null +++ b/tg/tl_inline_button_type_gen.go @@ -0,0 +1,2156 @@ +// 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{} +) + +// InlineButtonTypeURL represents TL type `inlineButtonTypeUrl#eca4f8d4`. +// +// See https://core.telegram.org/constructor/inlineButtonTypeUrl for reference. +type InlineButtonTypeURL struct { + // URL field of InlineButtonTypeURL. + URL string +} + +// InlineButtonTypeURLTypeID is TL type id of InlineButtonTypeURL. +const InlineButtonTypeURLTypeID = 0xeca4f8d4 + +// construct implements constructor of InlineButtonTypeClass. +func (i InlineButtonTypeURL) construct() InlineButtonTypeClass { return &i } + +// Ensuring interfaces in compile-time for InlineButtonTypeURL. +var ( + _ bin.Encoder = &InlineButtonTypeURL{} + _ bin.Decoder = &InlineButtonTypeURL{} + _ bin.BareEncoder = &InlineButtonTypeURL{} + _ bin.BareDecoder = &InlineButtonTypeURL{} + + _ InlineButtonTypeClass = &InlineButtonTypeURL{} +) + +func (i *InlineButtonTypeURL) Zero() bool { + if i == nil { + return true + } + if !(i.URL == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InlineButtonTypeURL) String() string { + if i == nil { + return "InlineButtonTypeURL(nil)" + } + type Alias InlineButtonTypeURL + return fmt.Sprintf("InlineButtonTypeURL%+v", Alias(*i)) +} + +// FillFrom fills InlineButtonTypeURL from given interface. +func (i *InlineButtonTypeURL) FillFrom(from interface { + GetURL() (value string) +}) { + i.URL = from.GetURL() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InlineButtonTypeURL) TypeID() uint32 { + return InlineButtonTypeURLTypeID +} + +// TypeName returns name of type in TL schema. +func (*InlineButtonTypeURL) TypeName() string { + return "inlineButtonTypeUrl" +} + +// TypeInfo returns info about TL type. +func (i *InlineButtonTypeURL) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inlineButtonTypeUrl", + ID: InlineButtonTypeURLTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "URL", + SchemaName: "url", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (i *InlineButtonTypeURL) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inlineButtonTypeUrl#eca4f8d4 as nil") + } + b.PutID(InlineButtonTypeURLTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InlineButtonTypeURL) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inlineButtonTypeUrl#eca4f8d4 as nil") + } + b.PutString(i.URL) + return nil +} + +// Decode implements bin.Decoder. +func (i *InlineButtonTypeURL) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inlineButtonTypeUrl#eca4f8d4 to nil") + } + if err := b.ConsumeID(InlineButtonTypeURLTypeID); err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeUrl#eca4f8d4: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InlineButtonTypeURL) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inlineButtonTypeUrl#eca4f8d4 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeUrl#eca4f8d4: field url: %w", err) + } + i.URL = value + } + return nil +} + +// GetURL returns value of URL field. +func (i *InlineButtonTypeURL) GetURL() (value string) { + if i == nil { + return + } + return i.URL +} + +// InlineButtonTypeURLAuth represents TL type `inlineButtonTypeUrlAuth#bfd02da2`. +// +// See https://core.telegram.org/constructor/inlineButtonTypeUrlAuth for reference. +type InlineButtonTypeURLAuth struct { + // Flags field of InlineButtonTypeURLAuth. + Flags bin.Fields + // FwdText field of InlineButtonTypeURLAuth. + // + // Use SetFwdText and GetFwdText helpers. + FwdText string + // URL field of InlineButtonTypeURLAuth. + URL string + // ButtonID field of InlineButtonTypeURLAuth. + ButtonID int +} + +// InlineButtonTypeURLAuthTypeID is TL type id of InlineButtonTypeURLAuth. +const InlineButtonTypeURLAuthTypeID = 0xbfd02da2 + +// construct implements constructor of InlineButtonTypeClass. +func (i InlineButtonTypeURLAuth) construct() InlineButtonTypeClass { return &i } + +// Ensuring interfaces in compile-time for InlineButtonTypeURLAuth. +var ( + _ bin.Encoder = &InlineButtonTypeURLAuth{} + _ bin.Decoder = &InlineButtonTypeURLAuth{} + _ bin.BareEncoder = &InlineButtonTypeURLAuth{} + _ bin.BareDecoder = &InlineButtonTypeURLAuth{} + + _ InlineButtonTypeClass = &InlineButtonTypeURLAuth{} +) + +func (i *InlineButtonTypeURLAuth) Zero() bool { + if i == nil { + return true + } + if !(i.Flags.Zero()) { + return false + } + if !(i.FwdText == "") { + return false + } + if !(i.URL == "") { + return false + } + if !(i.ButtonID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InlineButtonTypeURLAuth) String() string { + if i == nil { + return "InlineButtonTypeURLAuth(nil)" + } + type Alias InlineButtonTypeURLAuth + return fmt.Sprintf("InlineButtonTypeURLAuth%+v", Alias(*i)) +} + +// FillFrom fills InlineButtonTypeURLAuth from given interface. +func (i *InlineButtonTypeURLAuth) FillFrom(from interface { + GetFwdText() (value string, ok bool) + GetURL() (value string) + GetButtonID() (value int) +}) { + if val, ok := from.GetFwdText(); ok { + i.FwdText = val + } + + i.URL = from.GetURL() + i.ButtonID = from.GetButtonID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InlineButtonTypeURLAuth) TypeID() uint32 { + return InlineButtonTypeURLAuthTypeID +} + +// TypeName returns name of type in TL schema. +func (*InlineButtonTypeURLAuth) TypeName() string { + return "inlineButtonTypeUrlAuth" +} + +// TypeInfo returns info about TL type. +func (i *InlineButtonTypeURLAuth) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inlineButtonTypeUrlAuth", + ID: InlineButtonTypeURLAuthTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "FwdText", + SchemaName: "fwd_text", + Null: !i.Flags.Has(0), + }, + { + Name: "URL", + SchemaName: "url", + }, + { + Name: "ButtonID", + SchemaName: "button_id", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (i *InlineButtonTypeURLAuth) SetFlags() { + if !(i.FwdText == "") { + i.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (i *InlineButtonTypeURLAuth) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inlineButtonTypeUrlAuth#bfd02da2 as nil") + } + b.PutID(InlineButtonTypeURLAuthTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InlineButtonTypeURLAuth) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inlineButtonTypeUrlAuth#bfd02da2 as nil") + } + i.SetFlags() + if err := i.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode inlineButtonTypeUrlAuth#bfd02da2: field flags: %w", err) + } + if i.Flags.Has(0) { + b.PutString(i.FwdText) + } + b.PutString(i.URL) + b.PutInt(i.ButtonID) + return nil +} + +// Decode implements bin.Decoder. +func (i *InlineButtonTypeURLAuth) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inlineButtonTypeUrlAuth#bfd02da2 to nil") + } + if err := b.ConsumeID(InlineButtonTypeURLAuthTypeID); err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeUrlAuth#bfd02da2: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InlineButtonTypeURLAuth) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inlineButtonTypeUrlAuth#bfd02da2 to nil") + } + { + if err := i.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeUrlAuth#bfd02da2: field flags: %w", err) + } + } + if i.Flags.Has(0) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeUrlAuth#bfd02da2: field fwd_text: %w", err) + } + i.FwdText = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeUrlAuth#bfd02da2: field url: %w", err) + } + i.URL = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeUrlAuth#bfd02da2: field button_id: %w", err) + } + i.ButtonID = value + } + return nil +} + +// SetFwdText sets value of FwdText conditional field. +func (i *InlineButtonTypeURLAuth) SetFwdText(value string) { + i.Flags.Set(0) + i.FwdText = value +} + +// GetFwdText returns value of FwdText conditional field and +// boolean which is true if field was set. +func (i *InlineButtonTypeURLAuth) GetFwdText() (value string, ok bool) { + if i == nil { + return + } + if !i.Flags.Has(0) { + return value, false + } + return i.FwdText, true +} + +// GetURL returns value of URL field. +func (i *InlineButtonTypeURLAuth) GetURL() (value string) { + if i == nil { + return + } + return i.URL +} + +// GetButtonID returns value of ButtonID field. +func (i *InlineButtonTypeURLAuth) GetButtonID() (value int) { + if i == nil { + return + } + return i.ButtonID +} + +// InputInlineButtonTypeURLAuth represents TL type `inputInlineButtonTypeUrlAuth#9961bcb4`. +// +// See https://core.telegram.org/constructor/inputInlineButtonTypeUrlAuth for reference. +type InputInlineButtonTypeURLAuth struct { + // Flags field of InputInlineButtonTypeURLAuth. + Flags bin.Fields + // RequestWriteAccess field of InputInlineButtonTypeURLAuth. + RequestWriteAccess bool + // FwdText field of InputInlineButtonTypeURLAuth. + // + // Use SetFwdText and GetFwdText helpers. + FwdText string + // URL field of InputInlineButtonTypeURLAuth. + URL string + // Bot field of InputInlineButtonTypeURLAuth. + // + // Use SetBot and GetBot helpers. + Bot InputUserClass +} + +// InputInlineButtonTypeURLAuthTypeID is TL type id of InputInlineButtonTypeURLAuth. +const InputInlineButtonTypeURLAuthTypeID = 0x9961bcb4 + +// construct implements constructor of InlineButtonTypeClass. +func (i InputInlineButtonTypeURLAuth) construct() InlineButtonTypeClass { return &i } + +// Ensuring interfaces in compile-time for InputInlineButtonTypeURLAuth. +var ( + _ bin.Encoder = &InputInlineButtonTypeURLAuth{} + _ bin.Decoder = &InputInlineButtonTypeURLAuth{} + _ bin.BareEncoder = &InputInlineButtonTypeURLAuth{} + _ bin.BareDecoder = &InputInlineButtonTypeURLAuth{} + + _ InlineButtonTypeClass = &InputInlineButtonTypeURLAuth{} +) + +func (i *InputInlineButtonTypeURLAuth) Zero() bool { + if i == nil { + return true + } + if !(i.Flags.Zero()) { + return false + } + if !(i.RequestWriteAccess == false) { + return false + } + if !(i.FwdText == "") { + return false + } + if !(i.URL == "") { + return false + } + if !(i.Bot == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InputInlineButtonTypeURLAuth) String() string { + if i == nil { + return "InputInlineButtonTypeURLAuth(nil)" + } + type Alias InputInlineButtonTypeURLAuth + return fmt.Sprintf("InputInlineButtonTypeURLAuth%+v", Alias(*i)) +} + +// FillFrom fills InputInlineButtonTypeURLAuth from given interface. +func (i *InputInlineButtonTypeURLAuth) FillFrom(from interface { + GetRequestWriteAccess() (value bool) + GetFwdText() (value string, ok bool) + GetURL() (value string) + GetBot() (value InputUserClass, ok bool) +}) { + i.RequestWriteAccess = from.GetRequestWriteAccess() + if val, ok := from.GetFwdText(); ok { + i.FwdText = val + } + + i.URL = from.GetURL() + if val, ok := from.GetBot(); ok { + i.Bot = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InputInlineButtonTypeURLAuth) TypeID() uint32 { + return InputInlineButtonTypeURLAuthTypeID +} + +// TypeName returns name of type in TL schema. +func (*InputInlineButtonTypeURLAuth) TypeName() string { + return "inputInlineButtonTypeUrlAuth" +} + +// TypeInfo returns info about TL type. +func (i *InputInlineButtonTypeURLAuth) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inputInlineButtonTypeUrlAuth", + ID: InputInlineButtonTypeURLAuthTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "RequestWriteAccess", + SchemaName: "request_write_access", + Null: !i.Flags.Has(0), + }, + { + Name: "FwdText", + SchemaName: "fwd_text", + Null: !i.Flags.Has(1), + }, + { + Name: "URL", + SchemaName: "url", + }, + { + Name: "Bot", + SchemaName: "bot", + Null: !i.Flags.Has(2), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (i *InputInlineButtonTypeURLAuth) SetFlags() { + if !(i.RequestWriteAccess == false) { + i.Flags.Set(0) + } + if !(i.FwdText == "") { + i.Flags.Set(1) + } + if !(i.Bot == nil) { + i.Flags.Set(2) + } +} + +// Encode implements bin.Encoder. +func (i *InputInlineButtonTypeURLAuth) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputInlineButtonTypeUrlAuth#9961bcb4 as nil") + } + b.PutID(InputInlineButtonTypeURLAuthTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InputInlineButtonTypeURLAuth) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputInlineButtonTypeUrlAuth#9961bcb4 as nil") + } + i.SetFlags() + if err := i.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputInlineButtonTypeUrlAuth#9961bcb4: field flags: %w", err) + } + if i.Flags.Has(1) { + b.PutString(i.FwdText) + } + b.PutString(i.URL) + if i.Flags.Has(2) { + if i.Bot == nil { + return fmt.Errorf("unable to encode inputInlineButtonTypeUrlAuth#9961bcb4: field bot is nil") + } + if err := i.Bot.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputInlineButtonTypeUrlAuth#9961bcb4: field bot: %w", err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (i *InputInlineButtonTypeURLAuth) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputInlineButtonTypeUrlAuth#9961bcb4 to nil") + } + if err := b.ConsumeID(InputInlineButtonTypeURLAuthTypeID); err != nil { + return fmt.Errorf("unable to decode inputInlineButtonTypeUrlAuth#9961bcb4: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InputInlineButtonTypeURLAuth) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputInlineButtonTypeUrlAuth#9961bcb4 to nil") + } + { + if err := i.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode inputInlineButtonTypeUrlAuth#9961bcb4: field flags: %w", err) + } + } + i.RequestWriteAccess = i.Flags.Has(0) + if i.Flags.Has(1) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode inputInlineButtonTypeUrlAuth#9961bcb4: field fwd_text: %w", err) + } + i.FwdText = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode inputInlineButtonTypeUrlAuth#9961bcb4: field url: %w", err) + } + i.URL = value + } + if i.Flags.Has(2) { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode inputInlineButtonTypeUrlAuth#9961bcb4: field bot: %w", err) + } + i.Bot = value + } + return nil +} + +// SetRequestWriteAccess sets value of RequestWriteAccess conditional field. +func (i *InputInlineButtonTypeURLAuth) SetRequestWriteAccess(value bool) { + if value { + i.Flags.Set(0) + i.RequestWriteAccess = true + } else { + i.Flags.Unset(0) + i.RequestWriteAccess = false + } +} + +// GetRequestWriteAccess returns value of RequestWriteAccess conditional field. +func (i *InputInlineButtonTypeURLAuth) GetRequestWriteAccess() (value bool) { + if i == nil { + return + } + return i.Flags.Has(0) +} + +// SetFwdText sets value of FwdText conditional field. +func (i *InputInlineButtonTypeURLAuth) SetFwdText(value string) { + i.Flags.Set(1) + i.FwdText = value +} + +// GetFwdText returns value of FwdText conditional field and +// boolean which is true if field was set. +func (i *InputInlineButtonTypeURLAuth) GetFwdText() (value string, ok bool) { + if i == nil { + return + } + if !i.Flags.Has(1) { + return value, false + } + return i.FwdText, true +} + +// GetURL returns value of URL field. +func (i *InputInlineButtonTypeURLAuth) GetURL() (value string) { + if i == nil { + return + } + return i.URL +} + +// SetBot sets value of Bot conditional field. +func (i *InputInlineButtonTypeURLAuth) SetBot(value InputUserClass) { + i.Flags.Set(2) + i.Bot = value +} + +// GetBot returns value of Bot conditional field and +// boolean which is true if field was set. +func (i *InputInlineButtonTypeURLAuth) GetBot() (value InputUserClass, ok bool) { + if i == nil { + return + } + if !i.Flags.Has(2) { + return value, false + } + return i.Bot, true +} + +// InlineButtonTypeWebView represents TL type `inlineButtonTypeWebView#3bcab5b4`. +// +// See https://core.telegram.org/constructor/inlineButtonTypeWebView for reference. +type InlineButtonTypeWebView struct { + // URL field of InlineButtonTypeWebView. + URL string +} + +// InlineButtonTypeWebViewTypeID is TL type id of InlineButtonTypeWebView. +const InlineButtonTypeWebViewTypeID = 0x3bcab5b4 + +// construct implements constructor of InlineButtonTypeClass. +func (i InlineButtonTypeWebView) construct() InlineButtonTypeClass { return &i } + +// Ensuring interfaces in compile-time for InlineButtonTypeWebView. +var ( + _ bin.Encoder = &InlineButtonTypeWebView{} + _ bin.Decoder = &InlineButtonTypeWebView{} + _ bin.BareEncoder = &InlineButtonTypeWebView{} + _ bin.BareDecoder = &InlineButtonTypeWebView{} + + _ InlineButtonTypeClass = &InlineButtonTypeWebView{} +) + +func (i *InlineButtonTypeWebView) Zero() bool { + if i == nil { + return true + } + if !(i.URL == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InlineButtonTypeWebView) String() string { + if i == nil { + return "InlineButtonTypeWebView(nil)" + } + type Alias InlineButtonTypeWebView + return fmt.Sprintf("InlineButtonTypeWebView%+v", Alias(*i)) +} + +// FillFrom fills InlineButtonTypeWebView from given interface. +func (i *InlineButtonTypeWebView) FillFrom(from interface { + GetURL() (value string) +}) { + i.URL = from.GetURL() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InlineButtonTypeWebView) TypeID() uint32 { + return InlineButtonTypeWebViewTypeID +} + +// TypeName returns name of type in TL schema. +func (*InlineButtonTypeWebView) TypeName() string { + return "inlineButtonTypeWebView" +} + +// TypeInfo returns info about TL type. +func (i *InlineButtonTypeWebView) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inlineButtonTypeWebView", + ID: InlineButtonTypeWebViewTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "URL", + SchemaName: "url", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (i *InlineButtonTypeWebView) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inlineButtonTypeWebView#3bcab5b4 as nil") + } + b.PutID(InlineButtonTypeWebViewTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InlineButtonTypeWebView) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inlineButtonTypeWebView#3bcab5b4 as nil") + } + b.PutString(i.URL) + return nil +} + +// Decode implements bin.Decoder. +func (i *InlineButtonTypeWebView) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inlineButtonTypeWebView#3bcab5b4 to nil") + } + if err := b.ConsumeID(InlineButtonTypeWebViewTypeID); err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeWebView#3bcab5b4: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InlineButtonTypeWebView) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inlineButtonTypeWebView#3bcab5b4 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeWebView#3bcab5b4: field url: %w", err) + } + i.URL = value + } + return nil +} + +// GetURL returns value of URL field. +func (i *InlineButtonTypeWebView) GetURL() (value string) { + if i == nil { + return + } + return i.URL +} + +// InlineButtonTypeCallback represents TL type `inlineButtonTypeCallback#2955bc38`. +// +// See https://core.telegram.org/constructor/inlineButtonTypeCallback for reference. +type InlineButtonTypeCallback struct { + // Flags field of InlineButtonTypeCallback. + Flags bin.Fields + // RequiresPassword field of InlineButtonTypeCallback. + RequiresPassword bool + // Data field of InlineButtonTypeCallback. + Data []byte +} + +// InlineButtonTypeCallbackTypeID is TL type id of InlineButtonTypeCallback. +const InlineButtonTypeCallbackTypeID = 0x2955bc38 + +// construct implements constructor of InlineButtonTypeClass. +func (i InlineButtonTypeCallback) construct() InlineButtonTypeClass { return &i } + +// Ensuring interfaces in compile-time for InlineButtonTypeCallback. +var ( + _ bin.Encoder = &InlineButtonTypeCallback{} + _ bin.Decoder = &InlineButtonTypeCallback{} + _ bin.BareEncoder = &InlineButtonTypeCallback{} + _ bin.BareDecoder = &InlineButtonTypeCallback{} + + _ InlineButtonTypeClass = &InlineButtonTypeCallback{} +) + +func (i *InlineButtonTypeCallback) Zero() bool { + if i == nil { + return true + } + if !(i.Flags.Zero()) { + return false + } + if !(i.RequiresPassword == false) { + return false + } + if !(i.Data == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InlineButtonTypeCallback) String() string { + if i == nil { + return "InlineButtonTypeCallback(nil)" + } + type Alias InlineButtonTypeCallback + return fmt.Sprintf("InlineButtonTypeCallback%+v", Alias(*i)) +} + +// FillFrom fills InlineButtonTypeCallback from given interface. +func (i *InlineButtonTypeCallback) FillFrom(from interface { + GetRequiresPassword() (value bool) + GetData() (value []byte) +}) { + i.RequiresPassword = from.GetRequiresPassword() + i.Data = from.GetData() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InlineButtonTypeCallback) TypeID() uint32 { + return InlineButtonTypeCallbackTypeID +} + +// TypeName returns name of type in TL schema. +func (*InlineButtonTypeCallback) TypeName() string { + return "inlineButtonTypeCallback" +} + +// TypeInfo returns info about TL type. +func (i *InlineButtonTypeCallback) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inlineButtonTypeCallback", + ID: InlineButtonTypeCallbackTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "RequiresPassword", + SchemaName: "requires_password", + Null: !i.Flags.Has(0), + }, + { + Name: "Data", + SchemaName: "data", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (i *InlineButtonTypeCallback) SetFlags() { + if !(i.RequiresPassword == false) { + i.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (i *InlineButtonTypeCallback) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inlineButtonTypeCallback#2955bc38 as nil") + } + b.PutID(InlineButtonTypeCallbackTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InlineButtonTypeCallback) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inlineButtonTypeCallback#2955bc38 as nil") + } + i.SetFlags() + if err := i.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode inlineButtonTypeCallback#2955bc38: field flags: %w", err) + } + b.PutBytes(i.Data) + return nil +} + +// Decode implements bin.Decoder. +func (i *InlineButtonTypeCallback) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inlineButtonTypeCallback#2955bc38 to nil") + } + if err := b.ConsumeID(InlineButtonTypeCallbackTypeID); err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeCallback#2955bc38: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InlineButtonTypeCallback) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inlineButtonTypeCallback#2955bc38 to nil") + } + { + if err := i.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeCallback#2955bc38: field flags: %w", err) + } + } + i.RequiresPassword = i.Flags.Has(0) + { + value, err := b.Bytes() + if err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeCallback#2955bc38: field data: %w", err) + } + i.Data = value + } + return nil +} + +// SetRequiresPassword sets value of RequiresPassword conditional field. +func (i *InlineButtonTypeCallback) SetRequiresPassword(value bool) { + if value { + i.Flags.Set(0) + i.RequiresPassword = true + } else { + i.Flags.Unset(0) + i.RequiresPassword = false + } +} + +// GetRequiresPassword returns value of RequiresPassword conditional field. +func (i *InlineButtonTypeCallback) GetRequiresPassword() (value bool) { + if i == nil { + return + } + return i.Flags.Has(0) +} + +// GetData returns value of Data field. +func (i *InlineButtonTypeCallback) GetData() (value []byte) { + if i == nil { + return + } + return i.Data +} + +// InlineButtonTypeGame represents TL type `inlineButtonTypeGame#5cd3709d`. +// +// See https://core.telegram.org/constructor/inlineButtonTypeGame for reference. +type InlineButtonTypeGame struct { +} + +// InlineButtonTypeGameTypeID is TL type id of InlineButtonTypeGame. +const InlineButtonTypeGameTypeID = 0x5cd3709d + +// construct implements constructor of InlineButtonTypeClass. +func (i InlineButtonTypeGame) construct() InlineButtonTypeClass { return &i } + +// Ensuring interfaces in compile-time for InlineButtonTypeGame. +var ( + _ bin.Encoder = &InlineButtonTypeGame{} + _ bin.Decoder = &InlineButtonTypeGame{} + _ bin.BareEncoder = &InlineButtonTypeGame{} + _ bin.BareDecoder = &InlineButtonTypeGame{} + + _ InlineButtonTypeClass = &InlineButtonTypeGame{} +) + +func (i *InlineButtonTypeGame) Zero() bool { + if i == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (i *InlineButtonTypeGame) String() string { + if i == nil { + return "InlineButtonTypeGame(nil)" + } + type Alias InlineButtonTypeGame + return fmt.Sprintf("InlineButtonTypeGame%+v", Alias(*i)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InlineButtonTypeGame) TypeID() uint32 { + return InlineButtonTypeGameTypeID +} + +// TypeName returns name of type in TL schema. +func (*InlineButtonTypeGame) TypeName() string { + return "inlineButtonTypeGame" +} + +// TypeInfo returns info about TL type. +func (i *InlineButtonTypeGame) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inlineButtonTypeGame", + ID: InlineButtonTypeGameTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (i *InlineButtonTypeGame) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inlineButtonTypeGame#5cd3709d as nil") + } + b.PutID(InlineButtonTypeGameTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InlineButtonTypeGame) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inlineButtonTypeGame#5cd3709d as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (i *InlineButtonTypeGame) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inlineButtonTypeGame#5cd3709d to nil") + } + if err := b.ConsumeID(InlineButtonTypeGameTypeID); err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeGame#5cd3709d: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InlineButtonTypeGame) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inlineButtonTypeGame#5cd3709d to nil") + } + return nil +} + +// InlineButtonTypeBuy represents TL type `inlineButtonTypeBuy#48bad7a5`. +// +// See https://core.telegram.org/constructor/inlineButtonTypeBuy for reference. +type InlineButtonTypeBuy struct { +} + +// InlineButtonTypeBuyTypeID is TL type id of InlineButtonTypeBuy. +const InlineButtonTypeBuyTypeID = 0x48bad7a5 + +// construct implements constructor of InlineButtonTypeClass. +func (i InlineButtonTypeBuy) construct() InlineButtonTypeClass { return &i } + +// Ensuring interfaces in compile-time for InlineButtonTypeBuy. +var ( + _ bin.Encoder = &InlineButtonTypeBuy{} + _ bin.Decoder = &InlineButtonTypeBuy{} + _ bin.BareEncoder = &InlineButtonTypeBuy{} + _ bin.BareDecoder = &InlineButtonTypeBuy{} + + _ InlineButtonTypeClass = &InlineButtonTypeBuy{} +) + +func (i *InlineButtonTypeBuy) Zero() bool { + if i == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (i *InlineButtonTypeBuy) String() string { + if i == nil { + return "InlineButtonTypeBuy(nil)" + } + type Alias InlineButtonTypeBuy + return fmt.Sprintf("InlineButtonTypeBuy%+v", Alias(*i)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InlineButtonTypeBuy) TypeID() uint32 { + return InlineButtonTypeBuyTypeID +} + +// TypeName returns name of type in TL schema. +func (*InlineButtonTypeBuy) TypeName() string { + return "inlineButtonTypeBuy" +} + +// TypeInfo returns info about TL type. +func (i *InlineButtonTypeBuy) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inlineButtonTypeBuy", + ID: InlineButtonTypeBuyTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (i *InlineButtonTypeBuy) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inlineButtonTypeBuy#48bad7a5 as nil") + } + b.PutID(InlineButtonTypeBuyTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InlineButtonTypeBuy) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inlineButtonTypeBuy#48bad7a5 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (i *InlineButtonTypeBuy) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inlineButtonTypeBuy#48bad7a5 to nil") + } + if err := b.ConsumeID(InlineButtonTypeBuyTypeID); err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeBuy#48bad7a5: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InlineButtonTypeBuy) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inlineButtonTypeBuy#48bad7a5 to nil") + } + return nil +} + +// InlineButtonTypeSwitchInline represents TL type `inlineButtonTypeSwitchInline#93773ff5`. +// +// See https://core.telegram.org/constructor/inlineButtonTypeSwitchInline for reference. +type InlineButtonTypeSwitchInline struct { + // Flags field of InlineButtonTypeSwitchInline. + Flags bin.Fields + // SamePeer field of InlineButtonTypeSwitchInline. + SamePeer bool + // Query field of InlineButtonTypeSwitchInline. + Query string + // PeerTypes field of InlineButtonTypeSwitchInline. + // + // Use SetPeerTypes and GetPeerTypes helpers. + PeerTypes []InlineQueryPeerTypeClass +} + +// InlineButtonTypeSwitchInlineTypeID is TL type id of InlineButtonTypeSwitchInline. +const InlineButtonTypeSwitchInlineTypeID = 0x93773ff5 + +// construct implements constructor of InlineButtonTypeClass. +func (i InlineButtonTypeSwitchInline) construct() InlineButtonTypeClass { return &i } + +// Ensuring interfaces in compile-time for InlineButtonTypeSwitchInline. +var ( + _ bin.Encoder = &InlineButtonTypeSwitchInline{} + _ bin.Decoder = &InlineButtonTypeSwitchInline{} + _ bin.BareEncoder = &InlineButtonTypeSwitchInline{} + _ bin.BareDecoder = &InlineButtonTypeSwitchInline{} + + _ InlineButtonTypeClass = &InlineButtonTypeSwitchInline{} +) + +func (i *InlineButtonTypeSwitchInline) Zero() bool { + if i == nil { + return true + } + if !(i.Flags.Zero()) { + return false + } + if !(i.SamePeer == false) { + return false + } + if !(i.Query == "") { + return false + } + if !(i.PeerTypes == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InlineButtonTypeSwitchInline) String() string { + if i == nil { + return "InlineButtonTypeSwitchInline(nil)" + } + type Alias InlineButtonTypeSwitchInline + return fmt.Sprintf("InlineButtonTypeSwitchInline%+v", Alias(*i)) +} + +// FillFrom fills InlineButtonTypeSwitchInline from given interface. +func (i *InlineButtonTypeSwitchInline) FillFrom(from interface { + GetSamePeer() (value bool) + GetQuery() (value string) + GetPeerTypes() (value []InlineQueryPeerTypeClass, ok bool) +}) { + i.SamePeer = from.GetSamePeer() + i.Query = from.GetQuery() + if val, ok := from.GetPeerTypes(); ok { + i.PeerTypes = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InlineButtonTypeSwitchInline) TypeID() uint32 { + return InlineButtonTypeSwitchInlineTypeID +} + +// TypeName returns name of type in TL schema. +func (*InlineButtonTypeSwitchInline) TypeName() string { + return "inlineButtonTypeSwitchInline" +} + +// TypeInfo returns info about TL type. +func (i *InlineButtonTypeSwitchInline) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inlineButtonTypeSwitchInline", + ID: InlineButtonTypeSwitchInlineTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "SamePeer", + SchemaName: "same_peer", + Null: !i.Flags.Has(0), + }, + { + Name: "Query", + SchemaName: "query", + }, + { + Name: "PeerTypes", + SchemaName: "peer_types", + Null: !i.Flags.Has(1), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (i *InlineButtonTypeSwitchInline) SetFlags() { + if !(i.SamePeer == false) { + i.Flags.Set(0) + } + if !(i.PeerTypes == nil) { + i.Flags.Set(1) + } +} + +// Encode implements bin.Encoder. +func (i *InlineButtonTypeSwitchInline) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inlineButtonTypeSwitchInline#93773ff5 as nil") + } + b.PutID(InlineButtonTypeSwitchInlineTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InlineButtonTypeSwitchInline) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inlineButtonTypeSwitchInline#93773ff5 as nil") + } + i.SetFlags() + if err := i.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode inlineButtonTypeSwitchInline#93773ff5: field flags: %w", err) + } + b.PutString(i.Query) + if i.Flags.Has(1) { + b.PutVectorHeader(len(i.PeerTypes)) + for idx, v := range i.PeerTypes { + if v == nil { + return fmt.Errorf("unable to encode inlineButtonTypeSwitchInline#93773ff5: field peer_types element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode inlineButtonTypeSwitchInline#93773ff5: field peer_types element with index %d: %w", idx, err) + } + } + } + return nil +} + +// Decode implements bin.Decoder. +func (i *InlineButtonTypeSwitchInline) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inlineButtonTypeSwitchInline#93773ff5 to nil") + } + if err := b.ConsumeID(InlineButtonTypeSwitchInlineTypeID); err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeSwitchInline#93773ff5: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InlineButtonTypeSwitchInline) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inlineButtonTypeSwitchInline#93773ff5 to nil") + } + { + if err := i.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeSwitchInline#93773ff5: field flags: %w", err) + } + } + i.SamePeer = i.Flags.Has(0) + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeSwitchInline#93773ff5: field query: %w", err) + } + i.Query = value + } + if i.Flags.Has(1) { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeSwitchInline#93773ff5: field peer_types: %w", err) + } + + if headerLen > 0 { + i.PeerTypes = make([]InlineQueryPeerTypeClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeInlineQueryPeerType(b) + if err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeSwitchInline#93773ff5: field peer_types: %w", err) + } + i.PeerTypes = append(i.PeerTypes, value) + } + } + return nil +} + +// SetSamePeer sets value of SamePeer conditional field. +func (i *InlineButtonTypeSwitchInline) SetSamePeer(value bool) { + if value { + i.Flags.Set(0) + i.SamePeer = true + } else { + i.Flags.Unset(0) + i.SamePeer = false + } +} + +// GetSamePeer returns value of SamePeer conditional field. +func (i *InlineButtonTypeSwitchInline) GetSamePeer() (value bool) { + if i == nil { + return + } + return i.Flags.Has(0) +} + +// GetQuery returns value of Query field. +func (i *InlineButtonTypeSwitchInline) GetQuery() (value string) { + if i == nil { + return + } + return i.Query +} + +// SetPeerTypes sets value of PeerTypes conditional field. +func (i *InlineButtonTypeSwitchInline) SetPeerTypes(value []InlineQueryPeerTypeClass) { + i.Flags.Set(1) + i.PeerTypes = value +} + +// GetPeerTypes returns value of PeerTypes conditional field and +// boolean which is true if field was set. +func (i *InlineButtonTypeSwitchInline) GetPeerTypes() (value []InlineQueryPeerTypeClass, ok bool) { + if i == nil { + return + } + if !i.Flags.Has(1) { + return value, false + } + return i.PeerTypes, true +} + +// MapPeerTypes returns field PeerTypes wrapped in InlineQueryPeerTypeClassArray helper. +func (i *InlineButtonTypeSwitchInline) MapPeerTypes() (value InlineQueryPeerTypeClassArray, ok bool) { + if !i.Flags.Has(1) { + return value, false + } + return InlineQueryPeerTypeClassArray(i.PeerTypes), true +} + +// InlineButtonTypeUserProfile represents TL type `inlineButtonTypeUserProfile#3fa33fcf`. +// +// See https://core.telegram.org/constructor/inlineButtonTypeUserProfile for reference. +type InlineButtonTypeUserProfile struct { + // UserID field of InlineButtonTypeUserProfile. + UserID int64 +} + +// InlineButtonTypeUserProfileTypeID is TL type id of InlineButtonTypeUserProfile. +const InlineButtonTypeUserProfileTypeID = 0x3fa33fcf + +// construct implements constructor of InlineButtonTypeClass. +func (i InlineButtonTypeUserProfile) construct() InlineButtonTypeClass { return &i } + +// Ensuring interfaces in compile-time for InlineButtonTypeUserProfile. +var ( + _ bin.Encoder = &InlineButtonTypeUserProfile{} + _ bin.Decoder = &InlineButtonTypeUserProfile{} + _ bin.BareEncoder = &InlineButtonTypeUserProfile{} + _ bin.BareDecoder = &InlineButtonTypeUserProfile{} + + _ InlineButtonTypeClass = &InlineButtonTypeUserProfile{} +) + +func (i *InlineButtonTypeUserProfile) Zero() bool { + if i == nil { + return true + } + if !(i.UserID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InlineButtonTypeUserProfile) String() string { + if i == nil { + return "InlineButtonTypeUserProfile(nil)" + } + type Alias InlineButtonTypeUserProfile + return fmt.Sprintf("InlineButtonTypeUserProfile%+v", Alias(*i)) +} + +// FillFrom fills InlineButtonTypeUserProfile from given interface. +func (i *InlineButtonTypeUserProfile) FillFrom(from interface { + GetUserID() (value int64) +}) { + i.UserID = from.GetUserID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InlineButtonTypeUserProfile) TypeID() uint32 { + return InlineButtonTypeUserProfileTypeID +} + +// TypeName returns name of type in TL schema. +func (*InlineButtonTypeUserProfile) TypeName() string { + return "inlineButtonTypeUserProfile" +} + +// TypeInfo returns info about TL type. +func (i *InlineButtonTypeUserProfile) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inlineButtonTypeUserProfile", + ID: InlineButtonTypeUserProfileTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (i *InlineButtonTypeUserProfile) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inlineButtonTypeUserProfile#3fa33fcf as nil") + } + b.PutID(InlineButtonTypeUserProfileTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InlineButtonTypeUserProfile) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inlineButtonTypeUserProfile#3fa33fcf as nil") + } + b.PutLong(i.UserID) + return nil +} + +// Decode implements bin.Decoder. +func (i *InlineButtonTypeUserProfile) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inlineButtonTypeUserProfile#3fa33fcf to nil") + } + if err := b.ConsumeID(InlineButtonTypeUserProfileTypeID); err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeUserProfile#3fa33fcf: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InlineButtonTypeUserProfile) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inlineButtonTypeUserProfile#3fa33fcf to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeUserProfile#3fa33fcf: field user_id: %w", err) + } + i.UserID = value + } + return nil +} + +// GetUserID returns value of UserID field. +func (i *InlineButtonTypeUserProfile) GetUserID() (value int64) { + if i == nil { + return + } + return i.UserID +} + +// InputInlineButtonTypeUserProfile represents TL type `inputInlineButtonTypeUserProfile#53f3ce5a`. +// +// See https://core.telegram.org/constructor/inputInlineButtonTypeUserProfile for reference. +type InputInlineButtonTypeUserProfile struct { + // UserID field of InputInlineButtonTypeUserProfile. + UserID InputUserClass +} + +// InputInlineButtonTypeUserProfileTypeID is TL type id of InputInlineButtonTypeUserProfile. +const InputInlineButtonTypeUserProfileTypeID = 0x53f3ce5a + +// construct implements constructor of InlineButtonTypeClass. +func (i InputInlineButtonTypeUserProfile) construct() InlineButtonTypeClass { return &i } + +// Ensuring interfaces in compile-time for InputInlineButtonTypeUserProfile. +var ( + _ bin.Encoder = &InputInlineButtonTypeUserProfile{} + _ bin.Decoder = &InputInlineButtonTypeUserProfile{} + _ bin.BareEncoder = &InputInlineButtonTypeUserProfile{} + _ bin.BareDecoder = &InputInlineButtonTypeUserProfile{} + + _ InlineButtonTypeClass = &InputInlineButtonTypeUserProfile{} +) + +func (i *InputInlineButtonTypeUserProfile) Zero() bool { + if i == nil { + return true + } + if !(i.UserID == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InputInlineButtonTypeUserProfile) String() string { + if i == nil { + return "InputInlineButtonTypeUserProfile(nil)" + } + type Alias InputInlineButtonTypeUserProfile + return fmt.Sprintf("InputInlineButtonTypeUserProfile%+v", Alias(*i)) +} + +// FillFrom fills InputInlineButtonTypeUserProfile from given interface. +func (i *InputInlineButtonTypeUserProfile) FillFrom(from interface { + GetUserID() (value InputUserClass) +}) { + i.UserID = from.GetUserID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InputInlineButtonTypeUserProfile) TypeID() uint32 { + return InputInlineButtonTypeUserProfileTypeID +} + +// TypeName returns name of type in TL schema. +func (*InputInlineButtonTypeUserProfile) TypeName() string { + return "inputInlineButtonTypeUserProfile" +} + +// TypeInfo returns info about TL type. +func (i *InputInlineButtonTypeUserProfile) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inputInlineButtonTypeUserProfile", + ID: InputInlineButtonTypeUserProfileTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (i *InputInlineButtonTypeUserProfile) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputInlineButtonTypeUserProfile#53f3ce5a as nil") + } + b.PutID(InputInlineButtonTypeUserProfileTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InputInlineButtonTypeUserProfile) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inputInlineButtonTypeUserProfile#53f3ce5a as nil") + } + if i.UserID == nil { + return fmt.Errorf("unable to encode inputInlineButtonTypeUserProfile#53f3ce5a: field user_id is nil") + } + if err := i.UserID.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputInlineButtonTypeUserProfile#53f3ce5a: field user_id: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (i *InputInlineButtonTypeUserProfile) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputInlineButtonTypeUserProfile#53f3ce5a to nil") + } + if err := b.ConsumeID(InputInlineButtonTypeUserProfileTypeID); err != nil { + return fmt.Errorf("unable to decode inputInlineButtonTypeUserProfile#53f3ce5a: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InputInlineButtonTypeUserProfile) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inputInlineButtonTypeUserProfile#53f3ce5a to nil") + } + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode inputInlineButtonTypeUserProfile#53f3ce5a: field user_id: %w", err) + } + i.UserID = value + } + return nil +} + +// GetUserID returns value of UserID field. +func (i *InputInlineButtonTypeUserProfile) GetUserID() (value InputUserClass) { + if i == nil { + return + } + return i.UserID +} + +// InlineButtonTypeCopy represents TL type `inlineButtonTypeCopy#b41d3272`. +// +// See https://core.telegram.org/constructor/inlineButtonTypeCopy for reference. +type InlineButtonTypeCopy struct { + // CopyText field of InlineButtonTypeCopy. + CopyText string +} + +// InlineButtonTypeCopyTypeID is TL type id of InlineButtonTypeCopy. +const InlineButtonTypeCopyTypeID = 0xb41d3272 + +// construct implements constructor of InlineButtonTypeClass. +func (i InlineButtonTypeCopy) construct() InlineButtonTypeClass { return &i } + +// Ensuring interfaces in compile-time for InlineButtonTypeCopy. +var ( + _ bin.Encoder = &InlineButtonTypeCopy{} + _ bin.Decoder = &InlineButtonTypeCopy{} + _ bin.BareEncoder = &InlineButtonTypeCopy{} + _ bin.BareDecoder = &InlineButtonTypeCopy{} + + _ InlineButtonTypeClass = &InlineButtonTypeCopy{} +) + +func (i *InlineButtonTypeCopy) Zero() bool { + if i == nil { + return true + } + if !(i.CopyText == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InlineButtonTypeCopy) String() string { + if i == nil { + return "InlineButtonTypeCopy(nil)" + } + type Alias InlineButtonTypeCopy + return fmt.Sprintf("InlineButtonTypeCopy%+v", Alias(*i)) +} + +// FillFrom fills InlineButtonTypeCopy from given interface. +func (i *InlineButtonTypeCopy) FillFrom(from interface { + GetCopyText() (value string) +}) { + i.CopyText = from.GetCopyText() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InlineButtonTypeCopy) TypeID() uint32 { + return InlineButtonTypeCopyTypeID +} + +// TypeName returns name of type in TL schema. +func (*InlineButtonTypeCopy) TypeName() string { + return "inlineButtonTypeCopy" +} + +// TypeInfo returns info about TL type. +func (i *InlineButtonTypeCopy) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inlineButtonTypeCopy", + ID: InlineButtonTypeCopyTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "CopyText", + SchemaName: "copy_text", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (i *InlineButtonTypeCopy) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inlineButtonTypeCopy#b41d3272 as nil") + } + b.PutID(InlineButtonTypeCopyTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InlineButtonTypeCopy) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inlineButtonTypeCopy#b41d3272 as nil") + } + b.PutString(i.CopyText) + return nil +} + +// Decode implements bin.Decoder. +func (i *InlineButtonTypeCopy) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inlineButtonTypeCopy#b41d3272 to nil") + } + if err := b.ConsumeID(InlineButtonTypeCopyTypeID); err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeCopy#b41d3272: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InlineButtonTypeCopy) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inlineButtonTypeCopy#b41d3272 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeCopy#b41d3272: field copy_text: %w", err) + } + i.CopyText = value + } + return nil +} + +// GetCopyText returns value of CopyText field. +func (i *InlineButtonTypeCopy) GetCopyText() (value string) { + if i == nil { + return + } + return i.CopyText +} + +// InlineButtonTypeDisabled represents TL type `inlineButtonTypeDisabled#a438619d`. +// +// See https://core.telegram.org/constructor/inlineButtonTypeDisabled for reference. +type InlineButtonTypeDisabled struct { +} + +// InlineButtonTypeDisabledTypeID is TL type id of InlineButtonTypeDisabled. +const InlineButtonTypeDisabledTypeID = 0xa438619d + +// construct implements constructor of InlineButtonTypeClass. +func (i InlineButtonTypeDisabled) construct() InlineButtonTypeClass { return &i } + +// Ensuring interfaces in compile-time for InlineButtonTypeDisabled. +var ( + _ bin.Encoder = &InlineButtonTypeDisabled{} + _ bin.Decoder = &InlineButtonTypeDisabled{} + _ bin.BareEncoder = &InlineButtonTypeDisabled{} + _ bin.BareDecoder = &InlineButtonTypeDisabled{} + + _ InlineButtonTypeClass = &InlineButtonTypeDisabled{} +) + +func (i *InlineButtonTypeDisabled) Zero() bool { + if i == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (i *InlineButtonTypeDisabled) String() string { + if i == nil { + return "InlineButtonTypeDisabled(nil)" + } + type Alias InlineButtonTypeDisabled + return fmt.Sprintf("InlineButtonTypeDisabled%+v", Alias(*i)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InlineButtonTypeDisabled) TypeID() uint32 { + return InlineButtonTypeDisabledTypeID +} + +// TypeName returns name of type in TL schema. +func (*InlineButtonTypeDisabled) TypeName() string { + return "inlineButtonTypeDisabled" +} + +// TypeInfo returns info about TL type. +func (i *InlineButtonTypeDisabled) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inlineButtonTypeDisabled", + ID: InlineButtonTypeDisabledTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (i *InlineButtonTypeDisabled) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inlineButtonTypeDisabled#a438619d as nil") + } + b.PutID(InlineButtonTypeDisabledTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InlineButtonTypeDisabled) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inlineButtonTypeDisabled#a438619d as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (i *InlineButtonTypeDisabled) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inlineButtonTypeDisabled#a438619d to nil") + } + if err := b.ConsumeID(InlineButtonTypeDisabledTypeID); err != nil { + return fmt.Errorf("unable to decode inlineButtonTypeDisabled#a438619d: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InlineButtonTypeDisabled) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inlineButtonTypeDisabled#a438619d to nil") + } + return nil +} + +// InlineButtonTypeClassName is schema name of InlineButtonTypeClass. +const InlineButtonTypeClassName = "InlineButtonType" + +// InlineButtonTypeClass represents InlineButtonType generic type. +// +// See https://core.telegram.org/type/InlineButtonType for reference. +// +// Constructors: +// - [InlineButtonTypeURL] +// - [InlineButtonTypeURLAuth] +// - [InputInlineButtonTypeURLAuth] +// - [InlineButtonTypeWebView] +// - [InlineButtonTypeCallback] +// - [InlineButtonTypeGame] +// - [InlineButtonTypeBuy] +// - [InlineButtonTypeSwitchInline] +// - [InlineButtonTypeUserProfile] +// - [InputInlineButtonTypeUserProfile] +// - [InlineButtonTypeCopy] +// - [InlineButtonTypeDisabled] +// +// Example: +// +// g, err := tg.DecodeInlineButtonType(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.InlineButtonTypeURL: // inlineButtonTypeUrl#eca4f8d4 +// case *tg.InlineButtonTypeURLAuth: // inlineButtonTypeUrlAuth#bfd02da2 +// case *tg.InputInlineButtonTypeURLAuth: // inputInlineButtonTypeUrlAuth#9961bcb4 +// case *tg.InlineButtonTypeWebView: // inlineButtonTypeWebView#3bcab5b4 +// case *tg.InlineButtonTypeCallback: // inlineButtonTypeCallback#2955bc38 +// case *tg.InlineButtonTypeGame: // inlineButtonTypeGame#5cd3709d +// case *tg.InlineButtonTypeBuy: // inlineButtonTypeBuy#48bad7a5 +// case *tg.InlineButtonTypeSwitchInline: // inlineButtonTypeSwitchInline#93773ff5 +// case *tg.InlineButtonTypeUserProfile: // inlineButtonTypeUserProfile#3fa33fcf +// case *tg.InputInlineButtonTypeUserProfile: // inputInlineButtonTypeUserProfile#53f3ce5a +// case *tg.InlineButtonTypeCopy: // inlineButtonTypeCopy#b41d3272 +// case *tg.InlineButtonTypeDisabled: // inlineButtonTypeDisabled#a438619d +// default: panic(v) +// } +type InlineButtonTypeClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() InlineButtonTypeClass + + // TypeID returns type id in TL schema. + // + // See https://core.telegram.org/mtproto/TL-tl#remarks. + TypeID() uint32 + // TypeName returns name of type in TL schema. + TypeName() string + // String implements fmt.Stringer. + String() string + // Zero returns true if current object has a zero value. + Zero() bool +} + +// DecodeInlineButtonType implements binary de-serialization for InlineButtonTypeClass. +func DecodeInlineButtonType(buf *bin.Buffer) (InlineButtonTypeClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case InlineButtonTypeURLTypeID: + // Decoding inlineButtonTypeUrl#eca4f8d4. + v := InlineButtonTypeURL{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InlineButtonTypeClass: %w", err) + } + return &v, nil + case InlineButtonTypeURLAuthTypeID: + // Decoding inlineButtonTypeUrlAuth#bfd02da2. + v := InlineButtonTypeURLAuth{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InlineButtonTypeClass: %w", err) + } + return &v, nil + case InputInlineButtonTypeURLAuthTypeID: + // Decoding inputInlineButtonTypeUrlAuth#9961bcb4. + v := InputInlineButtonTypeURLAuth{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InlineButtonTypeClass: %w", err) + } + return &v, nil + case InlineButtonTypeWebViewTypeID: + // Decoding inlineButtonTypeWebView#3bcab5b4. + v := InlineButtonTypeWebView{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InlineButtonTypeClass: %w", err) + } + return &v, nil + case InlineButtonTypeCallbackTypeID: + // Decoding inlineButtonTypeCallback#2955bc38. + v := InlineButtonTypeCallback{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InlineButtonTypeClass: %w", err) + } + return &v, nil + case InlineButtonTypeGameTypeID: + // Decoding inlineButtonTypeGame#5cd3709d. + v := InlineButtonTypeGame{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InlineButtonTypeClass: %w", err) + } + return &v, nil + case InlineButtonTypeBuyTypeID: + // Decoding inlineButtonTypeBuy#48bad7a5. + v := InlineButtonTypeBuy{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InlineButtonTypeClass: %w", err) + } + return &v, nil + case InlineButtonTypeSwitchInlineTypeID: + // Decoding inlineButtonTypeSwitchInline#93773ff5. + v := InlineButtonTypeSwitchInline{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InlineButtonTypeClass: %w", err) + } + return &v, nil + case InlineButtonTypeUserProfileTypeID: + // Decoding inlineButtonTypeUserProfile#3fa33fcf. + v := InlineButtonTypeUserProfile{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InlineButtonTypeClass: %w", err) + } + return &v, nil + case InputInlineButtonTypeUserProfileTypeID: + // Decoding inputInlineButtonTypeUserProfile#53f3ce5a. + v := InputInlineButtonTypeUserProfile{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InlineButtonTypeClass: %w", err) + } + return &v, nil + case InlineButtonTypeCopyTypeID: + // Decoding inlineButtonTypeCopy#b41d3272. + v := InlineButtonTypeCopy{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InlineButtonTypeClass: %w", err) + } + return &v, nil + case InlineButtonTypeDisabledTypeID: + // Decoding inlineButtonTypeDisabled#a438619d. + v := InlineButtonTypeDisabled{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InlineButtonTypeClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode InlineButtonTypeClass: %w", bin.NewUnexpectedID(id)) + } +} + +// InlineButtonType boxes the InlineButtonTypeClass providing a helper. +type InlineButtonTypeBox struct { + InlineButtonType InlineButtonTypeClass +} + +// Decode implements bin.Decoder for InlineButtonTypeBox. +func (b *InlineButtonTypeBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode InlineButtonTypeBox to nil") + } + v, err := DecodeInlineButtonType(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.InlineButtonType = v + return nil +} + +// Encode implements bin.Encode for InlineButtonTypeBox. +func (b *InlineButtonTypeBox) Encode(buf *bin.Buffer) error { + if b == nil || b.InlineButtonType == nil { + return fmt.Errorf("unable to encode InlineButtonTypeClass as nil") + } + return b.InlineButtonType.Encode(buf) +} diff --git a/tg/tl_inline_button_type_slices_gen.go b/tg/tl_inline_button_type_slices_gen.go new file mode 100644 index 0000000000..c0921f531f --- /dev/null +++ b/tg/tl_inline_button_type_slices_gen.go @@ -0,0 +1,972 @@ +//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{} +) + +// InlineButtonTypeClassArray is adapter for slice of InlineButtonTypeClass. +type InlineButtonTypeClassArray []InlineButtonTypeClass + +// Sort sorts slice of InlineButtonTypeClass. +func (s InlineButtonTypeClassArray) Sort(less func(a, b InlineButtonTypeClass) bool) InlineButtonTypeClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of InlineButtonTypeClass. +func (s InlineButtonTypeClassArray) SortStable(less func(a, b InlineButtonTypeClass) bool) InlineButtonTypeClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of InlineButtonTypeClass. +func (s InlineButtonTypeClassArray) Retain(keep func(x InlineButtonTypeClass) bool) InlineButtonTypeClassArray { + 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 InlineButtonTypeClassArray) First() (v InlineButtonTypeClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s InlineButtonTypeClassArray) Last() (v InlineButtonTypeClass, 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 *InlineButtonTypeClassArray) PopFirst() (v InlineButtonTypeClass, 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 InlineButtonTypeClass + 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 *InlineButtonTypeClassArray) Pop() (v InlineButtonTypeClass, 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 +} + +// AsInlineButtonTypeURL returns copy with only InlineButtonTypeURL constructors. +func (s InlineButtonTypeClassArray) AsInlineButtonTypeURL() (to InlineButtonTypeURLArray) { + for _, elem := range s { + value, ok := elem.(*InlineButtonTypeURL) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsInlineButtonTypeURLAuth returns copy with only InlineButtonTypeURLAuth constructors. +func (s InlineButtonTypeClassArray) AsInlineButtonTypeURLAuth() (to InlineButtonTypeURLAuthArray) { + for _, elem := range s { + value, ok := elem.(*InlineButtonTypeURLAuth) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsInputInlineButtonTypeURLAuth returns copy with only InputInlineButtonTypeURLAuth constructors. +func (s InlineButtonTypeClassArray) AsInputInlineButtonTypeURLAuth() (to InputInlineButtonTypeURLAuthArray) { + for _, elem := range s { + value, ok := elem.(*InputInlineButtonTypeURLAuth) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsInlineButtonTypeWebView returns copy with only InlineButtonTypeWebView constructors. +func (s InlineButtonTypeClassArray) AsInlineButtonTypeWebView() (to InlineButtonTypeWebViewArray) { + for _, elem := range s { + value, ok := elem.(*InlineButtonTypeWebView) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsInlineButtonTypeCallback returns copy with only InlineButtonTypeCallback constructors. +func (s InlineButtonTypeClassArray) AsInlineButtonTypeCallback() (to InlineButtonTypeCallbackArray) { + for _, elem := range s { + value, ok := elem.(*InlineButtonTypeCallback) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsInlineButtonTypeSwitchInline returns copy with only InlineButtonTypeSwitchInline constructors. +func (s InlineButtonTypeClassArray) AsInlineButtonTypeSwitchInline() (to InlineButtonTypeSwitchInlineArray) { + for _, elem := range s { + value, ok := elem.(*InlineButtonTypeSwitchInline) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsInlineButtonTypeUserProfile returns copy with only InlineButtonTypeUserProfile constructors. +func (s InlineButtonTypeClassArray) AsInlineButtonTypeUserProfile() (to InlineButtonTypeUserProfileArray) { + for _, elem := range s { + value, ok := elem.(*InlineButtonTypeUserProfile) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsInputInlineButtonTypeUserProfile returns copy with only InputInlineButtonTypeUserProfile constructors. +func (s InlineButtonTypeClassArray) AsInputInlineButtonTypeUserProfile() (to InputInlineButtonTypeUserProfileArray) { + for _, elem := range s { + value, ok := elem.(*InputInlineButtonTypeUserProfile) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsInlineButtonTypeCopy returns copy with only InlineButtonTypeCopy constructors. +func (s InlineButtonTypeClassArray) AsInlineButtonTypeCopy() (to InlineButtonTypeCopyArray) { + for _, elem := range s { + value, ok := elem.(*InlineButtonTypeCopy) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// InlineButtonTypeURLArray is adapter for slice of InlineButtonTypeURL. +type InlineButtonTypeURLArray []InlineButtonTypeURL + +// Sort sorts slice of InlineButtonTypeURL. +func (s InlineButtonTypeURLArray) Sort(less func(a, b InlineButtonTypeURL) bool) InlineButtonTypeURLArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of InlineButtonTypeURL. +func (s InlineButtonTypeURLArray) SortStable(less func(a, b InlineButtonTypeURL) bool) InlineButtonTypeURLArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of InlineButtonTypeURL. +func (s InlineButtonTypeURLArray) Retain(keep func(x InlineButtonTypeURL) bool) InlineButtonTypeURLArray { + 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 InlineButtonTypeURLArray) First() (v InlineButtonTypeURL, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s InlineButtonTypeURLArray) Last() (v InlineButtonTypeURL, 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 *InlineButtonTypeURLArray) PopFirst() (v InlineButtonTypeURL, 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 InlineButtonTypeURL + 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 *InlineButtonTypeURLArray) Pop() (v InlineButtonTypeURL, 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 +} + +// InlineButtonTypeURLAuthArray is adapter for slice of InlineButtonTypeURLAuth. +type InlineButtonTypeURLAuthArray []InlineButtonTypeURLAuth + +// Sort sorts slice of InlineButtonTypeURLAuth. +func (s InlineButtonTypeURLAuthArray) Sort(less func(a, b InlineButtonTypeURLAuth) bool) InlineButtonTypeURLAuthArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of InlineButtonTypeURLAuth. +func (s InlineButtonTypeURLAuthArray) SortStable(less func(a, b InlineButtonTypeURLAuth) bool) InlineButtonTypeURLAuthArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of InlineButtonTypeURLAuth. +func (s InlineButtonTypeURLAuthArray) Retain(keep func(x InlineButtonTypeURLAuth) bool) InlineButtonTypeURLAuthArray { + 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 InlineButtonTypeURLAuthArray) First() (v InlineButtonTypeURLAuth, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s InlineButtonTypeURLAuthArray) Last() (v InlineButtonTypeURLAuth, 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 *InlineButtonTypeURLAuthArray) PopFirst() (v InlineButtonTypeURLAuth, 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 InlineButtonTypeURLAuth + 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 *InlineButtonTypeURLAuthArray) Pop() (v InlineButtonTypeURLAuth, 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 +} + +// InputInlineButtonTypeURLAuthArray is adapter for slice of InputInlineButtonTypeURLAuth. +type InputInlineButtonTypeURLAuthArray []InputInlineButtonTypeURLAuth + +// Sort sorts slice of InputInlineButtonTypeURLAuth. +func (s InputInlineButtonTypeURLAuthArray) Sort(less func(a, b InputInlineButtonTypeURLAuth) bool) InputInlineButtonTypeURLAuthArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of InputInlineButtonTypeURLAuth. +func (s InputInlineButtonTypeURLAuthArray) SortStable(less func(a, b InputInlineButtonTypeURLAuth) bool) InputInlineButtonTypeURLAuthArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of InputInlineButtonTypeURLAuth. +func (s InputInlineButtonTypeURLAuthArray) Retain(keep func(x InputInlineButtonTypeURLAuth) bool) InputInlineButtonTypeURLAuthArray { + 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 InputInlineButtonTypeURLAuthArray) First() (v InputInlineButtonTypeURLAuth, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s InputInlineButtonTypeURLAuthArray) Last() (v InputInlineButtonTypeURLAuth, 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 *InputInlineButtonTypeURLAuthArray) PopFirst() (v InputInlineButtonTypeURLAuth, 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 InputInlineButtonTypeURLAuth + 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 *InputInlineButtonTypeURLAuthArray) Pop() (v InputInlineButtonTypeURLAuth, 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 +} + +// InlineButtonTypeWebViewArray is adapter for slice of InlineButtonTypeWebView. +type InlineButtonTypeWebViewArray []InlineButtonTypeWebView + +// Sort sorts slice of InlineButtonTypeWebView. +func (s InlineButtonTypeWebViewArray) Sort(less func(a, b InlineButtonTypeWebView) bool) InlineButtonTypeWebViewArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of InlineButtonTypeWebView. +func (s InlineButtonTypeWebViewArray) SortStable(less func(a, b InlineButtonTypeWebView) bool) InlineButtonTypeWebViewArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of InlineButtonTypeWebView. +func (s InlineButtonTypeWebViewArray) Retain(keep func(x InlineButtonTypeWebView) bool) InlineButtonTypeWebViewArray { + 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 InlineButtonTypeWebViewArray) First() (v InlineButtonTypeWebView, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s InlineButtonTypeWebViewArray) Last() (v InlineButtonTypeWebView, 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 *InlineButtonTypeWebViewArray) PopFirst() (v InlineButtonTypeWebView, 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 InlineButtonTypeWebView + 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 *InlineButtonTypeWebViewArray) Pop() (v InlineButtonTypeWebView, 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 +} + +// InlineButtonTypeCallbackArray is adapter for slice of InlineButtonTypeCallback. +type InlineButtonTypeCallbackArray []InlineButtonTypeCallback + +// Sort sorts slice of InlineButtonTypeCallback. +func (s InlineButtonTypeCallbackArray) Sort(less func(a, b InlineButtonTypeCallback) bool) InlineButtonTypeCallbackArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of InlineButtonTypeCallback. +func (s InlineButtonTypeCallbackArray) SortStable(less func(a, b InlineButtonTypeCallback) bool) InlineButtonTypeCallbackArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of InlineButtonTypeCallback. +func (s InlineButtonTypeCallbackArray) Retain(keep func(x InlineButtonTypeCallback) bool) InlineButtonTypeCallbackArray { + 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 InlineButtonTypeCallbackArray) First() (v InlineButtonTypeCallback, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s InlineButtonTypeCallbackArray) Last() (v InlineButtonTypeCallback, 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 *InlineButtonTypeCallbackArray) PopFirst() (v InlineButtonTypeCallback, 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 InlineButtonTypeCallback + 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 *InlineButtonTypeCallbackArray) Pop() (v InlineButtonTypeCallback, 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 +} + +// InlineButtonTypeSwitchInlineArray is adapter for slice of InlineButtonTypeSwitchInline. +type InlineButtonTypeSwitchInlineArray []InlineButtonTypeSwitchInline + +// Sort sorts slice of InlineButtonTypeSwitchInline. +func (s InlineButtonTypeSwitchInlineArray) Sort(less func(a, b InlineButtonTypeSwitchInline) bool) InlineButtonTypeSwitchInlineArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of InlineButtonTypeSwitchInline. +func (s InlineButtonTypeSwitchInlineArray) SortStable(less func(a, b InlineButtonTypeSwitchInline) bool) InlineButtonTypeSwitchInlineArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of InlineButtonTypeSwitchInline. +func (s InlineButtonTypeSwitchInlineArray) Retain(keep func(x InlineButtonTypeSwitchInline) bool) InlineButtonTypeSwitchInlineArray { + 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 InlineButtonTypeSwitchInlineArray) First() (v InlineButtonTypeSwitchInline, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s InlineButtonTypeSwitchInlineArray) Last() (v InlineButtonTypeSwitchInline, 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 *InlineButtonTypeSwitchInlineArray) PopFirst() (v InlineButtonTypeSwitchInline, 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 InlineButtonTypeSwitchInline + 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 *InlineButtonTypeSwitchInlineArray) Pop() (v InlineButtonTypeSwitchInline, 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 +} + +// InlineButtonTypeUserProfileArray is adapter for slice of InlineButtonTypeUserProfile. +type InlineButtonTypeUserProfileArray []InlineButtonTypeUserProfile + +// Sort sorts slice of InlineButtonTypeUserProfile. +func (s InlineButtonTypeUserProfileArray) Sort(less func(a, b InlineButtonTypeUserProfile) bool) InlineButtonTypeUserProfileArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of InlineButtonTypeUserProfile. +func (s InlineButtonTypeUserProfileArray) SortStable(less func(a, b InlineButtonTypeUserProfile) bool) InlineButtonTypeUserProfileArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of InlineButtonTypeUserProfile. +func (s InlineButtonTypeUserProfileArray) Retain(keep func(x InlineButtonTypeUserProfile) bool) InlineButtonTypeUserProfileArray { + 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 InlineButtonTypeUserProfileArray) First() (v InlineButtonTypeUserProfile, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s InlineButtonTypeUserProfileArray) Last() (v InlineButtonTypeUserProfile, 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 *InlineButtonTypeUserProfileArray) PopFirst() (v InlineButtonTypeUserProfile, 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 InlineButtonTypeUserProfile + 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 *InlineButtonTypeUserProfileArray) Pop() (v InlineButtonTypeUserProfile, 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 +} + +// InputInlineButtonTypeUserProfileArray is adapter for slice of InputInlineButtonTypeUserProfile. +type InputInlineButtonTypeUserProfileArray []InputInlineButtonTypeUserProfile + +// Sort sorts slice of InputInlineButtonTypeUserProfile. +func (s InputInlineButtonTypeUserProfileArray) Sort(less func(a, b InputInlineButtonTypeUserProfile) bool) InputInlineButtonTypeUserProfileArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of InputInlineButtonTypeUserProfile. +func (s InputInlineButtonTypeUserProfileArray) SortStable(less func(a, b InputInlineButtonTypeUserProfile) bool) InputInlineButtonTypeUserProfileArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of InputInlineButtonTypeUserProfile. +func (s InputInlineButtonTypeUserProfileArray) Retain(keep func(x InputInlineButtonTypeUserProfile) bool) InputInlineButtonTypeUserProfileArray { + 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 InputInlineButtonTypeUserProfileArray) First() (v InputInlineButtonTypeUserProfile, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s InputInlineButtonTypeUserProfileArray) Last() (v InputInlineButtonTypeUserProfile, 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 *InputInlineButtonTypeUserProfileArray) PopFirst() (v InputInlineButtonTypeUserProfile, 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 InputInlineButtonTypeUserProfile + 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 *InputInlineButtonTypeUserProfileArray) Pop() (v InputInlineButtonTypeUserProfile, 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 +} + +// InlineButtonTypeCopyArray is adapter for slice of InlineButtonTypeCopy. +type InlineButtonTypeCopyArray []InlineButtonTypeCopy + +// Sort sorts slice of InlineButtonTypeCopy. +func (s InlineButtonTypeCopyArray) Sort(less func(a, b InlineButtonTypeCopy) bool) InlineButtonTypeCopyArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of InlineButtonTypeCopy. +func (s InlineButtonTypeCopyArray) SortStable(less func(a, b InlineButtonTypeCopy) bool) InlineButtonTypeCopyArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of InlineButtonTypeCopy. +func (s InlineButtonTypeCopyArray) Retain(keep func(x InlineButtonTypeCopy) bool) InlineButtonTypeCopyArray { + 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 InlineButtonTypeCopyArray) First() (v InlineButtonTypeCopy, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s InlineButtonTypeCopyArray) Last() (v InlineButtonTypeCopy, 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 *InlineButtonTypeCopyArray) PopFirst() (v InlineButtonTypeCopy, 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 InlineButtonTypeCopy + 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 *InlineButtonTypeCopyArray) Pop() (v InlineButtonTypeCopy, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_input_invoice_gen.go b/tg/tl_input_invoice_gen.go index a56e1bafcd..d252051c44 100644 --- a/tg/tl_input_invoice_gen.go +++ b/tg/tl_input_invoice_gen.go @@ -1942,7 +1942,7 @@ func (i *InputInvoiceBusinessBotTransferStars) GetStars() (value int64) { return i.Stars } -// InputInvoiceStarGiftResale represents TL type `inputInvoiceStarGiftResale#c39f5324`. +// InputInvoiceStarGiftResale represents TL type `inputInvoiceStarGiftResale#e9b0c658`. // Used to buy a collectible gift¹ currently up on resale, see here² for more info on // the full flow. // @@ -1959,14 +1959,20 @@ type InputInvoiceStarGiftResale struct { Flags bin.Fields // Buy the gift using TON. Ton bool + // ShowName field of InputInvoiceStarGiftResale. + ShowName bool // Slug of the gift to buy. Slug string // The receiver of the gift. ToID InputPeerClass + // Message field of InputInvoiceStarGiftResale. + // + // Use SetMessage and GetMessage helpers. + Message TextWithEntities } // InputInvoiceStarGiftResaleTypeID is TL type id of InputInvoiceStarGiftResale. -const InputInvoiceStarGiftResaleTypeID = 0xc39f5324 +const InputInvoiceStarGiftResaleTypeID = 0xe9b0c658 // construct implements constructor of InputInvoiceClass. func (i InputInvoiceStarGiftResale) construct() InputInvoiceClass { return &i } @@ -1991,12 +1997,18 @@ func (i *InputInvoiceStarGiftResale) Zero() bool { if !(i.Ton == false) { return false } + if !(i.ShowName == false) { + return false + } if !(i.Slug == "") { return false } if !(i.ToID == nil) { return false } + if !(i.Message.Zero()) { + return false + } return true } @@ -2013,12 +2025,19 @@ func (i *InputInvoiceStarGiftResale) String() string { // FillFrom fills InputInvoiceStarGiftResale from given interface. func (i *InputInvoiceStarGiftResale) FillFrom(from interface { GetTon() (value bool) + GetShowName() (value bool) GetSlug() (value string) GetToID() (value InputPeerClass) + GetMessage() (value TextWithEntities, ok bool) }) { i.Ton = from.GetTon() + i.ShowName = from.GetShowName() i.Slug = from.GetSlug() i.ToID = from.GetToID() + if val, ok := from.GetMessage(); ok { + i.Message = val + } + } // TypeID returns type id in TL schema. @@ -2049,6 +2068,11 @@ func (i *InputInvoiceStarGiftResale) TypeInfo() tdp.Type { SchemaName: "ton", Null: !i.Flags.Has(0), }, + { + Name: "ShowName", + SchemaName: "show_name", + Null: !i.Flags.Has(2), + }, { Name: "Slug", SchemaName: "slug", @@ -2057,6 +2081,11 @@ func (i *InputInvoiceStarGiftResale) TypeInfo() tdp.Type { Name: "ToID", SchemaName: "to_id", }, + { + Name: "Message", + SchemaName: "message", + Null: !i.Flags.Has(1), + }, } return typ } @@ -2066,12 +2095,18 @@ func (i *InputInvoiceStarGiftResale) SetFlags() { if !(i.Ton == false) { i.Flags.Set(0) } + if !(i.ShowName == false) { + i.Flags.Set(2) + } + if !(i.Message.Zero()) { + i.Flags.Set(1) + } } // Encode implements bin.Encoder. func (i *InputInvoiceStarGiftResale) Encode(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't encode inputInvoiceStarGiftResale#c39f5324 as nil") + return fmt.Errorf("can't encode inputInvoiceStarGiftResale#e9b0c658 as nil") } b.PutID(InputInvoiceStarGiftResaleTypeID) return i.EncodeBare(b) @@ -2080,18 +2115,23 @@ func (i *InputInvoiceStarGiftResale) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (i *InputInvoiceStarGiftResale) EncodeBare(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't encode inputInvoiceStarGiftResale#c39f5324 as nil") + return fmt.Errorf("can't encode inputInvoiceStarGiftResale#e9b0c658 as nil") } i.SetFlags() if err := i.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode inputInvoiceStarGiftResale#c39f5324: field flags: %w", err) + return fmt.Errorf("unable to encode inputInvoiceStarGiftResale#e9b0c658: field flags: %w", err) } b.PutString(i.Slug) if i.ToID == nil { - return fmt.Errorf("unable to encode inputInvoiceStarGiftResale#c39f5324: field to_id is nil") + return fmt.Errorf("unable to encode inputInvoiceStarGiftResale#e9b0c658: field to_id is nil") } if err := i.ToID.Encode(b); err != nil { - return fmt.Errorf("unable to encode inputInvoiceStarGiftResale#c39f5324: field to_id: %w", err) + return fmt.Errorf("unable to encode inputInvoiceStarGiftResale#e9b0c658: field to_id: %w", err) + } + if i.Flags.Has(1) { + if err := i.Message.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputInvoiceStarGiftResale#e9b0c658: field message: %w", err) + } } return nil } @@ -2099,10 +2139,10 @@ func (i *InputInvoiceStarGiftResale) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (i *InputInvoiceStarGiftResale) Decode(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't decode inputInvoiceStarGiftResale#c39f5324 to nil") + return fmt.Errorf("can't decode inputInvoiceStarGiftResale#e9b0c658 to nil") } if err := b.ConsumeID(InputInvoiceStarGiftResaleTypeID); err != nil { - return fmt.Errorf("unable to decode inputInvoiceStarGiftResale#c39f5324: %w", err) + return fmt.Errorf("unable to decode inputInvoiceStarGiftResale#e9b0c658: %w", err) } return i.DecodeBare(b) } @@ -2110,28 +2150,34 @@ func (i *InputInvoiceStarGiftResale) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (i *InputInvoiceStarGiftResale) DecodeBare(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't decode inputInvoiceStarGiftResale#c39f5324 to nil") + return fmt.Errorf("can't decode inputInvoiceStarGiftResale#e9b0c658 to nil") } { if err := i.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode inputInvoiceStarGiftResale#c39f5324: field flags: %w", err) + return fmt.Errorf("unable to decode inputInvoiceStarGiftResale#e9b0c658: field flags: %w", err) } } i.Ton = i.Flags.Has(0) + i.ShowName = i.Flags.Has(2) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode inputInvoiceStarGiftResale#c39f5324: field slug: %w", err) + return fmt.Errorf("unable to decode inputInvoiceStarGiftResale#e9b0c658: field slug: %w", err) } i.Slug = value } { value, err := DecodeInputPeer(b) if err != nil { - return fmt.Errorf("unable to decode inputInvoiceStarGiftResale#c39f5324: field to_id: %w", err) + return fmt.Errorf("unable to decode inputInvoiceStarGiftResale#e9b0c658: field to_id: %w", err) } i.ToID = value } + if i.Flags.Has(1) { + if err := i.Message.Decode(b); err != nil { + return fmt.Errorf("unable to decode inputInvoiceStarGiftResale#e9b0c658: field message: %w", err) + } + } return nil } @@ -2154,6 +2200,25 @@ func (i *InputInvoiceStarGiftResale) GetTon() (value bool) { return i.Flags.Has(0) } +// SetShowName sets value of ShowName conditional field. +func (i *InputInvoiceStarGiftResale) SetShowName(value bool) { + if value { + i.Flags.Set(2) + i.ShowName = true + } else { + i.Flags.Unset(2) + i.ShowName = false + } +} + +// GetShowName returns value of ShowName conditional field. +func (i *InputInvoiceStarGiftResale) GetShowName() (value bool) { + if i == nil { + return + } + return i.Flags.Has(2) +} + // GetSlug returns value of Slug field. func (i *InputInvoiceStarGiftResale) GetSlug() (value string) { if i == nil { @@ -2170,6 +2235,24 @@ func (i *InputInvoiceStarGiftResale) GetToID() (value InputPeerClass) { return i.ToID } +// SetMessage sets value of Message conditional field. +func (i *InputInvoiceStarGiftResale) SetMessage(value TextWithEntities) { + i.Flags.Set(1) + i.Message = value +} + +// GetMessage returns value of Message conditional field and +// boolean which is true if field was set. +func (i *InputInvoiceStarGiftResale) GetMessage() (value TextWithEntities, ok bool) { + if i == nil { + return + } + if !i.Flags.Has(1) { + return value, false + } + return i.Message, true +} + // InputInvoiceStarGiftPrepaidUpgrade represents TL type `inputInvoiceStarGiftPrepaidUpgrade#9a0b48b8`. // Separately prepay for the upgrade of a gift »¹. // @@ -3057,7 +3140,7 @@ const InputInvoiceClassName = "InputInvoice" // case *tg.InputInvoiceStarGiftTransfer: // inputInvoiceStarGiftTransfer#4a5f5bd9 // case *tg.InputInvoicePremiumGiftStars: // inputInvoicePremiumGiftStars#dabab2ef // case *tg.InputInvoiceBusinessBotTransferStars: // inputInvoiceBusinessBotTransferStars#f4997e42 -// case *tg.InputInvoiceStarGiftResale: // inputInvoiceStarGiftResale#c39f5324 +// case *tg.InputInvoiceStarGiftResale: // inputInvoiceStarGiftResale#e9b0c658 // case *tg.InputInvoiceStarGiftPrepaidUpgrade: // inputInvoiceStarGiftPrepaidUpgrade#9a0b48b8 // case *tg.InputInvoicePremiumAuthCode: // inputInvoicePremiumAuthCode#3e77f614 // case *tg.InputInvoiceStarGiftDropOriginalDetails: // inputInvoiceStarGiftDropOriginalDetails#923d8d1 @@ -3161,7 +3244,7 @@ func DecodeInputInvoice(buf *bin.Buffer) (InputInvoiceClass, error) { } return &v, nil case InputInvoiceStarGiftResaleTypeID: - // Decoding inputInvoiceStarGiftResale#c39f5324. + // Decoding inputInvoiceStarGiftResale#e9b0c658. v := InputInvoiceStarGiftResale{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode InputInvoiceClass: %w", err) diff --git a/tg/tl_keyboard_button_gen.go b/tg/tl_keyboard_button_gen.go index 6321e0297b..2e52716cfc 100644 --- a/tg/tl_keyboard_button_gen.go +++ b/tg/tl_keyboard_button_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// KeyboardButton represents TL type `keyboardButton#7d170cff`. +// KeyboardButton represents TL type `keyboardButton#2f67a72f`. // Bot keyboard button // // See https://core.telegram.org/constructor/keyboardButton for reference. @@ -50,13 +50,12 @@ type KeyboardButton struct { Style KeyboardButtonStyle // Button text Text string + // Type field of KeyboardButton. + Type ButtonTypeClass } // KeyboardButtonTypeID is TL type id of KeyboardButton. -const KeyboardButtonTypeID = 0x7d170cff - -// construct implements constructor of KeyboardButtonClass. -func (k KeyboardButton) construct() KeyboardButtonClass { return &k } +const KeyboardButtonTypeID = 0x2f67a72f // Ensuring interfaces in compile-time for KeyboardButton. var ( @@ -64,8 +63,6 @@ var ( _ bin.Decoder = &KeyboardButton{} _ bin.BareEncoder = &KeyboardButton{} _ bin.BareDecoder = &KeyboardButton{} - - _ KeyboardButtonClass = &KeyboardButton{} ) func (k *KeyboardButton) Zero() bool { @@ -81,6 +78,9 @@ func (k *KeyboardButton) Zero() bool { if !(k.Text == "") { return false } + if !(k.Type == nil) { + return false + } return true } @@ -98,12 +98,14 @@ func (k *KeyboardButton) String() string { func (k *KeyboardButton) FillFrom(from interface { GetStyle() (value KeyboardButtonStyle, ok bool) GetText() (value string) + GetType() (value ButtonTypeClass) }) { if val, ok := from.GetStyle(); ok { k.Style = val } k.Text = from.GetText() + k.Type = from.GetType() } // TypeID returns type id in TL schema. @@ -138,6 +140,10 @@ func (k *KeyboardButton) TypeInfo() tdp.Type { Name: "Text", SchemaName: "text", }, + { + Name: "Type", + SchemaName: "type", + }, } return typ } @@ -152,7 +158,7 @@ func (k *KeyboardButton) SetFlags() { // Encode implements bin.Encoder. func (k *KeyboardButton) Encode(b *bin.Buffer) error { if k == nil { - return fmt.Errorf("can't encode keyboardButton#7d170cff as nil") + return fmt.Errorf("can't encode keyboardButton#2f67a72f as nil") } b.PutID(KeyboardButtonTypeID) return k.EncodeBare(b) @@ -161,28 +167,34 @@ func (k *KeyboardButton) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (k *KeyboardButton) EncodeBare(b *bin.Buffer) error { if k == nil { - return fmt.Errorf("can't encode keyboardButton#7d170cff as nil") + return fmt.Errorf("can't encode keyboardButton#2f67a72f as nil") } k.SetFlags() if err := k.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButton#7d170cff: field flags: %w", err) + return fmt.Errorf("unable to encode keyboardButton#2f67a72f: field flags: %w", err) } if k.Flags.Has(10) { if err := k.Style.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButton#7d170cff: field style: %w", err) + return fmt.Errorf("unable to encode keyboardButton#2f67a72f: field style: %w", err) } } b.PutString(k.Text) + if k.Type == nil { + return fmt.Errorf("unable to encode keyboardButton#2f67a72f: field type is nil") + } + if err := k.Type.Encode(b); err != nil { + return fmt.Errorf("unable to encode keyboardButton#2f67a72f: field type: %w", err) + } return nil } // Decode implements bin.Decoder. func (k *KeyboardButton) Decode(b *bin.Buffer) error { if k == nil { - return fmt.Errorf("can't decode keyboardButton#7d170cff to nil") + return fmt.Errorf("can't decode keyboardButton#2f67a72f to nil") } if err := b.ConsumeID(KeyboardButtonTypeID); err != nil { - return fmt.Errorf("unable to decode keyboardButton#7d170cff: %w", err) + return fmt.Errorf("unable to decode keyboardButton#2f67a72f: %w", err) } return k.DecodeBare(b) } @@ -190,263 +202,44 @@ func (k *KeyboardButton) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (k *KeyboardButton) DecodeBare(b *bin.Buffer) error { if k == nil { - return fmt.Errorf("can't decode keyboardButton#7d170cff to nil") - } - { - if err := k.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButton#7d170cff: field flags: %w", err) - } - } - if k.Flags.Has(10) { - if err := k.Style.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButton#7d170cff: field style: %w", err) - } - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode keyboardButton#7d170cff: field text: %w", err) - } - k.Text = value - } - return nil -} - -// SetStyle sets value of Style conditional field. -func (k *KeyboardButton) SetStyle(value KeyboardButtonStyle) { - k.Flags.Set(10) - k.Style = value -} - -// GetStyle returns value of Style conditional field and -// boolean which is true if field was set. -func (k *KeyboardButton) GetStyle() (value KeyboardButtonStyle, ok bool) { - if k == nil { - return - } - if !k.Flags.Has(10) { - return value, false - } - return k.Style, true -} - -// GetText returns value of Text field. -func (k *KeyboardButton) GetText() (value string) { - if k == nil { - return - } - return k.Text -} - -// KeyboardButtonURL represents TL type `keyboardButtonUrl#d80c25ec`. -// URL button -// -// See https://core.telegram.org/constructor/keyboardButtonUrl for reference. -type KeyboardButtonURL struct { - // Flags, see TL conditional fields¹ - // - // Links: - // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields - Flags bin.Fields - // Button style, see here »¹ for more info on button styles. - // - // Links: - // 1) https://core.telegram.org/api/bots/buttons#button-styles - // - // Use SetStyle and GetStyle helpers. - Style KeyboardButtonStyle - // Button label - Text string - // URL - URL string -} - -// KeyboardButtonURLTypeID is TL type id of KeyboardButtonURL. -const KeyboardButtonURLTypeID = 0xd80c25ec - -// construct implements constructor of KeyboardButtonClass. -func (k KeyboardButtonURL) construct() KeyboardButtonClass { return &k } - -// Ensuring interfaces in compile-time for KeyboardButtonURL. -var ( - _ bin.Encoder = &KeyboardButtonURL{} - _ bin.Decoder = &KeyboardButtonURL{} - _ bin.BareEncoder = &KeyboardButtonURL{} - _ bin.BareDecoder = &KeyboardButtonURL{} - - _ KeyboardButtonClass = &KeyboardButtonURL{} -) - -func (k *KeyboardButtonURL) Zero() bool { - if k == nil { - return true - } - if !(k.Flags.Zero()) { - return false - } - if !(k.Style.Zero()) { - return false - } - if !(k.Text == "") { - return false - } - if !(k.URL == "") { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (k *KeyboardButtonURL) String() string { - if k == nil { - return "KeyboardButtonURL(nil)" - } - type Alias KeyboardButtonURL - return fmt.Sprintf("KeyboardButtonURL%+v", Alias(*k)) -} - -// FillFrom fills KeyboardButtonURL from given interface. -func (k *KeyboardButtonURL) FillFrom(from interface { - GetStyle() (value KeyboardButtonStyle, ok bool) - GetText() (value string) - GetURL() (value string) -}) { - if val, ok := from.GetStyle(); ok { - k.Style = val - } - - k.Text = from.GetText() - k.URL = from.GetURL() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*KeyboardButtonURL) TypeID() uint32 { - return KeyboardButtonURLTypeID -} - -// TypeName returns name of type in TL schema. -func (*KeyboardButtonURL) TypeName() string { - return "keyboardButtonUrl" -} - -// TypeInfo returns info about TL type. -func (k *KeyboardButtonURL) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "keyboardButtonUrl", - ID: KeyboardButtonURLTypeID, - } - if k == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Style", - SchemaName: "style", - Null: !k.Flags.Has(10), - }, - { - Name: "Text", - SchemaName: "text", - }, - { - Name: "URL", - SchemaName: "url", - }, - } - return typ -} - -// SetFlags sets flags for non-zero fields. -func (k *KeyboardButtonURL) SetFlags() { - if !(k.Style.Zero()) { - k.Flags.Set(10) - } -} - -// Encode implements bin.Encoder. -func (k *KeyboardButtonURL) Encode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonUrl#d80c25ec as nil") - } - b.PutID(KeyboardButtonURLTypeID) - return k.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (k *KeyboardButtonURL) EncodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonUrl#d80c25ec as nil") - } - k.SetFlags() - if err := k.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonUrl#d80c25ec: field flags: %w", err) - } - if k.Flags.Has(10) { - if err := k.Style.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonUrl#d80c25ec: field style: %w", err) - } - } - b.PutString(k.Text) - b.PutString(k.URL) - return nil -} - -// Decode implements bin.Decoder. -func (k *KeyboardButtonURL) Decode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonUrl#d80c25ec to nil") - } - if err := b.ConsumeID(KeyboardButtonURLTypeID); err != nil { - return fmt.Errorf("unable to decode keyboardButtonUrl#d80c25ec: %w", err) - } - return k.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (k *KeyboardButtonURL) DecodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonUrl#d80c25ec to nil") + return fmt.Errorf("can't decode keyboardButton#2f67a72f to nil") } { if err := k.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonUrl#d80c25ec: field flags: %w", err) + return fmt.Errorf("unable to decode keyboardButton#2f67a72f: field flags: %w", err) } } if k.Flags.Has(10) { if err := k.Style.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonUrl#d80c25ec: field style: %w", err) + return fmt.Errorf("unable to decode keyboardButton#2f67a72f: field style: %w", err) } } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode keyboardButtonUrl#d80c25ec: field text: %w", err) + return fmt.Errorf("unable to decode keyboardButton#2f67a72f: field text: %w", err) } k.Text = value } { - value, err := b.String() + value, err := DecodeButtonType(b) if err != nil { - return fmt.Errorf("unable to decode keyboardButtonUrl#d80c25ec: field url: %w", err) + return fmt.Errorf("unable to decode keyboardButton#2f67a72f: field type: %w", err) } - k.URL = value + k.Type = value } return nil } // SetStyle sets value of Style conditional field. -func (k *KeyboardButtonURL) SetStyle(value KeyboardButtonStyle) { +func (k *KeyboardButton) SetStyle(value KeyboardButtonStyle) { k.Flags.Set(10) k.Style = value } // GetStyle returns value of Style conditional field and // boolean which is true if field was set. -func (k *KeyboardButtonURL) GetStyle() (value KeyboardButtonStyle, ok bool) { +func (k *KeyboardButton) GetStyle() (value KeyboardButtonStyle, ok bool) { if k == nil { return } @@ -457,4588 +250,17 @@ func (k *KeyboardButtonURL) GetStyle() (value KeyboardButtonStyle, ok bool) { } // GetText returns value of Text field. -func (k *KeyboardButtonURL) GetText() (value string) { +func (k *KeyboardButton) GetText() (value string) { if k == nil { return } return k.Text } -// GetURL returns value of URL field. -func (k *KeyboardButtonURL) GetURL() (value string) { +// GetType returns value of Type field. +func (k *KeyboardButton) GetType() (value ButtonTypeClass) { if k == nil { return } - return k.URL -} - -// KeyboardButtonCallback represents TL type `keyboardButtonCallback#e62bc960`. -// Callback button -// -// See https://core.telegram.org/constructor/keyboardButtonCallback for reference. -type KeyboardButtonCallback struct { - // Flags, see TL conditional fields¹ - // - // Links: - // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields - Flags bin.Fields - // Whether the user should verify his identity by entering his 2FA SRP parameters¹ to - // the messages.getBotCallbackAnswer² method. NOTE: telegram and the bot WILL NOT have - // access to the plaintext password, thanks to SRP³. This button is mainly used by the - // official @botfather⁴ bot, for verifying the user's identity before transferring - // ownership of a bot to another user. - // - // Links: - // 1) https://core.telegram.org/api/srp - // 2) https://core.telegram.org/method/messages.getBotCallbackAnswer - // 3) https://core.telegram.org/api/srp - // 4) https://t.me/botfather - RequiresPassword bool - // Button style, see here »¹ for more info on button styles. - // - // Links: - // 1) https://core.telegram.org/api/bots/buttons#button-styles - // - // Use SetStyle and GetStyle helpers. - Style KeyboardButtonStyle - // Button text - Text string - // Callback data - Data []byte -} - -// KeyboardButtonCallbackTypeID is TL type id of KeyboardButtonCallback. -const KeyboardButtonCallbackTypeID = 0xe62bc960 - -// construct implements constructor of KeyboardButtonClass. -func (k KeyboardButtonCallback) construct() KeyboardButtonClass { return &k } - -// Ensuring interfaces in compile-time for KeyboardButtonCallback. -var ( - _ bin.Encoder = &KeyboardButtonCallback{} - _ bin.Decoder = &KeyboardButtonCallback{} - _ bin.BareEncoder = &KeyboardButtonCallback{} - _ bin.BareDecoder = &KeyboardButtonCallback{} - - _ KeyboardButtonClass = &KeyboardButtonCallback{} -) - -func (k *KeyboardButtonCallback) Zero() bool { - if k == nil { - return true - } - if !(k.Flags.Zero()) { - return false - } - if !(k.RequiresPassword == false) { - return false - } - if !(k.Style.Zero()) { - return false - } - if !(k.Text == "") { - return false - } - if !(k.Data == nil) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (k *KeyboardButtonCallback) String() string { - if k == nil { - return "KeyboardButtonCallback(nil)" - } - type Alias KeyboardButtonCallback - return fmt.Sprintf("KeyboardButtonCallback%+v", Alias(*k)) -} - -// FillFrom fills KeyboardButtonCallback from given interface. -func (k *KeyboardButtonCallback) FillFrom(from interface { - GetRequiresPassword() (value bool) - GetStyle() (value KeyboardButtonStyle, ok bool) - GetText() (value string) - GetData() (value []byte) -}) { - k.RequiresPassword = from.GetRequiresPassword() - if val, ok := from.GetStyle(); ok { - k.Style = val - } - - k.Text = from.GetText() - k.Data = from.GetData() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*KeyboardButtonCallback) TypeID() uint32 { - return KeyboardButtonCallbackTypeID -} - -// TypeName returns name of type in TL schema. -func (*KeyboardButtonCallback) TypeName() string { - return "keyboardButtonCallback" -} - -// TypeInfo returns info about TL type. -func (k *KeyboardButtonCallback) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "keyboardButtonCallback", - ID: KeyboardButtonCallbackTypeID, - } - if k == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "RequiresPassword", - SchemaName: "requires_password", - Null: !k.Flags.Has(0), - }, - { - Name: "Style", - SchemaName: "style", - Null: !k.Flags.Has(10), - }, - { - Name: "Text", - SchemaName: "text", - }, - { - Name: "Data", - SchemaName: "data", - }, - } - return typ -} - -// SetFlags sets flags for non-zero fields. -func (k *KeyboardButtonCallback) SetFlags() { - if !(k.RequiresPassword == false) { - k.Flags.Set(0) - } - if !(k.Style.Zero()) { - k.Flags.Set(10) - } -} - -// Encode implements bin.Encoder. -func (k *KeyboardButtonCallback) Encode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonCallback#e62bc960 as nil") - } - b.PutID(KeyboardButtonCallbackTypeID) - return k.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (k *KeyboardButtonCallback) EncodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonCallback#e62bc960 as nil") - } - k.SetFlags() - if err := k.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonCallback#e62bc960: field flags: %w", err) - } - if k.Flags.Has(10) { - if err := k.Style.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonCallback#e62bc960: field style: %w", err) - } - } - b.PutString(k.Text) - b.PutBytes(k.Data) - return nil -} - -// Decode implements bin.Decoder. -func (k *KeyboardButtonCallback) Decode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonCallback#e62bc960 to nil") - } - if err := b.ConsumeID(KeyboardButtonCallbackTypeID); err != nil { - return fmt.Errorf("unable to decode keyboardButtonCallback#e62bc960: %w", err) - } - return k.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (k *KeyboardButtonCallback) DecodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonCallback#e62bc960 to nil") - } - { - if err := k.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonCallback#e62bc960: field flags: %w", err) - } - } - k.RequiresPassword = k.Flags.Has(0) - if k.Flags.Has(10) { - if err := k.Style.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonCallback#e62bc960: field style: %w", err) - } - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonCallback#e62bc960: field text: %w", err) - } - k.Text = value - } - { - value, err := b.Bytes() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonCallback#e62bc960: field data: %w", err) - } - k.Data = value - } - return nil -} - -// SetRequiresPassword sets value of RequiresPassword conditional field. -func (k *KeyboardButtonCallback) SetRequiresPassword(value bool) { - if value { - k.Flags.Set(0) - k.RequiresPassword = true - } else { - k.Flags.Unset(0) - k.RequiresPassword = false - } -} - -// GetRequiresPassword returns value of RequiresPassword conditional field. -func (k *KeyboardButtonCallback) GetRequiresPassword() (value bool) { - if k == nil { - return - } - return k.Flags.Has(0) -} - -// SetStyle sets value of Style conditional field. -func (k *KeyboardButtonCallback) SetStyle(value KeyboardButtonStyle) { - k.Flags.Set(10) - k.Style = value -} - -// GetStyle returns value of Style conditional field and -// boolean which is true if field was set. -func (k *KeyboardButtonCallback) GetStyle() (value KeyboardButtonStyle, ok bool) { - if k == nil { - return - } - if !k.Flags.Has(10) { - return value, false - } - return k.Style, true -} - -// GetText returns value of Text field. -func (k *KeyboardButtonCallback) GetText() (value string) { - if k == nil { - return - } - return k.Text -} - -// GetData returns value of Data field. -func (k *KeyboardButtonCallback) GetData() (value []byte) { - if k == nil { - return - } - return k.Data -} - -// KeyboardButtonRequestPhone represents TL type `keyboardButtonRequestPhone#417efd8f`. -// Button to request a user's phone number -// -// See https://core.telegram.org/constructor/keyboardButtonRequestPhone for reference. -type KeyboardButtonRequestPhone struct { - // Flags, see TL conditional fields¹ - // - // Links: - // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields - Flags bin.Fields - // Button style, see here »¹ for more info on button styles. - // - // Links: - // 1) https://core.telegram.org/api/bots/buttons#button-styles - // - // Use SetStyle and GetStyle helpers. - Style KeyboardButtonStyle - // Button text - Text string -} - -// KeyboardButtonRequestPhoneTypeID is TL type id of KeyboardButtonRequestPhone. -const KeyboardButtonRequestPhoneTypeID = 0x417efd8f - -// construct implements constructor of KeyboardButtonClass. -func (k KeyboardButtonRequestPhone) construct() KeyboardButtonClass { return &k } - -// Ensuring interfaces in compile-time for KeyboardButtonRequestPhone. -var ( - _ bin.Encoder = &KeyboardButtonRequestPhone{} - _ bin.Decoder = &KeyboardButtonRequestPhone{} - _ bin.BareEncoder = &KeyboardButtonRequestPhone{} - _ bin.BareDecoder = &KeyboardButtonRequestPhone{} - - _ KeyboardButtonClass = &KeyboardButtonRequestPhone{} -) - -func (k *KeyboardButtonRequestPhone) Zero() bool { - if k == nil { - return true - } - if !(k.Flags.Zero()) { - return false - } - if !(k.Style.Zero()) { - return false - } - if !(k.Text == "") { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (k *KeyboardButtonRequestPhone) String() string { - if k == nil { - return "KeyboardButtonRequestPhone(nil)" - } - type Alias KeyboardButtonRequestPhone - return fmt.Sprintf("KeyboardButtonRequestPhone%+v", Alias(*k)) -} - -// FillFrom fills KeyboardButtonRequestPhone from given interface. -func (k *KeyboardButtonRequestPhone) FillFrom(from interface { - GetStyle() (value KeyboardButtonStyle, ok bool) - GetText() (value string) -}) { - if val, ok := from.GetStyle(); ok { - k.Style = val - } - - k.Text = from.GetText() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*KeyboardButtonRequestPhone) TypeID() uint32 { - return KeyboardButtonRequestPhoneTypeID -} - -// TypeName returns name of type in TL schema. -func (*KeyboardButtonRequestPhone) TypeName() string { - return "keyboardButtonRequestPhone" -} - -// TypeInfo returns info about TL type. -func (k *KeyboardButtonRequestPhone) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "keyboardButtonRequestPhone", - ID: KeyboardButtonRequestPhoneTypeID, - } - if k == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Style", - SchemaName: "style", - Null: !k.Flags.Has(10), - }, - { - Name: "Text", - SchemaName: "text", - }, - } - return typ -} - -// SetFlags sets flags for non-zero fields. -func (k *KeyboardButtonRequestPhone) SetFlags() { - if !(k.Style.Zero()) { - k.Flags.Set(10) - } -} - -// Encode implements bin.Encoder. -func (k *KeyboardButtonRequestPhone) Encode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonRequestPhone#417efd8f as nil") - } - b.PutID(KeyboardButtonRequestPhoneTypeID) - return k.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (k *KeyboardButtonRequestPhone) EncodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonRequestPhone#417efd8f as nil") - } - k.SetFlags() - if err := k.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonRequestPhone#417efd8f: field flags: %w", err) - } - if k.Flags.Has(10) { - if err := k.Style.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonRequestPhone#417efd8f: field style: %w", err) - } - } - b.PutString(k.Text) - return nil -} - -// Decode implements bin.Decoder. -func (k *KeyboardButtonRequestPhone) Decode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonRequestPhone#417efd8f to nil") - } - if err := b.ConsumeID(KeyboardButtonRequestPhoneTypeID); err != nil { - return fmt.Errorf("unable to decode keyboardButtonRequestPhone#417efd8f: %w", err) - } - return k.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (k *KeyboardButtonRequestPhone) DecodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonRequestPhone#417efd8f to nil") - } - { - if err := k.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonRequestPhone#417efd8f: field flags: %w", err) - } - } - if k.Flags.Has(10) { - if err := k.Style.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonRequestPhone#417efd8f: field style: %w", err) - } - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonRequestPhone#417efd8f: field text: %w", err) - } - k.Text = value - } - return nil -} - -// SetStyle sets value of Style conditional field. -func (k *KeyboardButtonRequestPhone) SetStyle(value KeyboardButtonStyle) { - k.Flags.Set(10) - k.Style = value -} - -// GetStyle returns value of Style conditional field and -// boolean which is true if field was set. -func (k *KeyboardButtonRequestPhone) GetStyle() (value KeyboardButtonStyle, ok bool) { - if k == nil { - return - } - if !k.Flags.Has(10) { - return value, false - } - return k.Style, true -} - -// GetText returns value of Text field. -func (k *KeyboardButtonRequestPhone) GetText() (value string) { - if k == nil { - return - } - return k.Text -} - -// KeyboardButtonRequestGeoLocation represents TL type `keyboardButtonRequestGeoLocation#aa40f94d`. -// Button to request a user's geolocation -// -// See https://core.telegram.org/constructor/keyboardButtonRequestGeoLocation for reference. -type KeyboardButtonRequestGeoLocation struct { - // Flags, see TL conditional fields¹ - // - // Links: - // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields - Flags bin.Fields - // Button style, see here »¹ for more info on button styles. - // - // Links: - // 1) https://core.telegram.org/api/bots/buttons#button-styles - // - // Use SetStyle and GetStyle helpers. - Style KeyboardButtonStyle - // Button text - Text string -} - -// KeyboardButtonRequestGeoLocationTypeID is TL type id of KeyboardButtonRequestGeoLocation. -const KeyboardButtonRequestGeoLocationTypeID = 0xaa40f94d - -// construct implements constructor of KeyboardButtonClass. -func (k KeyboardButtonRequestGeoLocation) construct() KeyboardButtonClass { return &k } - -// Ensuring interfaces in compile-time for KeyboardButtonRequestGeoLocation. -var ( - _ bin.Encoder = &KeyboardButtonRequestGeoLocation{} - _ bin.Decoder = &KeyboardButtonRequestGeoLocation{} - _ bin.BareEncoder = &KeyboardButtonRequestGeoLocation{} - _ bin.BareDecoder = &KeyboardButtonRequestGeoLocation{} - - _ KeyboardButtonClass = &KeyboardButtonRequestGeoLocation{} -) - -func (k *KeyboardButtonRequestGeoLocation) Zero() bool { - if k == nil { - return true - } - if !(k.Flags.Zero()) { - return false - } - if !(k.Style.Zero()) { - return false - } - if !(k.Text == "") { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (k *KeyboardButtonRequestGeoLocation) String() string { - if k == nil { - return "KeyboardButtonRequestGeoLocation(nil)" - } - type Alias KeyboardButtonRequestGeoLocation - return fmt.Sprintf("KeyboardButtonRequestGeoLocation%+v", Alias(*k)) -} - -// FillFrom fills KeyboardButtonRequestGeoLocation from given interface. -func (k *KeyboardButtonRequestGeoLocation) FillFrom(from interface { - GetStyle() (value KeyboardButtonStyle, ok bool) - GetText() (value string) -}) { - if val, ok := from.GetStyle(); ok { - k.Style = val - } - - k.Text = from.GetText() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*KeyboardButtonRequestGeoLocation) TypeID() uint32 { - return KeyboardButtonRequestGeoLocationTypeID -} - -// TypeName returns name of type in TL schema. -func (*KeyboardButtonRequestGeoLocation) TypeName() string { - return "keyboardButtonRequestGeoLocation" -} - -// TypeInfo returns info about TL type. -func (k *KeyboardButtonRequestGeoLocation) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "keyboardButtonRequestGeoLocation", - ID: KeyboardButtonRequestGeoLocationTypeID, - } - if k == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Style", - SchemaName: "style", - Null: !k.Flags.Has(10), - }, - { - Name: "Text", - SchemaName: "text", - }, - } - return typ -} - -// SetFlags sets flags for non-zero fields. -func (k *KeyboardButtonRequestGeoLocation) SetFlags() { - if !(k.Style.Zero()) { - k.Flags.Set(10) - } -} - -// Encode implements bin.Encoder. -func (k *KeyboardButtonRequestGeoLocation) Encode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonRequestGeoLocation#aa40f94d as nil") - } - b.PutID(KeyboardButtonRequestGeoLocationTypeID) - return k.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (k *KeyboardButtonRequestGeoLocation) EncodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonRequestGeoLocation#aa40f94d as nil") - } - k.SetFlags() - if err := k.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonRequestGeoLocation#aa40f94d: field flags: %w", err) - } - if k.Flags.Has(10) { - if err := k.Style.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonRequestGeoLocation#aa40f94d: field style: %w", err) - } - } - b.PutString(k.Text) - return nil -} - -// Decode implements bin.Decoder. -func (k *KeyboardButtonRequestGeoLocation) Decode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonRequestGeoLocation#aa40f94d to nil") - } - if err := b.ConsumeID(KeyboardButtonRequestGeoLocationTypeID); err != nil { - return fmt.Errorf("unable to decode keyboardButtonRequestGeoLocation#aa40f94d: %w", err) - } - return k.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (k *KeyboardButtonRequestGeoLocation) DecodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonRequestGeoLocation#aa40f94d to nil") - } - { - if err := k.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonRequestGeoLocation#aa40f94d: field flags: %w", err) - } - } - if k.Flags.Has(10) { - if err := k.Style.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonRequestGeoLocation#aa40f94d: field style: %w", err) - } - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonRequestGeoLocation#aa40f94d: field text: %w", err) - } - k.Text = value - } - return nil -} - -// SetStyle sets value of Style conditional field. -func (k *KeyboardButtonRequestGeoLocation) SetStyle(value KeyboardButtonStyle) { - k.Flags.Set(10) - k.Style = value -} - -// GetStyle returns value of Style conditional field and -// boolean which is true if field was set. -func (k *KeyboardButtonRequestGeoLocation) GetStyle() (value KeyboardButtonStyle, ok bool) { - if k == nil { - return - } - if !k.Flags.Has(10) { - return value, false - } - return k.Style, true -} - -// GetText returns value of Text field. -func (k *KeyboardButtonRequestGeoLocation) GetText() (value string) { - if k == nil { - return - } - return k.Text -} - -// KeyboardButtonSwitchInline represents TL type `keyboardButtonSwitchInline#991399fc`. -// Button to force a user to switch to inline mode: pressing the button will prompt the -// user to select one of their chats, open that chat and insert the bot's username and -// the specified inline query in the input field. -// -// See https://core.telegram.org/constructor/keyboardButtonSwitchInline for reference. -type KeyboardButtonSwitchInline struct { - // Flags, see TL conditional fields¹ - // - // Links: - // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields - Flags bin.Fields - // If set, pressing the button will insert the bot's username and the specified inline - // query in the current chat's input field. - SamePeer bool - // Button style, see here »¹ for more info on button styles. - // - // Links: - // 1) https://core.telegram.org/api/bots/buttons#button-styles - // - // Use SetStyle and GetStyle helpers. - Style KeyboardButtonStyle - // Button label - Text string - // The inline query to use - Query string - // Filter to use when selecting chats. - // - // Use SetPeerTypes and GetPeerTypes helpers. - PeerTypes []InlineQueryPeerTypeClass -} - -// KeyboardButtonSwitchInlineTypeID is TL type id of KeyboardButtonSwitchInline. -const KeyboardButtonSwitchInlineTypeID = 0x991399fc - -// construct implements constructor of KeyboardButtonClass. -func (k KeyboardButtonSwitchInline) construct() KeyboardButtonClass { return &k } - -// Ensuring interfaces in compile-time for KeyboardButtonSwitchInline. -var ( - _ bin.Encoder = &KeyboardButtonSwitchInline{} - _ bin.Decoder = &KeyboardButtonSwitchInline{} - _ bin.BareEncoder = &KeyboardButtonSwitchInline{} - _ bin.BareDecoder = &KeyboardButtonSwitchInline{} - - _ KeyboardButtonClass = &KeyboardButtonSwitchInline{} -) - -func (k *KeyboardButtonSwitchInline) Zero() bool { - if k == nil { - return true - } - if !(k.Flags.Zero()) { - return false - } - if !(k.SamePeer == false) { - return false - } - if !(k.Style.Zero()) { - return false - } - if !(k.Text == "") { - return false - } - if !(k.Query == "") { - return false - } - if !(k.PeerTypes == nil) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (k *KeyboardButtonSwitchInline) String() string { - if k == nil { - return "KeyboardButtonSwitchInline(nil)" - } - type Alias KeyboardButtonSwitchInline - return fmt.Sprintf("KeyboardButtonSwitchInline%+v", Alias(*k)) -} - -// FillFrom fills KeyboardButtonSwitchInline from given interface. -func (k *KeyboardButtonSwitchInline) FillFrom(from interface { - GetSamePeer() (value bool) - GetStyle() (value KeyboardButtonStyle, ok bool) - GetText() (value string) - GetQuery() (value string) - GetPeerTypes() (value []InlineQueryPeerTypeClass, ok bool) -}) { - k.SamePeer = from.GetSamePeer() - if val, ok := from.GetStyle(); ok { - k.Style = val - } - - k.Text = from.GetText() - k.Query = from.GetQuery() - if val, ok := from.GetPeerTypes(); ok { - k.PeerTypes = val - } - -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*KeyboardButtonSwitchInline) TypeID() uint32 { - return KeyboardButtonSwitchInlineTypeID -} - -// TypeName returns name of type in TL schema. -func (*KeyboardButtonSwitchInline) TypeName() string { - return "keyboardButtonSwitchInline" -} - -// TypeInfo returns info about TL type. -func (k *KeyboardButtonSwitchInline) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "keyboardButtonSwitchInline", - ID: KeyboardButtonSwitchInlineTypeID, - } - if k == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "SamePeer", - SchemaName: "same_peer", - Null: !k.Flags.Has(0), - }, - { - Name: "Style", - SchemaName: "style", - Null: !k.Flags.Has(10), - }, - { - Name: "Text", - SchemaName: "text", - }, - { - Name: "Query", - SchemaName: "query", - }, - { - Name: "PeerTypes", - SchemaName: "peer_types", - Null: !k.Flags.Has(1), - }, - } - return typ -} - -// SetFlags sets flags for non-zero fields. -func (k *KeyboardButtonSwitchInline) SetFlags() { - if !(k.SamePeer == false) { - k.Flags.Set(0) - } - if !(k.Style.Zero()) { - k.Flags.Set(10) - } - if !(k.PeerTypes == nil) { - k.Flags.Set(1) - } -} - -// Encode implements bin.Encoder. -func (k *KeyboardButtonSwitchInline) Encode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonSwitchInline#991399fc as nil") - } - b.PutID(KeyboardButtonSwitchInlineTypeID) - return k.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (k *KeyboardButtonSwitchInline) EncodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonSwitchInline#991399fc as nil") - } - k.SetFlags() - if err := k.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonSwitchInline#991399fc: field flags: %w", err) - } - if k.Flags.Has(10) { - if err := k.Style.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonSwitchInline#991399fc: field style: %w", err) - } - } - b.PutString(k.Text) - b.PutString(k.Query) - if k.Flags.Has(1) { - b.PutVectorHeader(len(k.PeerTypes)) - for idx, v := range k.PeerTypes { - if v == nil { - return fmt.Errorf("unable to encode keyboardButtonSwitchInline#991399fc: field peer_types element with index %d is nil", idx) - } - if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonSwitchInline#991399fc: field peer_types element with index %d: %w", idx, err) - } - } - } - return nil -} - -// Decode implements bin.Decoder. -func (k *KeyboardButtonSwitchInline) Decode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonSwitchInline#991399fc to nil") - } - if err := b.ConsumeID(KeyboardButtonSwitchInlineTypeID); err != nil { - return fmt.Errorf("unable to decode keyboardButtonSwitchInline#991399fc: %w", err) - } - return k.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (k *KeyboardButtonSwitchInline) DecodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonSwitchInline#991399fc to nil") - } - { - if err := k.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonSwitchInline#991399fc: field flags: %w", err) - } - } - k.SamePeer = k.Flags.Has(0) - if k.Flags.Has(10) { - if err := k.Style.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonSwitchInline#991399fc: field style: %w", err) - } - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonSwitchInline#991399fc: field text: %w", err) - } - k.Text = value - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonSwitchInline#991399fc: field query: %w", err) - } - k.Query = value - } - if k.Flags.Has(1) { - headerLen, err := b.VectorHeader() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonSwitchInline#991399fc: field peer_types: %w", err) - } - - if headerLen > 0 { - k.PeerTypes = make([]InlineQueryPeerTypeClass, 0, headerLen%bin.PreallocateLimit) - } - for idx := 0; idx < headerLen; idx++ { - value, err := DecodeInlineQueryPeerType(b) - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonSwitchInline#991399fc: field peer_types: %w", err) - } - k.PeerTypes = append(k.PeerTypes, value) - } - } - return nil -} - -// SetSamePeer sets value of SamePeer conditional field. -func (k *KeyboardButtonSwitchInline) SetSamePeer(value bool) { - if value { - k.Flags.Set(0) - k.SamePeer = true - } else { - k.Flags.Unset(0) - k.SamePeer = false - } -} - -// GetSamePeer returns value of SamePeer conditional field. -func (k *KeyboardButtonSwitchInline) GetSamePeer() (value bool) { - if k == nil { - return - } - return k.Flags.Has(0) -} - -// SetStyle sets value of Style conditional field. -func (k *KeyboardButtonSwitchInline) SetStyle(value KeyboardButtonStyle) { - k.Flags.Set(10) - k.Style = value -} - -// GetStyle returns value of Style conditional field and -// boolean which is true if field was set. -func (k *KeyboardButtonSwitchInline) GetStyle() (value KeyboardButtonStyle, ok bool) { - if k == nil { - return - } - if !k.Flags.Has(10) { - return value, false - } - return k.Style, true -} - -// GetText returns value of Text field. -func (k *KeyboardButtonSwitchInline) GetText() (value string) { - if k == nil { - return - } - return k.Text -} - -// GetQuery returns value of Query field. -func (k *KeyboardButtonSwitchInline) GetQuery() (value string) { - if k == nil { - return - } - return k.Query -} - -// SetPeerTypes sets value of PeerTypes conditional field. -func (k *KeyboardButtonSwitchInline) SetPeerTypes(value []InlineQueryPeerTypeClass) { - k.Flags.Set(1) - k.PeerTypes = value -} - -// GetPeerTypes returns value of PeerTypes conditional field and -// boolean which is true if field was set. -func (k *KeyboardButtonSwitchInline) GetPeerTypes() (value []InlineQueryPeerTypeClass, ok bool) { - if k == nil { - return - } - if !k.Flags.Has(1) { - return value, false - } - return k.PeerTypes, true -} - -// MapPeerTypes returns field PeerTypes wrapped in InlineQueryPeerTypeClassArray helper. -func (k *KeyboardButtonSwitchInline) MapPeerTypes() (value InlineQueryPeerTypeClassArray, ok bool) { - if !k.Flags.Has(1) { - return value, false - } - return InlineQueryPeerTypeClassArray(k.PeerTypes), true -} - -// KeyboardButtonGame represents TL type `keyboardButtonGame#89c590f9`. -// Button to start a game -// -// See https://core.telegram.org/constructor/keyboardButtonGame for reference. -type KeyboardButtonGame struct { - // Flags, see TL conditional fields¹ - // - // Links: - // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields - Flags bin.Fields - // Button style, see here »¹ for more info on button styles. - // - // Links: - // 1) https://core.telegram.org/api/bots/buttons#button-styles - // - // Use SetStyle and GetStyle helpers. - Style KeyboardButtonStyle - // Button text - Text string -} - -// KeyboardButtonGameTypeID is TL type id of KeyboardButtonGame. -const KeyboardButtonGameTypeID = 0x89c590f9 - -// construct implements constructor of KeyboardButtonClass. -func (k KeyboardButtonGame) construct() KeyboardButtonClass { return &k } - -// Ensuring interfaces in compile-time for KeyboardButtonGame. -var ( - _ bin.Encoder = &KeyboardButtonGame{} - _ bin.Decoder = &KeyboardButtonGame{} - _ bin.BareEncoder = &KeyboardButtonGame{} - _ bin.BareDecoder = &KeyboardButtonGame{} - - _ KeyboardButtonClass = &KeyboardButtonGame{} -) - -func (k *KeyboardButtonGame) Zero() bool { - if k == nil { - return true - } - if !(k.Flags.Zero()) { - return false - } - if !(k.Style.Zero()) { - return false - } - if !(k.Text == "") { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (k *KeyboardButtonGame) String() string { - if k == nil { - return "KeyboardButtonGame(nil)" - } - type Alias KeyboardButtonGame - return fmt.Sprintf("KeyboardButtonGame%+v", Alias(*k)) -} - -// FillFrom fills KeyboardButtonGame from given interface. -func (k *KeyboardButtonGame) FillFrom(from interface { - GetStyle() (value KeyboardButtonStyle, ok bool) - GetText() (value string) -}) { - if val, ok := from.GetStyle(); ok { - k.Style = val - } - - k.Text = from.GetText() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*KeyboardButtonGame) TypeID() uint32 { - return KeyboardButtonGameTypeID -} - -// TypeName returns name of type in TL schema. -func (*KeyboardButtonGame) TypeName() string { - return "keyboardButtonGame" -} - -// TypeInfo returns info about TL type. -func (k *KeyboardButtonGame) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "keyboardButtonGame", - ID: KeyboardButtonGameTypeID, - } - if k == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Style", - SchemaName: "style", - Null: !k.Flags.Has(10), - }, - { - Name: "Text", - SchemaName: "text", - }, - } - return typ -} - -// SetFlags sets flags for non-zero fields. -func (k *KeyboardButtonGame) SetFlags() { - if !(k.Style.Zero()) { - k.Flags.Set(10) - } -} - -// Encode implements bin.Encoder. -func (k *KeyboardButtonGame) Encode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonGame#89c590f9 as nil") - } - b.PutID(KeyboardButtonGameTypeID) - return k.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (k *KeyboardButtonGame) EncodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonGame#89c590f9 as nil") - } - k.SetFlags() - if err := k.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonGame#89c590f9: field flags: %w", err) - } - if k.Flags.Has(10) { - if err := k.Style.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonGame#89c590f9: field style: %w", err) - } - } - b.PutString(k.Text) - return nil -} - -// Decode implements bin.Decoder. -func (k *KeyboardButtonGame) Decode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonGame#89c590f9 to nil") - } - if err := b.ConsumeID(KeyboardButtonGameTypeID); err != nil { - return fmt.Errorf("unable to decode keyboardButtonGame#89c590f9: %w", err) - } - return k.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (k *KeyboardButtonGame) DecodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonGame#89c590f9 to nil") - } - { - if err := k.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonGame#89c590f9: field flags: %w", err) - } - } - if k.Flags.Has(10) { - if err := k.Style.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonGame#89c590f9: field style: %w", err) - } - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonGame#89c590f9: field text: %w", err) - } - k.Text = value - } - return nil -} - -// SetStyle sets value of Style conditional field. -func (k *KeyboardButtonGame) SetStyle(value KeyboardButtonStyle) { - k.Flags.Set(10) - k.Style = value -} - -// GetStyle returns value of Style conditional field and -// boolean which is true if field was set. -func (k *KeyboardButtonGame) GetStyle() (value KeyboardButtonStyle, ok bool) { - if k == nil { - return - } - if !k.Flags.Has(10) { - return value, false - } - return k.Style, true -} - -// GetText returns value of Text field. -func (k *KeyboardButtonGame) GetText() (value string) { - if k == nil { - return - } - return k.Text -} - -// KeyboardButtonBuy represents TL type `keyboardButtonBuy#3fa53905`. -// Button to buy a product -// -// See https://core.telegram.org/constructor/keyboardButtonBuy for reference. -type KeyboardButtonBuy struct { - // Flags, see TL conditional fields¹ - // - // Links: - // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields - Flags bin.Fields - // Button style, see here »¹ for more info on button styles. - // - // Links: - // 1) https://core.telegram.org/api/bots/buttons#button-styles - // - // Use SetStyle and GetStyle helpers. - Style KeyboardButtonStyle - // Button text - Text string -} - -// KeyboardButtonBuyTypeID is TL type id of KeyboardButtonBuy. -const KeyboardButtonBuyTypeID = 0x3fa53905 - -// construct implements constructor of KeyboardButtonClass. -func (k KeyboardButtonBuy) construct() KeyboardButtonClass { return &k } - -// Ensuring interfaces in compile-time for KeyboardButtonBuy. -var ( - _ bin.Encoder = &KeyboardButtonBuy{} - _ bin.Decoder = &KeyboardButtonBuy{} - _ bin.BareEncoder = &KeyboardButtonBuy{} - _ bin.BareDecoder = &KeyboardButtonBuy{} - - _ KeyboardButtonClass = &KeyboardButtonBuy{} -) - -func (k *KeyboardButtonBuy) Zero() bool { - if k == nil { - return true - } - if !(k.Flags.Zero()) { - return false - } - if !(k.Style.Zero()) { - return false - } - if !(k.Text == "") { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (k *KeyboardButtonBuy) String() string { - if k == nil { - return "KeyboardButtonBuy(nil)" - } - type Alias KeyboardButtonBuy - return fmt.Sprintf("KeyboardButtonBuy%+v", Alias(*k)) -} - -// FillFrom fills KeyboardButtonBuy from given interface. -func (k *KeyboardButtonBuy) FillFrom(from interface { - GetStyle() (value KeyboardButtonStyle, ok bool) - GetText() (value string) -}) { - if val, ok := from.GetStyle(); ok { - k.Style = val - } - - k.Text = from.GetText() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*KeyboardButtonBuy) TypeID() uint32 { - return KeyboardButtonBuyTypeID -} - -// TypeName returns name of type in TL schema. -func (*KeyboardButtonBuy) TypeName() string { - return "keyboardButtonBuy" -} - -// TypeInfo returns info about TL type. -func (k *KeyboardButtonBuy) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "keyboardButtonBuy", - ID: KeyboardButtonBuyTypeID, - } - if k == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Style", - SchemaName: "style", - Null: !k.Flags.Has(10), - }, - { - Name: "Text", - SchemaName: "text", - }, - } - return typ -} - -// SetFlags sets flags for non-zero fields. -func (k *KeyboardButtonBuy) SetFlags() { - if !(k.Style.Zero()) { - k.Flags.Set(10) - } -} - -// Encode implements bin.Encoder. -func (k *KeyboardButtonBuy) Encode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonBuy#3fa53905 as nil") - } - b.PutID(KeyboardButtonBuyTypeID) - return k.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (k *KeyboardButtonBuy) EncodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonBuy#3fa53905 as nil") - } - k.SetFlags() - if err := k.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonBuy#3fa53905: field flags: %w", err) - } - if k.Flags.Has(10) { - if err := k.Style.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonBuy#3fa53905: field style: %w", err) - } - } - b.PutString(k.Text) - return nil -} - -// Decode implements bin.Decoder. -func (k *KeyboardButtonBuy) Decode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonBuy#3fa53905 to nil") - } - if err := b.ConsumeID(KeyboardButtonBuyTypeID); err != nil { - return fmt.Errorf("unable to decode keyboardButtonBuy#3fa53905: %w", err) - } - return k.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (k *KeyboardButtonBuy) DecodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonBuy#3fa53905 to nil") - } - { - if err := k.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonBuy#3fa53905: field flags: %w", err) - } - } - if k.Flags.Has(10) { - if err := k.Style.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonBuy#3fa53905: field style: %w", err) - } - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonBuy#3fa53905: field text: %w", err) - } - k.Text = value - } - return nil -} - -// SetStyle sets value of Style conditional field. -func (k *KeyboardButtonBuy) SetStyle(value KeyboardButtonStyle) { - k.Flags.Set(10) - k.Style = value -} - -// GetStyle returns value of Style conditional field and -// boolean which is true if field was set. -func (k *KeyboardButtonBuy) GetStyle() (value KeyboardButtonStyle, ok bool) { - if k == nil { - return - } - if !k.Flags.Has(10) { - return value, false - } - return k.Style, true -} - -// GetText returns value of Text field. -func (k *KeyboardButtonBuy) GetText() (value string) { - if k == nil { - return - } - return k.Text -} - -// KeyboardButtonURLAuth represents TL type `keyboardButtonUrlAuth#f51006f9`. -// Button to request a user to authorize via URL using Seamless Telegram Login¹. When -// the user clicks on such a button, messages.requestUrlAuth² should be called, -// providing the button_id and the ID of the container message. The returned -// urlAuthResultRequest³ object will contain more details about the authorization -// request (request_write_access if the bot would like to send messages to the user along -// with the username of the bot which will be used for user authorization). Finally, the -// user can choose to call messages.acceptUrlAuth⁴ to get a urlAuthResultAccepted⁵ -// with the URL to open instead of the url of this constructor, or a -// urlAuthResultDefault⁶, in which case the url of this constructor must be opened, -// instead. If the user refuses the authorization request but still wants to open the -// link, the url of this constructor must be used. -// -// Links: -// 1. https://telegram.org/blog/privacy-discussions-web-bots#meet-seamless-web-bots -// 2. https://core.telegram.org/method/messages.requestUrlAuth -// 3. https://core.telegram.org/constructor/urlAuthResultRequest -// 4. https://core.telegram.org/method/messages.acceptUrlAuth -// 5. https://core.telegram.org/constructor/urlAuthResultAccepted -// 6. https://core.telegram.org/constructor/urlAuthResultDefault -// -// See https://core.telegram.org/constructor/keyboardButtonUrlAuth for reference. -type KeyboardButtonURLAuth struct { - // Flags, see TL conditional fields¹ - // - // Links: - // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields - Flags bin.Fields - // Button style, see here »¹ for more info on button styles. - // - // Links: - // 1) https://core.telegram.org/api/bots/buttons#button-styles - // - // Use SetStyle and GetStyle helpers. - Style KeyboardButtonStyle - // Button label - Text string - // New text of the button in forwarded messages. - // - // Use SetFwdText and GetFwdText helpers. - FwdText string - // An HTTP URL to be opened with user authorization data added to the query string when - // the button is pressed. If the user refuses to provide authorization data, the original - // URL without information about the user will be opened. The data added is the same as - // described in Receiving authorization data¹.NOTE: Services must always check the hash - // of the received data to verify the authentication and the integrity of the data as - // described in Checking authorization². - // - // Links: - // 1) https://core.telegram.org/widgets/login#receiving-authorization-data - // 2) https://core.telegram.org/widgets/login#checking-authorization - URL string - // ID of the button to pass to messages.requestUrlAuth¹ - // - // Links: - // 1) https://core.telegram.org/method/messages.requestUrlAuth - ButtonID int -} - -// KeyboardButtonURLAuthTypeID is TL type id of KeyboardButtonURLAuth. -const KeyboardButtonURLAuthTypeID = 0xf51006f9 - -// construct implements constructor of KeyboardButtonClass. -func (k KeyboardButtonURLAuth) construct() KeyboardButtonClass { return &k } - -// Ensuring interfaces in compile-time for KeyboardButtonURLAuth. -var ( - _ bin.Encoder = &KeyboardButtonURLAuth{} - _ bin.Decoder = &KeyboardButtonURLAuth{} - _ bin.BareEncoder = &KeyboardButtonURLAuth{} - _ bin.BareDecoder = &KeyboardButtonURLAuth{} - - _ KeyboardButtonClass = &KeyboardButtonURLAuth{} -) - -func (k *KeyboardButtonURLAuth) Zero() bool { - if k == nil { - return true - } - if !(k.Flags.Zero()) { - return false - } - if !(k.Style.Zero()) { - return false - } - if !(k.Text == "") { - return false - } - if !(k.FwdText == "") { - return false - } - if !(k.URL == "") { - return false - } - if !(k.ButtonID == 0) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (k *KeyboardButtonURLAuth) String() string { - if k == nil { - return "KeyboardButtonURLAuth(nil)" - } - type Alias KeyboardButtonURLAuth - return fmt.Sprintf("KeyboardButtonURLAuth%+v", Alias(*k)) -} - -// FillFrom fills KeyboardButtonURLAuth from given interface. -func (k *KeyboardButtonURLAuth) FillFrom(from interface { - GetStyle() (value KeyboardButtonStyle, ok bool) - GetText() (value string) - GetFwdText() (value string, ok bool) - GetURL() (value string) - GetButtonID() (value int) -}) { - if val, ok := from.GetStyle(); ok { - k.Style = val - } - - k.Text = from.GetText() - if val, ok := from.GetFwdText(); ok { - k.FwdText = val - } - - k.URL = from.GetURL() - k.ButtonID = from.GetButtonID() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*KeyboardButtonURLAuth) TypeID() uint32 { - return KeyboardButtonURLAuthTypeID -} - -// TypeName returns name of type in TL schema. -func (*KeyboardButtonURLAuth) TypeName() string { - return "keyboardButtonUrlAuth" -} - -// TypeInfo returns info about TL type. -func (k *KeyboardButtonURLAuth) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "keyboardButtonUrlAuth", - ID: KeyboardButtonURLAuthTypeID, - } - if k == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Style", - SchemaName: "style", - Null: !k.Flags.Has(10), - }, - { - Name: "Text", - SchemaName: "text", - }, - { - Name: "FwdText", - SchemaName: "fwd_text", - Null: !k.Flags.Has(0), - }, - { - Name: "URL", - SchemaName: "url", - }, - { - Name: "ButtonID", - SchemaName: "button_id", - }, - } - return typ -} - -// SetFlags sets flags for non-zero fields. -func (k *KeyboardButtonURLAuth) SetFlags() { - if !(k.Style.Zero()) { - k.Flags.Set(10) - } - if !(k.FwdText == "") { - k.Flags.Set(0) - } -} - -// Encode implements bin.Encoder. -func (k *KeyboardButtonURLAuth) Encode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonUrlAuth#f51006f9 as nil") - } - b.PutID(KeyboardButtonURLAuthTypeID) - return k.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (k *KeyboardButtonURLAuth) EncodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonUrlAuth#f51006f9 as nil") - } - k.SetFlags() - if err := k.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonUrlAuth#f51006f9: field flags: %w", err) - } - if k.Flags.Has(10) { - if err := k.Style.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonUrlAuth#f51006f9: field style: %w", err) - } - } - b.PutString(k.Text) - if k.Flags.Has(0) { - b.PutString(k.FwdText) - } - b.PutString(k.URL) - b.PutInt(k.ButtonID) - return nil -} - -// Decode implements bin.Decoder. -func (k *KeyboardButtonURLAuth) Decode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonUrlAuth#f51006f9 to nil") - } - if err := b.ConsumeID(KeyboardButtonURLAuthTypeID); err != nil { - return fmt.Errorf("unable to decode keyboardButtonUrlAuth#f51006f9: %w", err) - } - return k.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (k *KeyboardButtonURLAuth) DecodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonUrlAuth#f51006f9 to nil") - } - { - if err := k.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonUrlAuth#f51006f9: field flags: %w", err) - } - } - if k.Flags.Has(10) { - if err := k.Style.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonUrlAuth#f51006f9: field style: %w", err) - } - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonUrlAuth#f51006f9: field text: %w", err) - } - k.Text = value - } - if k.Flags.Has(0) { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonUrlAuth#f51006f9: field fwd_text: %w", err) - } - k.FwdText = value - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonUrlAuth#f51006f9: field url: %w", err) - } - k.URL = value - } - { - value, err := b.Int() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonUrlAuth#f51006f9: field button_id: %w", err) - } - k.ButtonID = value - } - return nil -} - -// SetStyle sets value of Style conditional field. -func (k *KeyboardButtonURLAuth) SetStyle(value KeyboardButtonStyle) { - k.Flags.Set(10) - k.Style = value -} - -// GetStyle returns value of Style conditional field and -// boolean which is true if field was set. -func (k *KeyboardButtonURLAuth) GetStyle() (value KeyboardButtonStyle, ok bool) { - if k == nil { - return - } - if !k.Flags.Has(10) { - return value, false - } - return k.Style, true -} - -// GetText returns value of Text field. -func (k *KeyboardButtonURLAuth) GetText() (value string) { - if k == nil { - return - } - return k.Text -} - -// SetFwdText sets value of FwdText conditional field. -func (k *KeyboardButtonURLAuth) SetFwdText(value string) { - k.Flags.Set(0) - k.FwdText = value -} - -// GetFwdText returns value of FwdText conditional field and -// boolean which is true if field was set. -func (k *KeyboardButtonURLAuth) GetFwdText() (value string, ok bool) { - if k == nil { - return - } - if !k.Flags.Has(0) { - return value, false - } - return k.FwdText, true -} - -// GetURL returns value of URL field. -func (k *KeyboardButtonURLAuth) GetURL() (value string) { - if k == nil { - return - } - return k.URL -} - -// GetButtonID returns value of ButtonID field. -func (k *KeyboardButtonURLAuth) GetButtonID() (value int) { - if k == nil { - return - } - return k.ButtonID -} - -// InputKeyboardButtonURLAuth represents TL type `inputKeyboardButtonUrlAuth#68013e72`. -// Button to request a user to authorize¹ via URL using Seamless Telegram Login². -// -// Links: -// 1. https://core.telegram.org/method/messages.acceptUrlAuth -// 2. https://telegram.org/blog/privacy-discussions-web-bots#meet-seamless-web-bots -// -// See https://core.telegram.org/constructor/inputKeyboardButtonUrlAuth for reference. -type InputKeyboardButtonURLAuth struct { - // Flags, see TL conditional fields¹ - // - // Links: - // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields - Flags bin.Fields - // Set this flag to request the permission for your bot to send messages to the user. - RequestWriteAccess bool - // Button style, see here »¹ for more info on button styles. - // - // Links: - // 1) https://core.telegram.org/api/bots/buttons#button-styles - // - // Use SetStyle and GetStyle helpers. - Style KeyboardButtonStyle - // Button text - Text string - // New text of the button in forwarded messages. - // - // Use SetFwdText and GetFwdText helpers. - FwdText string - // An HTTP URL to be opened with user authorization data added to the query string when - // the button is pressed. If the user refuses to provide authorization data, the original - // URL without information about the user will be opened. The data added is the same as - // described in Receiving authorization data¹.NOTE: You must always check the hash of - // the received data to verify the authentication and the integrity of the data as - // described in Checking authorization². - // - // Links: - // 1) https://core.telegram.org/widgets/login#receiving-authorization-data - // 2) https://core.telegram.org/widgets/login#checking-authorization - URL string - // Username of a bot, which will be used for user authorization. See Setting up a bot¹ - // for more details. If not specified, the current bot's username will be assumed. The - // url's domain must be the same as the domain linked with the bot. See Linking your - // domain to the bot² for more details. - // - // Links: - // 1) https://core.telegram.org/widgets/login#setting-up-a-bot - // 2) https://core.telegram.org/widgets/login#linking-your-domain-to-the-bot - Bot InputUserClass -} - -// InputKeyboardButtonURLAuthTypeID is TL type id of InputKeyboardButtonURLAuth. -const InputKeyboardButtonURLAuthTypeID = 0x68013e72 - -// construct implements constructor of KeyboardButtonClass. -func (i InputKeyboardButtonURLAuth) construct() KeyboardButtonClass { return &i } - -// Ensuring interfaces in compile-time for InputKeyboardButtonURLAuth. -var ( - _ bin.Encoder = &InputKeyboardButtonURLAuth{} - _ bin.Decoder = &InputKeyboardButtonURLAuth{} - _ bin.BareEncoder = &InputKeyboardButtonURLAuth{} - _ bin.BareDecoder = &InputKeyboardButtonURLAuth{} - - _ KeyboardButtonClass = &InputKeyboardButtonURLAuth{} -) - -func (i *InputKeyboardButtonURLAuth) Zero() bool { - if i == nil { - return true - } - if !(i.Flags.Zero()) { - return false - } - if !(i.RequestWriteAccess == false) { - return false - } - if !(i.Style.Zero()) { - return false - } - if !(i.Text == "") { - return false - } - if !(i.FwdText == "") { - return false - } - if !(i.URL == "") { - return false - } - if !(i.Bot == nil) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (i *InputKeyboardButtonURLAuth) String() string { - if i == nil { - return "InputKeyboardButtonURLAuth(nil)" - } - type Alias InputKeyboardButtonURLAuth - return fmt.Sprintf("InputKeyboardButtonURLAuth%+v", Alias(*i)) -} - -// FillFrom fills InputKeyboardButtonURLAuth from given interface. -func (i *InputKeyboardButtonURLAuth) FillFrom(from interface { - GetRequestWriteAccess() (value bool) - GetStyle() (value KeyboardButtonStyle, ok bool) - GetText() (value string) - GetFwdText() (value string, ok bool) - GetURL() (value string) - GetBot() (value InputUserClass) -}) { - i.RequestWriteAccess = from.GetRequestWriteAccess() - if val, ok := from.GetStyle(); ok { - i.Style = val - } - - i.Text = from.GetText() - if val, ok := from.GetFwdText(); ok { - i.FwdText = val - } - - i.URL = from.GetURL() - i.Bot = from.GetBot() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*InputKeyboardButtonURLAuth) TypeID() uint32 { - return InputKeyboardButtonURLAuthTypeID -} - -// TypeName returns name of type in TL schema. -func (*InputKeyboardButtonURLAuth) TypeName() string { - return "inputKeyboardButtonUrlAuth" -} - -// TypeInfo returns info about TL type. -func (i *InputKeyboardButtonURLAuth) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "inputKeyboardButtonUrlAuth", - ID: InputKeyboardButtonURLAuthTypeID, - } - if i == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "RequestWriteAccess", - SchemaName: "request_write_access", - Null: !i.Flags.Has(0), - }, - { - Name: "Style", - SchemaName: "style", - Null: !i.Flags.Has(10), - }, - { - Name: "Text", - SchemaName: "text", - }, - { - Name: "FwdText", - SchemaName: "fwd_text", - Null: !i.Flags.Has(1), - }, - { - Name: "URL", - SchemaName: "url", - }, - { - Name: "Bot", - SchemaName: "bot", - }, - } - return typ -} - -// SetFlags sets flags for non-zero fields. -func (i *InputKeyboardButtonURLAuth) SetFlags() { - if !(i.RequestWriteAccess == false) { - i.Flags.Set(0) - } - if !(i.Style.Zero()) { - i.Flags.Set(10) - } - if !(i.FwdText == "") { - i.Flags.Set(1) - } -} - -// Encode implements bin.Encoder. -func (i *InputKeyboardButtonURLAuth) Encode(b *bin.Buffer) error { - if i == nil { - return fmt.Errorf("can't encode inputKeyboardButtonUrlAuth#68013e72 as nil") - } - b.PutID(InputKeyboardButtonURLAuthTypeID) - return i.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (i *InputKeyboardButtonURLAuth) EncodeBare(b *bin.Buffer) error { - if i == nil { - return fmt.Errorf("can't encode inputKeyboardButtonUrlAuth#68013e72 as nil") - } - i.SetFlags() - if err := i.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode inputKeyboardButtonUrlAuth#68013e72: field flags: %w", err) - } - if i.Flags.Has(10) { - if err := i.Style.Encode(b); err != nil { - return fmt.Errorf("unable to encode inputKeyboardButtonUrlAuth#68013e72: field style: %w", err) - } - } - b.PutString(i.Text) - if i.Flags.Has(1) { - b.PutString(i.FwdText) - } - b.PutString(i.URL) - if i.Bot == nil { - return fmt.Errorf("unable to encode inputKeyboardButtonUrlAuth#68013e72: field bot is nil") - } - if err := i.Bot.Encode(b); err != nil { - return fmt.Errorf("unable to encode inputKeyboardButtonUrlAuth#68013e72: field bot: %w", err) - } - return nil -} - -// Decode implements bin.Decoder. -func (i *InputKeyboardButtonURLAuth) Decode(b *bin.Buffer) error { - if i == nil { - return fmt.Errorf("can't decode inputKeyboardButtonUrlAuth#68013e72 to nil") - } - if err := b.ConsumeID(InputKeyboardButtonURLAuthTypeID); err != nil { - return fmt.Errorf("unable to decode inputKeyboardButtonUrlAuth#68013e72: %w", err) - } - return i.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (i *InputKeyboardButtonURLAuth) DecodeBare(b *bin.Buffer) error { - if i == nil { - return fmt.Errorf("can't decode inputKeyboardButtonUrlAuth#68013e72 to nil") - } - { - if err := i.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode inputKeyboardButtonUrlAuth#68013e72: field flags: %w", err) - } - } - i.RequestWriteAccess = i.Flags.Has(0) - if i.Flags.Has(10) { - if err := i.Style.Decode(b); err != nil { - return fmt.Errorf("unable to decode inputKeyboardButtonUrlAuth#68013e72: field style: %w", err) - } - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode inputKeyboardButtonUrlAuth#68013e72: field text: %w", err) - } - i.Text = value - } - if i.Flags.Has(1) { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode inputKeyboardButtonUrlAuth#68013e72: field fwd_text: %w", err) - } - i.FwdText = value - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode inputKeyboardButtonUrlAuth#68013e72: field url: %w", err) - } - i.URL = value - } - { - value, err := DecodeInputUser(b) - if err != nil { - return fmt.Errorf("unable to decode inputKeyboardButtonUrlAuth#68013e72: field bot: %w", err) - } - i.Bot = value - } - return nil -} - -// SetRequestWriteAccess sets value of RequestWriteAccess conditional field. -func (i *InputKeyboardButtonURLAuth) SetRequestWriteAccess(value bool) { - if value { - i.Flags.Set(0) - i.RequestWriteAccess = true - } else { - i.Flags.Unset(0) - i.RequestWriteAccess = false - } -} - -// GetRequestWriteAccess returns value of RequestWriteAccess conditional field. -func (i *InputKeyboardButtonURLAuth) GetRequestWriteAccess() (value bool) { - if i == nil { - return - } - return i.Flags.Has(0) -} - -// SetStyle sets value of Style conditional field. -func (i *InputKeyboardButtonURLAuth) SetStyle(value KeyboardButtonStyle) { - i.Flags.Set(10) - i.Style = value -} - -// GetStyle returns value of Style conditional field and -// boolean which is true if field was set. -func (i *InputKeyboardButtonURLAuth) GetStyle() (value KeyboardButtonStyle, ok bool) { - if i == nil { - return - } - if !i.Flags.Has(10) { - return value, false - } - return i.Style, true -} - -// GetText returns value of Text field. -func (i *InputKeyboardButtonURLAuth) GetText() (value string) { - if i == nil { - return - } - return i.Text -} - -// SetFwdText sets value of FwdText conditional field. -func (i *InputKeyboardButtonURLAuth) SetFwdText(value string) { - i.Flags.Set(1) - i.FwdText = value -} - -// GetFwdText returns value of FwdText conditional field and -// boolean which is true if field was set. -func (i *InputKeyboardButtonURLAuth) GetFwdText() (value string, ok bool) { - if i == nil { - return - } - if !i.Flags.Has(1) { - return value, false - } - return i.FwdText, true -} - -// GetURL returns value of URL field. -func (i *InputKeyboardButtonURLAuth) GetURL() (value string) { - if i == nil { - return - } - return i.URL -} - -// GetBot returns value of Bot field. -func (i *InputKeyboardButtonURLAuth) GetBot() (value InputUserClass) { - if i == nil { - return - } - return i.Bot -} - -// KeyboardButtonRequestPoll represents TL type `keyboardButtonRequestPoll#7a11d782`. -// A button that allows the user to create and send a poll when pressed; available only -// in private -// -// See https://core.telegram.org/constructor/keyboardButtonRequestPoll for reference. -type KeyboardButtonRequestPoll struct { - // Flags, see TL conditional fields¹ - // - // Links: - // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields - Flags bin.Fields - // Button style, see here »¹ for more info on button styles. - // - // Links: - // 1) https://core.telegram.org/api/bots/buttons#button-styles - // - // Use SetStyle and GetStyle helpers. - Style KeyboardButtonStyle - // If set, only quiz polls can be sent - // - // Use SetQuiz and GetQuiz helpers. - Quiz bool - // Button text - Text string -} - -// KeyboardButtonRequestPollTypeID is TL type id of KeyboardButtonRequestPoll. -const KeyboardButtonRequestPollTypeID = 0x7a11d782 - -// construct implements constructor of KeyboardButtonClass. -func (k KeyboardButtonRequestPoll) construct() KeyboardButtonClass { return &k } - -// Ensuring interfaces in compile-time for KeyboardButtonRequestPoll. -var ( - _ bin.Encoder = &KeyboardButtonRequestPoll{} - _ bin.Decoder = &KeyboardButtonRequestPoll{} - _ bin.BareEncoder = &KeyboardButtonRequestPoll{} - _ bin.BareDecoder = &KeyboardButtonRequestPoll{} - - _ KeyboardButtonClass = &KeyboardButtonRequestPoll{} -) - -func (k *KeyboardButtonRequestPoll) Zero() bool { - if k == nil { - return true - } - if !(k.Flags.Zero()) { - return false - } - if !(k.Style.Zero()) { - return false - } - if !(k.Quiz == false) { - return false - } - if !(k.Text == "") { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (k *KeyboardButtonRequestPoll) String() string { - if k == nil { - return "KeyboardButtonRequestPoll(nil)" - } - type Alias KeyboardButtonRequestPoll - return fmt.Sprintf("KeyboardButtonRequestPoll%+v", Alias(*k)) -} - -// FillFrom fills KeyboardButtonRequestPoll from given interface. -func (k *KeyboardButtonRequestPoll) FillFrom(from interface { - GetStyle() (value KeyboardButtonStyle, ok bool) - GetQuiz() (value bool, ok bool) - GetText() (value string) -}) { - if val, ok := from.GetStyle(); ok { - k.Style = val - } - - if val, ok := from.GetQuiz(); ok { - k.Quiz = val - } - - k.Text = from.GetText() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*KeyboardButtonRequestPoll) TypeID() uint32 { - return KeyboardButtonRequestPollTypeID -} - -// TypeName returns name of type in TL schema. -func (*KeyboardButtonRequestPoll) TypeName() string { - return "keyboardButtonRequestPoll" -} - -// TypeInfo returns info about TL type. -func (k *KeyboardButtonRequestPoll) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "keyboardButtonRequestPoll", - ID: KeyboardButtonRequestPollTypeID, - } - if k == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Style", - SchemaName: "style", - Null: !k.Flags.Has(10), - }, - { - Name: "Quiz", - SchemaName: "quiz", - Null: !k.Flags.Has(0), - }, - { - Name: "Text", - SchemaName: "text", - }, - } - return typ -} - -// SetFlags sets flags for non-zero fields. -func (k *KeyboardButtonRequestPoll) SetFlags() { - if !(k.Style.Zero()) { - k.Flags.Set(10) - } - if !(k.Quiz == false) { - k.Flags.Set(0) - } -} - -// Encode implements bin.Encoder. -func (k *KeyboardButtonRequestPoll) Encode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonRequestPoll#7a11d782 as nil") - } - b.PutID(KeyboardButtonRequestPollTypeID) - return k.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (k *KeyboardButtonRequestPoll) EncodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonRequestPoll#7a11d782 as nil") - } - k.SetFlags() - if err := k.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonRequestPoll#7a11d782: field flags: %w", err) - } - if k.Flags.Has(10) { - if err := k.Style.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonRequestPoll#7a11d782: field style: %w", err) - } - } - if k.Flags.Has(0) { - b.PutBool(k.Quiz) - } - b.PutString(k.Text) - return nil -} - -// Decode implements bin.Decoder. -func (k *KeyboardButtonRequestPoll) Decode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonRequestPoll#7a11d782 to nil") - } - if err := b.ConsumeID(KeyboardButtonRequestPollTypeID); err != nil { - return fmt.Errorf("unable to decode keyboardButtonRequestPoll#7a11d782: %w", err) - } - return k.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (k *KeyboardButtonRequestPoll) DecodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonRequestPoll#7a11d782 to nil") - } - { - if err := k.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonRequestPoll#7a11d782: field flags: %w", err) - } - } - if k.Flags.Has(10) { - if err := k.Style.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonRequestPoll#7a11d782: field style: %w", err) - } - } - if k.Flags.Has(0) { - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonRequestPoll#7a11d782: field quiz: %w", err) - } - k.Quiz = value - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonRequestPoll#7a11d782: field text: %w", err) - } - k.Text = value - } - return nil -} - -// SetStyle sets value of Style conditional field. -func (k *KeyboardButtonRequestPoll) SetStyle(value KeyboardButtonStyle) { - k.Flags.Set(10) - k.Style = value -} - -// GetStyle returns value of Style conditional field and -// boolean which is true if field was set. -func (k *KeyboardButtonRequestPoll) GetStyle() (value KeyboardButtonStyle, ok bool) { - if k == nil { - return - } - if !k.Flags.Has(10) { - return value, false - } - return k.Style, true -} - -// SetQuiz sets value of Quiz conditional field. -func (k *KeyboardButtonRequestPoll) SetQuiz(value bool) { - k.Flags.Set(0) - k.Quiz = value -} - -// GetQuiz returns value of Quiz conditional field and -// boolean which is true if field was set. -func (k *KeyboardButtonRequestPoll) GetQuiz() (value bool, ok bool) { - if k == nil { - return - } - if !k.Flags.Has(0) { - return value, false - } - return k.Quiz, true -} - -// GetText returns value of Text field. -func (k *KeyboardButtonRequestPoll) GetText() (value string) { - if k == nil { - return - } - return k.Text -} - -// InputKeyboardButtonUserProfile represents TL type `inputKeyboardButtonUserProfile#7d5e07c7`. -// Button that links directly to a user profile -// -// See https://core.telegram.org/constructor/inputKeyboardButtonUserProfile for reference. -type InputKeyboardButtonUserProfile struct { - // Flags, see TL conditional fields¹ - // - // Links: - // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields - Flags bin.Fields - // Button style, see here »¹ for more info on button styles. - // - // Links: - // 1) https://core.telegram.org/api/bots/buttons#button-styles - // - // Use SetStyle and GetStyle helpers. - Style KeyboardButtonStyle - // Button text - Text string - // User ID - UserID InputUserClass -} - -// InputKeyboardButtonUserProfileTypeID is TL type id of InputKeyboardButtonUserProfile. -const InputKeyboardButtonUserProfileTypeID = 0x7d5e07c7 - -// construct implements constructor of KeyboardButtonClass. -func (i InputKeyboardButtonUserProfile) construct() KeyboardButtonClass { return &i } - -// Ensuring interfaces in compile-time for InputKeyboardButtonUserProfile. -var ( - _ bin.Encoder = &InputKeyboardButtonUserProfile{} - _ bin.Decoder = &InputKeyboardButtonUserProfile{} - _ bin.BareEncoder = &InputKeyboardButtonUserProfile{} - _ bin.BareDecoder = &InputKeyboardButtonUserProfile{} - - _ KeyboardButtonClass = &InputKeyboardButtonUserProfile{} -) - -func (i *InputKeyboardButtonUserProfile) Zero() bool { - if i == nil { - return true - } - if !(i.Flags.Zero()) { - return false - } - if !(i.Style.Zero()) { - return false - } - if !(i.Text == "") { - return false - } - if !(i.UserID == nil) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (i *InputKeyboardButtonUserProfile) String() string { - if i == nil { - return "InputKeyboardButtonUserProfile(nil)" - } - type Alias InputKeyboardButtonUserProfile - return fmt.Sprintf("InputKeyboardButtonUserProfile%+v", Alias(*i)) -} - -// FillFrom fills InputKeyboardButtonUserProfile from given interface. -func (i *InputKeyboardButtonUserProfile) FillFrom(from interface { - GetStyle() (value KeyboardButtonStyle, ok bool) - GetText() (value string) - GetUserID() (value InputUserClass) -}) { - if val, ok := from.GetStyle(); ok { - i.Style = val - } - - i.Text = from.GetText() - i.UserID = from.GetUserID() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*InputKeyboardButtonUserProfile) TypeID() uint32 { - return InputKeyboardButtonUserProfileTypeID -} - -// TypeName returns name of type in TL schema. -func (*InputKeyboardButtonUserProfile) TypeName() string { - return "inputKeyboardButtonUserProfile" -} - -// TypeInfo returns info about TL type. -func (i *InputKeyboardButtonUserProfile) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "inputKeyboardButtonUserProfile", - ID: InputKeyboardButtonUserProfileTypeID, - } - if i == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Style", - SchemaName: "style", - Null: !i.Flags.Has(10), - }, - { - Name: "Text", - SchemaName: "text", - }, - { - Name: "UserID", - SchemaName: "user_id", - }, - } - return typ -} - -// SetFlags sets flags for non-zero fields. -func (i *InputKeyboardButtonUserProfile) SetFlags() { - if !(i.Style.Zero()) { - i.Flags.Set(10) - } -} - -// Encode implements bin.Encoder. -func (i *InputKeyboardButtonUserProfile) Encode(b *bin.Buffer) error { - if i == nil { - return fmt.Errorf("can't encode inputKeyboardButtonUserProfile#7d5e07c7 as nil") - } - b.PutID(InputKeyboardButtonUserProfileTypeID) - return i.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (i *InputKeyboardButtonUserProfile) EncodeBare(b *bin.Buffer) error { - if i == nil { - return fmt.Errorf("can't encode inputKeyboardButtonUserProfile#7d5e07c7 as nil") - } - i.SetFlags() - if err := i.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode inputKeyboardButtonUserProfile#7d5e07c7: field flags: %w", err) - } - if i.Flags.Has(10) { - if err := i.Style.Encode(b); err != nil { - return fmt.Errorf("unable to encode inputKeyboardButtonUserProfile#7d5e07c7: field style: %w", err) - } - } - b.PutString(i.Text) - if i.UserID == nil { - return fmt.Errorf("unable to encode inputKeyboardButtonUserProfile#7d5e07c7: field user_id is nil") - } - if err := i.UserID.Encode(b); err != nil { - return fmt.Errorf("unable to encode inputKeyboardButtonUserProfile#7d5e07c7: field user_id: %w", err) - } - return nil -} - -// Decode implements bin.Decoder. -func (i *InputKeyboardButtonUserProfile) Decode(b *bin.Buffer) error { - if i == nil { - return fmt.Errorf("can't decode inputKeyboardButtonUserProfile#7d5e07c7 to nil") - } - if err := b.ConsumeID(InputKeyboardButtonUserProfileTypeID); err != nil { - return fmt.Errorf("unable to decode inputKeyboardButtonUserProfile#7d5e07c7: %w", err) - } - return i.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (i *InputKeyboardButtonUserProfile) DecodeBare(b *bin.Buffer) error { - if i == nil { - return fmt.Errorf("can't decode inputKeyboardButtonUserProfile#7d5e07c7 to nil") - } - { - if err := i.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode inputKeyboardButtonUserProfile#7d5e07c7: field flags: %w", err) - } - } - if i.Flags.Has(10) { - if err := i.Style.Decode(b); err != nil { - return fmt.Errorf("unable to decode inputKeyboardButtonUserProfile#7d5e07c7: field style: %w", err) - } - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode inputKeyboardButtonUserProfile#7d5e07c7: field text: %w", err) - } - i.Text = value - } - { - value, err := DecodeInputUser(b) - if err != nil { - return fmt.Errorf("unable to decode inputKeyboardButtonUserProfile#7d5e07c7: field user_id: %w", err) - } - i.UserID = value - } - return nil -} - -// SetStyle sets value of Style conditional field. -func (i *InputKeyboardButtonUserProfile) SetStyle(value KeyboardButtonStyle) { - i.Flags.Set(10) - i.Style = value -} - -// GetStyle returns value of Style conditional field and -// boolean which is true if field was set. -func (i *InputKeyboardButtonUserProfile) GetStyle() (value KeyboardButtonStyle, ok bool) { - if i == nil { - return - } - if !i.Flags.Has(10) { - return value, false - } - return i.Style, true -} - -// GetText returns value of Text field. -func (i *InputKeyboardButtonUserProfile) GetText() (value string) { - if i == nil { - return - } - return i.Text -} - -// GetUserID returns value of UserID field. -func (i *InputKeyboardButtonUserProfile) GetUserID() (value InputUserClass) { - if i == nil { - return - } - return i.UserID -} - -// KeyboardButtonUserProfile represents TL type `keyboardButtonUserProfile#c0fd5d09`. -// Button that links directly to a user profile -// -// See https://core.telegram.org/constructor/keyboardButtonUserProfile for reference. -type KeyboardButtonUserProfile struct { - // Flags, see TL conditional fields¹ - // - // Links: - // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields - Flags bin.Fields - // Button style, see here »¹ for more info on button styles. - // - // Links: - // 1) https://core.telegram.org/api/bots/buttons#button-styles - // - // Use SetStyle and GetStyle helpers. - Style KeyboardButtonStyle - // Button text - Text string - // User ID - UserID int64 -} - -// KeyboardButtonUserProfileTypeID is TL type id of KeyboardButtonUserProfile. -const KeyboardButtonUserProfileTypeID = 0xc0fd5d09 - -// construct implements constructor of KeyboardButtonClass. -func (k KeyboardButtonUserProfile) construct() KeyboardButtonClass { return &k } - -// Ensuring interfaces in compile-time for KeyboardButtonUserProfile. -var ( - _ bin.Encoder = &KeyboardButtonUserProfile{} - _ bin.Decoder = &KeyboardButtonUserProfile{} - _ bin.BareEncoder = &KeyboardButtonUserProfile{} - _ bin.BareDecoder = &KeyboardButtonUserProfile{} - - _ KeyboardButtonClass = &KeyboardButtonUserProfile{} -) - -func (k *KeyboardButtonUserProfile) Zero() bool { - if k == nil { - return true - } - if !(k.Flags.Zero()) { - return false - } - if !(k.Style.Zero()) { - return false - } - if !(k.Text == "") { - return false - } - if !(k.UserID == 0) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (k *KeyboardButtonUserProfile) String() string { - if k == nil { - return "KeyboardButtonUserProfile(nil)" - } - type Alias KeyboardButtonUserProfile - return fmt.Sprintf("KeyboardButtonUserProfile%+v", Alias(*k)) -} - -// FillFrom fills KeyboardButtonUserProfile from given interface. -func (k *KeyboardButtonUserProfile) FillFrom(from interface { - GetStyle() (value KeyboardButtonStyle, ok bool) - GetText() (value string) - GetUserID() (value int64) -}) { - if val, ok := from.GetStyle(); ok { - k.Style = val - } - - k.Text = from.GetText() - k.UserID = from.GetUserID() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*KeyboardButtonUserProfile) TypeID() uint32 { - return KeyboardButtonUserProfileTypeID -} - -// TypeName returns name of type in TL schema. -func (*KeyboardButtonUserProfile) TypeName() string { - return "keyboardButtonUserProfile" -} - -// TypeInfo returns info about TL type. -func (k *KeyboardButtonUserProfile) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "keyboardButtonUserProfile", - ID: KeyboardButtonUserProfileTypeID, - } - if k == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Style", - SchemaName: "style", - Null: !k.Flags.Has(10), - }, - { - Name: "Text", - SchemaName: "text", - }, - { - Name: "UserID", - SchemaName: "user_id", - }, - } - return typ -} - -// SetFlags sets flags for non-zero fields. -func (k *KeyboardButtonUserProfile) SetFlags() { - if !(k.Style.Zero()) { - k.Flags.Set(10) - } -} - -// Encode implements bin.Encoder. -func (k *KeyboardButtonUserProfile) Encode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonUserProfile#c0fd5d09 as nil") - } - b.PutID(KeyboardButtonUserProfileTypeID) - return k.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (k *KeyboardButtonUserProfile) EncodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonUserProfile#c0fd5d09 as nil") - } - k.SetFlags() - if err := k.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonUserProfile#c0fd5d09: field flags: %w", err) - } - if k.Flags.Has(10) { - if err := k.Style.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonUserProfile#c0fd5d09: field style: %w", err) - } - } - b.PutString(k.Text) - b.PutLong(k.UserID) - return nil -} - -// Decode implements bin.Decoder. -func (k *KeyboardButtonUserProfile) Decode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonUserProfile#c0fd5d09 to nil") - } - if err := b.ConsumeID(KeyboardButtonUserProfileTypeID); err != nil { - return fmt.Errorf("unable to decode keyboardButtonUserProfile#c0fd5d09: %w", err) - } - return k.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (k *KeyboardButtonUserProfile) DecodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonUserProfile#c0fd5d09 to nil") - } - { - if err := k.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonUserProfile#c0fd5d09: field flags: %w", err) - } - } - if k.Flags.Has(10) { - if err := k.Style.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonUserProfile#c0fd5d09: field style: %w", err) - } - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonUserProfile#c0fd5d09: field text: %w", err) - } - k.Text = value - } - { - value, err := b.Long() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonUserProfile#c0fd5d09: field user_id: %w", err) - } - k.UserID = value - } - return nil -} - -// SetStyle sets value of Style conditional field. -func (k *KeyboardButtonUserProfile) SetStyle(value KeyboardButtonStyle) { - k.Flags.Set(10) - k.Style = value -} - -// GetStyle returns value of Style conditional field and -// boolean which is true if field was set. -func (k *KeyboardButtonUserProfile) GetStyle() (value KeyboardButtonStyle, ok bool) { - if k == nil { - return - } - if !k.Flags.Has(10) { - return value, false - } - return k.Style, true -} - -// GetText returns value of Text field. -func (k *KeyboardButtonUserProfile) GetText() (value string) { - if k == nil { - return - } - return k.Text -} - -// GetUserID returns value of UserID field. -func (k *KeyboardButtonUserProfile) GetUserID() (value int64) { - if k == nil { - return - } - return k.UserID -} - -// KeyboardButtonWebView represents TL type `keyboardButtonWebView#e846b1a0`. -// Button to open a bot mini app¹ using messages.requestWebView², sending over user -// information after user confirmation. -// Can only be sent or received as part of an inline keyboard, use -// keyboardButtonSimpleWebView¹ for reply keyboards. -// -// Links: -// 1. https://core.telegram.org/api/bots/webapps -// 2. https://core.telegram.org/method/messages.requestWebView -// 3. https://core.telegram.org/constructor/keyboardButtonSimpleWebView -// -// See https://core.telegram.org/constructor/keyboardButtonWebView for reference. -type KeyboardButtonWebView struct { - // Flags, see TL conditional fields¹ - // - // Links: - // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields - Flags bin.Fields - // Button style, see here »¹ for more info on button styles. - // - // Links: - // 1) https://core.telegram.org/api/bots/buttons#button-styles - // - // Use SetStyle and GetStyle helpers. - Style KeyboardButtonStyle - // Button text - Text string - // Web app url¹ - // - // Links: - // 1) https://core.telegram.org/api/bots/webapps - URL string -} - -// KeyboardButtonWebViewTypeID is TL type id of KeyboardButtonWebView. -const KeyboardButtonWebViewTypeID = 0xe846b1a0 - -// construct implements constructor of KeyboardButtonClass. -func (k KeyboardButtonWebView) construct() KeyboardButtonClass { return &k } - -// Ensuring interfaces in compile-time for KeyboardButtonWebView. -var ( - _ bin.Encoder = &KeyboardButtonWebView{} - _ bin.Decoder = &KeyboardButtonWebView{} - _ bin.BareEncoder = &KeyboardButtonWebView{} - _ bin.BareDecoder = &KeyboardButtonWebView{} - - _ KeyboardButtonClass = &KeyboardButtonWebView{} -) - -func (k *KeyboardButtonWebView) Zero() bool { - if k == nil { - return true - } - if !(k.Flags.Zero()) { - return false - } - if !(k.Style.Zero()) { - return false - } - if !(k.Text == "") { - return false - } - if !(k.URL == "") { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (k *KeyboardButtonWebView) String() string { - if k == nil { - return "KeyboardButtonWebView(nil)" - } - type Alias KeyboardButtonWebView - return fmt.Sprintf("KeyboardButtonWebView%+v", Alias(*k)) -} - -// FillFrom fills KeyboardButtonWebView from given interface. -func (k *KeyboardButtonWebView) FillFrom(from interface { - GetStyle() (value KeyboardButtonStyle, ok bool) - GetText() (value string) - GetURL() (value string) -}) { - if val, ok := from.GetStyle(); ok { - k.Style = val - } - - k.Text = from.GetText() - k.URL = from.GetURL() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*KeyboardButtonWebView) TypeID() uint32 { - return KeyboardButtonWebViewTypeID -} - -// TypeName returns name of type in TL schema. -func (*KeyboardButtonWebView) TypeName() string { - return "keyboardButtonWebView" -} - -// TypeInfo returns info about TL type. -func (k *KeyboardButtonWebView) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "keyboardButtonWebView", - ID: KeyboardButtonWebViewTypeID, - } - if k == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Style", - SchemaName: "style", - Null: !k.Flags.Has(10), - }, - { - Name: "Text", - SchemaName: "text", - }, - { - Name: "URL", - SchemaName: "url", - }, - } - return typ -} - -// SetFlags sets flags for non-zero fields. -func (k *KeyboardButtonWebView) SetFlags() { - if !(k.Style.Zero()) { - k.Flags.Set(10) - } -} - -// Encode implements bin.Encoder. -func (k *KeyboardButtonWebView) Encode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonWebView#e846b1a0 as nil") - } - b.PutID(KeyboardButtonWebViewTypeID) - return k.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (k *KeyboardButtonWebView) EncodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonWebView#e846b1a0 as nil") - } - k.SetFlags() - if err := k.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonWebView#e846b1a0: field flags: %w", err) - } - if k.Flags.Has(10) { - if err := k.Style.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonWebView#e846b1a0: field style: %w", err) - } - } - b.PutString(k.Text) - b.PutString(k.URL) - return nil -} - -// Decode implements bin.Decoder. -func (k *KeyboardButtonWebView) Decode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonWebView#e846b1a0 to nil") - } - if err := b.ConsumeID(KeyboardButtonWebViewTypeID); err != nil { - return fmt.Errorf("unable to decode keyboardButtonWebView#e846b1a0: %w", err) - } - return k.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (k *KeyboardButtonWebView) DecodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonWebView#e846b1a0 to nil") - } - { - if err := k.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonWebView#e846b1a0: field flags: %w", err) - } - } - if k.Flags.Has(10) { - if err := k.Style.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonWebView#e846b1a0: field style: %w", err) - } - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonWebView#e846b1a0: field text: %w", err) - } - k.Text = value - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonWebView#e846b1a0: field url: %w", err) - } - k.URL = value - } - return nil -} - -// SetStyle sets value of Style conditional field. -func (k *KeyboardButtonWebView) SetStyle(value KeyboardButtonStyle) { - k.Flags.Set(10) - k.Style = value -} - -// GetStyle returns value of Style conditional field and -// boolean which is true if field was set. -func (k *KeyboardButtonWebView) GetStyle() (value KeyboardButtonStyle, ok bool) { - if k == nil { - return - } - if !k.Flags.Has(10) { - return value, false - } - return k.Style, true -} - -// GetText returns value of Text field. -func (k *KeyboardButtonWebView) GetText() (value string) { - if k == nil { - return - } - return k.Text -} - -// GetURL returns value of URL field. -func (k *KeyboardButtonWebView) GetURL() (value string) { - if k == nil { - return - } - return k.URL -} - -// KeyboardButtonSimpleWebView represents TL type `keyboardButtonSimpleWebView#e15c4370`. -// Button to open a bot mini app¹ using messages.requestSimpleWebView², without sending -// user information to the web app. -// Can only be sent or received as part of a reply keyboard, use keyboardButtonWebView¹ -// for inline keyboards. -// -// Links: -// 1. https://core.telegram.org/api/bots/webapps -// 2. https://core.telegram.org/method/messages.requestSimpleWebView -// 3. https://core.telegram.org/constructor/keyboardButtonWebView -// -// See https://core.telegram.org/constructor/keyboardButtonSimpleWebView for reference. -type KeyboardButtonSimpleWebView struct { - // Flags, see TL conditional fields¹ - // - // Links: - // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields - Flags bin.Fields - // Button style, see here »¹ for more info on button styles. - // - // Links: - // 1) https://core.telegram.org/api/bots/buttons#button-styles - // - // Use SetStyle and GetStyle helpers. - Style KeyboardButtonStyle - // Button text - Text string - // Web app URL¹ - // - // Links: - // 1) https://core.telegram.org/api/bots/webapps - URL string -} - -// KeyboardButtonSimpleWebViewTypeID is TL type id of KeyboardButtonSimpleWebView. -const KeyboardButtonSimpleWebViewTypeID = 0xe15c4370 - -// construct implements constructor of KeyboardButtonClass. -func (k KeyboardButtonSimpleWebView) construct() KeyboardButtonClass { return &k } - -// Ensuring interfaces in compile-time for KeyboardButtonSimpleWebView. -var ( - _ bin.Encoder = &KeyboardButtonSimpleWebView{} - _ bin.Decoder = &KeyboardButtonSimpleWebView{} - _ bin.BareEncoder = &KeyboardButtonSimpleWebView{} - _ bin.BareDecoder = &KeyboardButtonSimpleWebView{} - - _ KeyboardButtonClass = &KeyboardButtonSimpleWebView{} -) - -func (k *KeyboardButtonSimpleWebView) Zero() bool { - if k == nil { - return true - } - if !(k.Flags.Zero()) { - return false - } - if !(k.Style.Zero()) { - return false - } - if !(k.Text == "") { - return false - } - if !(k.URL == "") { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (k *KeyboardButtonSimpleWebView) String() string { - if k == nil { - return "KeyboardButtonSimpleWebView(nil)" - } - type Alias KeyboardButtonSimpleWebView - return fmt.Sprintf("KeyboardButtonSimpleWebView%+v", Alias(*k)) -} - -// FillFrom fills KeyboardButtonSimpleWebView from given interface. -func (k *KeyboardButtonSimpleWebView) FillFrom(from interface { - GetStyle() (value KeyboardButtonStyle, ok bool) - GetText() (value string) - GetURL() (value string) -}) { - if val, ok := from.GetStyle(); ok { - k.Style = val - } - - k.Text = from.GetText() - k.URL = from.GetURL() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*KeyboardButtonSimpleWebView) TypeID() uint32 { - return KeyboardButtonSimpleWebViewTypeID -} - -// TypeName returns name of type in TL schema. -func (*KeyboardButtonSimpleWebView) TypeName() string { - return "keyboardButtonSimpleWebView" -} - -// TypeInfo returns info about TL type. -func (k *KeyboardButtonSimpleWebView) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "keyboardButtonSimpleWebView", - ID: KeyboardButtonSimpleWebViewTypeID, - } - if k == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Style", - SchemaName: "style", - Null: !k.Flags.Has(10), - }, - { - Name: "Text", - SchemaName: "text", - }, - { - Name: "URL", - SchemaName: "url", - }, - } - return typ -} - -// SetFlags sets flags for non-zero fields. -func (k *KeyboardButtonSimpleWebView) SetFlags() { - if !(k.Style.Zero()) { - k.Flags.Set(10) - } -} - -// Encode implements bin.Encoder. -func (k *KeyboardButtonSimpleWebView) Encode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonSimpleWebView#e15c4370 as nil") - } - b.PutID(KeyboardButtonSimpleWebViewTypeID) - return k.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (k *KeyboardButtonSimpleWebView) EncodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonSimpleWebView#e15c4370 as nil") - } - k.SetFlags() - if err := k.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonSimpleWebView#e15c4370: field flags: %w", err) - } - if k.Flags.Has(10) { - if err := k.Style.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonSimpleWebView#e15c4370: field style: %w", err) - } - } - b.PutString(k.Text) - b.PutString(k.URL) - return nil -} - -// Decode implements bin.Decoder. -func (k *KeyboardButtonSimpleWebView) Decode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonSimpleWebView#e15c4370 to nil") - } - if err := b.ConsumeID(KeyboardButtonSimpleWebViewTypeID); err != nil { - return fmt.Errorf("unable to decode keyboardButtonSimpleWebView#e15c4370: %w", err) - } - return k.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (k *KeyboardButtonSimpleWebView) DecodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonSimpleWebView#e15c4370 to nil") - } - { - if err := k.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonSimpleWebView#e15c4370: field flags: %w", err) - } - } - if k.Flags.Has(10) { - if err := k.Style.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonSimpleWebView#e15c4370: field style: %w", err) - } - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonSimpleWebView#e15c4370: field text: %w", err) - } - k.Text = value - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonSimpleWebView#e15c4370: field url: %w", err) - } - k.URL = value - } - return nil -} - -// SetStyle sets value of Style conditional field. -func (k *KeyboardButtonSimpleWebView) SetStyle(value KeyboardButtonStyle) { - k.Flags.Set(10) - k.Style = value -} - -// GetStyle returns value of Style conditional field and -// boolean which is true if field was set. -func (k *KeyboardButtonSimpleWebView) GetStyle() (value KeyboardButtonStyle, ok bool) { - if k == nil { - return - } - if !k.Flags.Has(10) { - return value, false - } - return k.Style, true -} - -// GetText returns value of Text field. -func (k *KeyboardButtonSimpleWebView) GetText() (value string) { - if k == nil { - return - } - return k.Text -} - -// GetURL returns value of URL field. -func (k *KeyboardButtonSimpleWebView) GetURL() (value string) { - if k == nil { - return - } - return k.URL -} - -// KeyboardButtonRequestPeer represents TL type `keyboardButtonRequestPeer#5b0f15f5`. -// Prompts the user to select and share one or more peers with the bot using messages -// sendBotRequestedPeer¹ -// -// Links: -// 1. https://core.telegram.org/method/messages.sendBotRequestedPeer -// -// See https://core.telegram.org/constructor/keyboardButtonRequestPeer for reference. -type KeyboardButtonRequestPeer struct { - // Flags, see TL conditional fields¹ - // - // Links: - // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields - Flags bin.Fields - // Button style, see here »¹ for more info on button styles. - // - // Links: - // 1) https://core.telegram.org/api/bots/buttons#button-styles - // - // Use SetStyle and GetStyle helpers. - Style KeyboardButtonStyle - // Button text - Text string - // Button ID, to be passed to messages.sendBotRequestedPeer¹. - // - // Links: - // 1) https://core.telegram.org/method/messages.sendBotRequestedPeer - ButtonID int - // Filtering criteria to use for the peer selection list shown to the user. The list - // should display all existing peers of the specified type, and should also offer an - // option for the user to create and immediately use one or more (up to max_quantity) - // peers of the specified type, if needed. - PeerType RequestPeerTypeClass - // Maximum number of peers that can be chosen. - MaxQuantity int -} - -// KeyboardButtonRequestPeerTypeID is TL type id of KeyboardButtonRequestPeer. -const KeyboardButtonRequestPeerTypeID = 0x5b0f15f5 - -// construct implements constructor of KeyboardButtonClass. -func (k KeyboardButtonRequestPeer) construct() KeyboardButtonClass { return &k } - -// Ensuring interfaces in compile-time for KeyboardButtonRequestPeer. -var ( - _ bin.Encoder = &KeyboardButtonRequestPeer{} - _ bin.Decoder = &KeyboardButtonRequestPeer{} - _ bin.BareEncoder = &KeyboardButtonRequestPeer{} - _ bin.BareDecoder = &KeyboardButtonRequestPeer{} - - _ KeyboardButtonClass = &KeyboardButtonRequestPeer{} -) - -func (k *KeyboardButtonRequestPeer) Zero() bool { - if k == nil { - return true - } - if !(k.Flags.Zero()) { - return false - } - if !(k.Style.Zero()) { - return false - } - if !(k.Text == "") { - return false - } - if !(k.ButtonID == 0) { - return false - } - if !(k.PeerType == nil) { - return false - } - if !(k.MaxQuantity == 0) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (k *KeyboardButtonRequestPeer) String() string { - if k == nil { - return "KeyboardButtonRequestPeer(nil)" - } - type Alias KeyboardButtonRequestPeer - return fmt.Sprintf("KeyboardButtonRequestPeer%+v", Alias(*k)) -} - -// FillFrom fills KeyboardButtonRequestPeer from given interface. -func (k *KeyboardButtonRequestPeer) FillFrom(from interface { - GetStyle() (value KeyboardButtonStyle, ok bool) - GetText() (value string) - GetButtonID() (value int) - GetPeerType() (value RequestPeerTypeClass) - GetMaxQuantity() (value int) -}) { - if val, ok := from.GetStyle(); ok { - k.Style = val - } - - k.Text = from.GetText() - k.ButtonID = from.GetButtonID() - k.PeerType = from.GetPeerType() - k.MaxQuantity = from.GetMaxQuantity() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*KeyboardButtonRequestPeer) TypeID() uint32 { - return KeyboardButtonRequestPeerTypeID -} - -// TypeName returns name of type in TL schema. -func (*KeyboardButtonRequestPeer) TypeName() string { - return "keyboardButtonRequestPeer" -} - -// TypeInfo returns info about TL type. -func (k *KeyboardButtonRequestPeer) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "keyboardButtonRequestPeer", - ID: KeyboardButtonRequestPeerTypeID, - } - if k == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Style", - SchemaName: "style", - Null: !k.Flags.Has(10), - }, - { - Name: "Text", - SchemaName: "text", - }, - { - Name: "ButtonID", - SchemaName: "button_id", - }, - { - Name: "PeerType", - SchemaName: "peer_type", - }, - { - Name: "MaxQuantity", - SchemaName: "max_quantity", - }, - } - return typ -} - -// SetFlags sets flags for non-zero fields. -func (k *KeyboardButtonRequestPeer) SetFlags() { - if !(k.Style.Zero()) { - k.Flags.Set(10) - } -} - -// Encode implements bin.Encoder. -func (k *KeyboardButtonRequestPeer) Encode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonRequestPeer#5b0f15f5 as nil") - } - b.PutID(KeyboardButtonRequestPeerTypeID) - return k.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (k *KeyboardButtonRequestPeer) EncodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonRequestPeer#5b0f15f5 as nil") - } - k.SetFlags() - if err := k.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonRequestPeer#5b0f15f5: field flags: %w", err) - } - if k.Flags.Has(10) { - if err := k.Style.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonRequestPeer#5b0f15f5: field style: %w", err) - } - } - b.PutString(k.Text) - b.PutInt(k.ButtonID) - if k.PeerType == nil { - return fmt.Errorf("unable to encode keyboardButtonRequestPeer#5b0f15f5: field peer_type is nil") - } - if err := k.PeerType.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonRequestPeer#5b0f15f5: field peer_type: %w", err) - } - b.PutInt(k.MaxQuantity) - return nil -} - -// Decode implements bin.Decoder. -func (k *KeyboardButtonRequestPeer) Decode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonRequestPeer#5b0f15f5 to nil") - } - if err := b.ConsumeID(KeyboardButtonRequestPeerTypeID); err != nil { - return fmt.Errorf("unable to decode keyboardButtonRequestPeer#5b0f15f5: %w", err) - } - return k.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (k *KeyboardButtonRequestPeer) DecodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonRequestPeer#5b0f15f5 to nil") - } - { - if err := k.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonRequestPeer#5b0f15f5: field flags: %w", err) - } - } - if k.Flags.Has(10) { - if err := k.Style.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonRequestPeer#5b0f15f5: field style: %w", err) - } - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonRequestPeer#5b0f15f5: field text: %w", err) - } - k.Text = value - } - { - value, err := b.Int() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonRequestPeer#5b0f15f5: field button_id: %w", err) - } - k.ButtonID = value - } - { - value, err := DecodeRequestPeerType(b) - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonRequestPeer#5b0f15f5: field peer_type: %w", err) - } - k.PeerType = value - } - { - value, err := b.Int() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonRequestPeer#5b0f15f5: field max_quantity: %w", err) - } - k.MaxQuantity = value - } - return nil -} - -// SetStyle sets value of Style conditional field. -func (k *KeyboardButtonRequestPeer) SetStyle(value KeyboardButtonStyle) { - k.Flags.Set(10) - k.Style = value -} - -// GetStyle returns value of Style conditional field and -// boolean which is true if field was set. -func (k *KeyboardButtonRequestPeer) GetStyle() (value KeyboardButtonStyle, ok bool) { - if k == nil { - return - } - if !k.Flags.Has(10) { - return value, false - } - return k.Style, true -} - -// GetText returns value of Text field. -func (k *KeyboardButtonRequestPeer) GetText() (value string) { - if k == nil { - return - } - return k.Text -} - -// GetButtonID returns value of ButtonID field. -func (k *KeyboardButtonRequestPeer) GetButtonID() (value int) { - if k == nil { - return - } - return k.ButtonID -} - -// GetPeerType returns value of PeerType field. -func (k *KeyboardButtonRequestPeer) GetPeerType() (value RequestPeerTypeClass) { - if k == nil { - return - } - return k.PeerType -} - -// GetMaxQuantity returns value of MaxQuantity field. -func (k *KeyboardButtonRequestPeer) GetMaxQuantity() (value int) { - if k == nil { - return - } - return k.MaxQuantity -} - -// InputKeyboardButtonRequestPeer represents TL type `inputKeyboardButtonRequestPeer#2b78156`. -// Prompts the user to select and share one or more peers with the bot using messages -// sendBotRequestedPeer¹. -// -// Links: -// 1. https://core.telegram.org/method/messages.sendBotRequestedPeer -// -// See https://core.telegram.org/constructor/inputKeyboardButtonRequestPeer for reference. -type InputKeyboardButtonRequestPeer struct { - // Flags, see TL conditional fields¹ - // - // Links: - // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields - Flags bin.Fields - // Set this flag to request the peer's name. - NameRequested bool - // Set this flag to request the peer's @username (if any). - UsernameRequested bool - // Set this flag to request the peer's photo (if any). - PhotoRequested bool - // Button style, see here »¹ for more info on button styles. - // - // Links: - // 1) https://core.telegram.org/api/bots/buttons#button-styles - // - // Use SetStyle and GetStyle helpers. - Style KeyboardButtonStyle - // Button text - Text string - // Button ID, to be passed to messages.sendBotRequestedPeer¹. - // - // Links: - // 1) https://core.telegram.org/method/messages.sendBotRequestedPeer - ButtonID int - // Filtering criteria to use for the peer selection list shown to the user. The list - // should display all existing peers of the specified type, and should also offer an - // option for the user to create and immediately use one or more (up to max_quantity) - // peers of the specified type, if needed. - PeerType RequestPeerTypeClass - // Maximum number of peers that can be chosen. - MaxQuantity int -} - -// InputKeyboardButtonRequestPeerTypeID is TL type id of InputKeyboardButtonRequestPeer. -const InputKeyboardButtonRequestPeerTypeID = 0x2b78156 - -// construct implements constructor of KeyboardButtonClass. -func (i InputKeyboardButtonRequestPeer) construct() KeyboardButtonClass { return &i } - -// Ensuring interfaces in compile-time for InputKeyboardButtonRequestPeer. -var ( - _ bin.Encoder = &InputKeyboardButtonRequestPeer{} - _ bin.Decoder = &InputKeyboardButtonRequestPeer{} - _ bin.BareEncoder = &InputKeyboardButtonRequestPeer{} - _ bin.BareDecoder = &InputKeyboardButtonRequestPeer{} - - _ KeyboardButtonClass = &InputKeyboardButtonRequestPeer{} -) - -func (i *InputKeyboardButtonRequestPeer) Zero() bool { - if i == nil { - return true - } - if !(i.Flags.Zero()) { - return false - } - if !(i.NameRequested == false) { - return false - } - if !(i.UsernameRequested == false) { - return false - } - if !(i.PhotoRequested == false) { - return false - } - if !(i.Style.Zero()) { - return false - } - if !(i.Text == "") { - return false - } - if !(i.ButtonID == 0) { - return false - } - if !(i.PeerType == nil) { - return false - } - if !(i.MaxQuantity == 0) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (i *InputKeyboardButtonRequestPeer) String() string { - if i == nil { - return "InputKeyboardButtonRequestPeer(nil)" - } - type Alias InputKeyboardButtonRequestPeer - return fmt.Sprintf("InputKeyboardButtonRequestPeer%+v", Alias(*i)) -} - -// FillFrom fills InputKeyboardButtonRequestPeer from given interface. -func (i *InputKeyboardButtonRequestPeer) FillFrom(from interface { - GetNameRequested() (value bool) - GetUsernameRequested() (value bool) - GetPhotoRequested() (value bool) - GetStyle() (value KeyboardButtonStyle, ok bool) - GetText() (value string) - GetButtonID() (value int) - GetPeerType() (value RequestPeerTypeClass) - GetMaxQuantity() (value int) -}) { - i.NameRequested = from.GetNameRequested() - i.UsernameRequested = from.GetUsernameRequested() - i.PhotoRequested = from.GetPhotoRequested() - if val, ok := from.GetStyle(); ok { - i.Style = val - } - - i.Text = from.GetText() - i.ButtonID = from.GetButtonID() - i.PeerType = from.GetPeerType() - i.MaxQuantity = from.GetMaxQuantity() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*InputKeyboardButtonRequestPeer) TypeID() uint32 { - return InputKeyboardButtonRequestPeerTypeID -} - -// TypeName returns name of type in TL schema. -func (*InputKeyboardButtonRequestPeer) TypeName() string { - return "inputKeyboardButtonRequestPeer" -} - -// TypeInfo returns info about TL type. -func (i *InputKeyboardButtonRequestPeer) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "inputKeyboardButtonRequestPeer", - ID: InputKeyboardButtonRequestPeerTypeID, - } - if i == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "NameRequested", - SchemaName: "name_requested", - Null: !i.Flags.Has(0), - }, - { - Name: "UsernameRequested", - SchemaName: "username_requested", - Null: !i.Flags.Has(1), - }, - { - Name: "PhotoRequested", - SchemaName: "photo_requested", - Null: !i.Flags.Has(2), - }, - { - Name: "Style", - SchemaName: "style", - Null: !i.Flags.Has(10), - }, - { - Name: "Text", - SchemaName: "text", - }, - { - Name: "ButtonID", - SchemaName: "button_id", - }, - { - Name: "PeerType", - SchemaName: "peer_type", - }, - { - Name: "MaxQuantity", - SchemaName: "max_quantity", - }, - } - return typ -} - -// SetFlags sets flags for non-zero fields. -func (i *InputKeyboardButtonRequestPeer) SetFlags() { - if !(i.NameRequested == false) { - i.Flags.Set(0) - } - if !(i.UsernameRequested == false) { - i.Flags.Set(1) - } - if !(i.PhotoRequested == false) { - i.Flags.Set(2) - } - if !(i.Style.Zero()) { - i.Flags.Set(10) - } -} - -// Encode implements bin.Encoder. -func (i *InputKeyboardButtonRequestPeer) Encode(b *bin.Buffer) error { - if i == nil { - return fmt.Errorf("can't encode inputKeyboardButtonRequestPeer#2b78156 as nil") - } - b.PutID(InputKeyboardButtonRequestPeerTypeID) - return i.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (i *InputKeyboardButtonRequestPeer) EncodeBare(b *bin.Buffer) error { - if i == nil { - return fmt.Errorf("can't encode inputKeyboardButtonRequestPeer#2b78156 as nil") - } - i.SetFlags() - if err := i.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode inputKeyboardButtonRequestPeer#2b78156: field flags: %w", err) - } - if i.Flags.Has(10) { - if err := i.Style.Encode(b); err != nil { - return fmt.Errorf("unable to encode inputKeyboardButtonRequestPeer#2b78156: field style: %w", err) - } - } - b.PutString(i.Text) - b.PutInt(i.ButtonID) - if i.PeerType == nil { - return fmt.Errorf("unable to encode inputKeyboardButtonRequestPeer#2b78156: field peer_type is nil") - } - if err := i.PeerType.Encode(b); err != nil { - return fmt.Errorf("unable to encode inputKeyboardButtonRequestPeer#2b78156: field peer_type: %w", err) - } - b.PutInt(i.MaxQuantity) - return nil -} - -// Decode implements bin.Decoder. -func (i *InputKeyboardButtonRequestPeer) Decode(b *bin.Buffer) error { - if i == nil { - return fmt.Errorf("can't decode inputKeyboardButtonRequestPeer#2b78156 to nil") - } - if err := b.ConsumeID(InputKeyboardButtonRequestPeerTypeID); err != nil { - return fmt.Errorf("unable to decode inputKeyboardButtonRequestPeer#2b78156: %w", err) - } - return i.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (i *InputKeyboardButtonRequestPeer) DecodeBare(b *bin.Buffer) error { - if i == nil { - return fmt.Errorf("can't decode inputKeyboardButtonRequestPeer#2b78156 to nil") - } - { - if err := i.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode inputKeyboardButtonRequestPeer#2b78156: field flags: %w", err) - } - } - i.NameRequested = i.Flags.Has(0) - i.UsernameRequested = i.Flags.Has(1) - i.PhotoRequested = i.Flags.Has(2) - if i.Flags.Has(10) { - if err := i.Style.Decode(b); err != nil { - return fmt.Errorf("unable to decode inputKeyboardButtonRequestPeer#2b78156: field style: %w", err) - } - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode inputKeyboardButtonRequestPeer#2b78156: field text: %w", err) - } - i.Text = value - } - { - value, err := b.Int() - if err != nil { - return fmt.Errorf("unable to decode inputKeyboardButtonRequestPeer#2b78156: field button_id: %w", err) - } - i.ButtonID = value - } - { - value, err := DecodeRequestPeerType(b) - if err != nil { - return fmt.Errorf("unable to decode inputKeyboardButtonRequestPeer#2b78156: field peer_type: %w", err) - } - i.PeerType = value - } - { - value, err := b.Int() - if err != nil { - return fmt.Errorf("unable to decode inputKeyboardButtonRequestPeer#2b78156: field max_quantity: %w", err) - } - i.MaxQuantity = value - } - return nil -} - -// SetNameRequested sets value of NameRequested conditional field. -func (i *InputKeyboardButtonRequestPeer) SetNameRequested(value bool) { - if value { - i.Flags.Set(0) - i.NameRequested = true - } else { - i.Flags.Unset(0) - i.NameRequested = false - } -} - -// GetNameRequested returns value of NameRequested conditional field. -func (i *InputKeyboardButtonRequestPeer) GetNameRequested() (value bool) { - if i == nil { - return - } - return i.Flags.Has(0) -} - -// SetUsernameRequested sets value of UsernameRequested conditional field. -func (i *InputKeyboardButtonRequestPeer) SetUsernameRequested(value bool) { - if value { - i.Flags.Set(1) - i.UsernameRequested = true - } else { - i.Flags.Unset(1) - i.UsernameRequested = false - } -} - -// GetUsernameRequested returns value of UsernameRequested conditional field. -func (i *InputKeyboardButtonRequestPeer) GetUsernameRequested() (value bool) { - if i == nil { - return - } - return i.Flags.Has(1) -} - -// SetPhotoRequested sets value of PhotoRequested conditional field. -func (i *InputKeyboardButtonRequestPeer) SetPhotoRequested(value bool) { - if value { - i.Flags.Set(2) - i.PhotoRequested = true - } else { - i.Flags.Unset(2) - i.PhotoRequested = false - } -} - -// GetPhotoRequested returns value of PhotoRequested conditional field. -func (i *InputKeyboardButtonRequestPeer) GetPhotoRequested() (value bool) { - if i == nil { - return - } - return i.Flags.Has(2) -} - -// SetStyle sets value of Style conditional field. -func (i *InputKeyboardButtonRequestPeer) SetStyle(value KeyboardButtonStyle) { - i.Flags.Set(10) - i.Style = value -} - -// GetStyle returns value of Style conditional field and -// boolean which is true if field was set. -func (i *InputKeyboardButtonRequestPeer) GetStyle() (value KeyboardButtonStyle, ok bool) { - if i == nil { - return - } - if !i.Flags.Has(10) { - return value, false - } - return i.Style, true -} - -// GetText returns value of Text field. -func (i *InputKeyboardButtonRequestPeer) GetText() (value string) { - if i == nil { - return - } - return i.Text -} - -// GetButtonID returns value of ButtonID field. -func (i *InputKeyboardButtonRequestPeer) GetButtonID() (value int) { - if i == nil { - return - } - return i.ButtonID -} - -// GetPeerType returns value of PeerType field. -func (i *InputKeyboardButtonRequestPeer) GetPeerType() (value RequestPeerTypeClass) { - if i == nil { - return - } - return i.PeerType -} - -// GetMaxQuantity returns value of MaxQuantity field. -func (i *InputKeyboardButtonRequestPeer) GetMaxQuantity() (value int) { - if i == nil { - return - } - return i.MaxQuantity -} - -// KeyboardButtonCopy represents TL type `keyboardButtonCopy#bcc4af10`. -// Clipboard button: when clicked, the attached text must be copied to the clipboard. -// -// See https://core.telegram.org/constructor/keyboardButtonCopy for reference. -type KeyboardButtonCopy struct { - // Flags, see TL conditional fields¹ - // - // Links: - // 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields - Flags bin.Fields - // Button style, see here »¹ for more info on button styles. - // - // Links: - // 1) https://core.telegram.org/api/bots/buttons#button-styles - // - // Use SetStyle and GetStyle helpers. - Style KeyboardButtonStyle - // Title of the button - Text string - // The text that will be copied to the clipboard - CopyText string -} - -// KeyboardButtonCopyTypeID is TL type id of KeyboardButtonCopy. -const KeyboardButtonCopyTypeID = 0xbcc4af10 - -// construct implements constructor of KeyboardButtonClass. -func (k KeyboardButtonCopy) construct() KeyboardButtonClass { return &k } - -// Ensuring interfaces in compile-time for KeyboardButtonCopy. -var ( - _ bin.Encoder = &KeyboardButtonCopy{} - _ bin.Decoder = &KeyboardButtonCopy{} - _ bin.BareEncoder = &KeyboardButtonCopy{} - _ bin.BareDecoder = &KeyboardButtonCopy{} - - _ KeyboardButtonClass = &KeyboardButtonCopy{} -) - -func (k *KeyboardButtonCopy) Zero() bool { - if k == nil { - return true - } - if !(k.Flags.Zero()) { - return false - } - if !(k.Style.Zero()) { - return false - } - if !(k.Text == "") { - return false - } - if !(k.CopyText == "") { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (k *KeyboardButtonCopy) String() string { - if k == nil { - return "KeyboardButtonCopy(nil)" - } - type Alias KeyboardButtonCopy - return fmt.Sprintf("KeyboardButtonCopy%+v", Alias(*k)) -} - -// FillFrom fills KeyboardButtonCopy from given interface. -func (k *KeyboardButtonCopy) FillFrom(from interface { - GetStyle() (value KeyboardButtonStyle, ok bool) - GetText() (value string) - GetCopyText() (value string) -}) { - if val, ok := from.GetStyle(); ok { - k.Style = val - } - - k.Text = from.GetText() - k.CopyText = from.GetCopyText() -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*KeyboardButtonCopy) TypeID() uint32 { - return KeyboardButtonCopyTypeID -} - -// TypeName returns name of type in TL schema. -func (*KeyboardButtonCopy) TypeName() string { - return "keyboardButtonCopy" -} - -// TypeInfo returns info about TL type. -func (k *KeyboardButtonCopy) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "keyboardButtonCopy", - ID: KeyboardButtonCopyTypeID, - } - if k == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Style", - SchemaName: "style", - Null: !k.Flags.Has(10), - }, - { - Name: "Text", - SchemaName: "text", - }, - { - Name: "CopyText", - SchemaName: "copy_text", - }, - } - return typ -} - -// SetFlags sets flags for non-zero fields. -func (k *KeyboardButtonCopy) SetFlags() { - if !(k.Style.Zero()) { - k.Flags.Set(10) - } -} - -// Encode implements bin.Encoder. -func (k *KeyboardButtonCopy) Encode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonCopy#bcc4af10 as nil") - } - b.PutID(KeyboardButtonCopyTypeID) - return k.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (k *KeyboardButtonCopy) EncodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't encode keyboardButtonCopy#bcc4af10 as nil") - } - k.SetFlags() - if err := k.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonCopy#bcc4af10: field flags: %w", err) - } - if k.Flags.Has(10) { - if err := k.Style.Encode(b); err != nil { - return fmt.Errorf("unable to encode keyboardButtonCopy#bcc4af10: field style: %w", err) - } - } - b.PutString(k.Text) - b.PutString(k.CopyText) - return nil -} - -// Decode implements bin.Decoder. -func (k *KeyboardButtonCopy) Decode(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonCopy#bcc4af10 to nil") - } - if err := b.ConsumeID(KeyboardButtonCopyTypeID); err != nil { - return fmt.Errorf("unable to decode keyboardButtonCopy#bcc4af10: %w", err) - } - return k.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (k *KeyboardButtonCopy) DecodeBare(b *bin.Buffer) error { - if k == nil { - return fmt.Errorf("can't decode keyboardButtonCopy#bcc4af10 to nil") - } - { - if err := k.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonCopy#bcc4af10: field flags: %w", err) - } - } - if k.Flags.Has(10) { - if err := k.Style.Decode(b); err != nil { - return fmt.Errorf("unable to decode keyboardButtonCopy#bcc4af10: field style: %w", err) - } - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonCopy#bcc4af10: field text: %w", err) - } - k.Text = value - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode keyboardButtonCopy#bcc4af10: field copy_text: %w", err) - } - k.CopyText = value - } - return nil -} - -// SetStyle sets value of Style conditional field. -func (k *KeyboardButtonCopy) SetStyle(value KeyboardButtonStyle) { - k.Flags.Set(10) - k.Style = value -} - -// GetStyle returns value of Style conditional field and -// boolean which is true if field was set. -func (k *KeyboardButtonCopy) GetStyle() (value KeyboardButtonStyle, ok bool) { - if k == nil { - return - } - if !k.Flags.Has(10) { - return value, false - } - return k.Style, true -} - -// GetText returns value of Text field. -func (k *KeyboardButtonCopy) GetText() (value string) { - if k == nil { - return - } - return k.Text -} - -// GetCopyText returns value of CopyText field. -func (k *KeyboardButtonCopy) GetCopyText() (value string) { - if k == nil { - return - } - return k.CopyText -} - -// KeyboardButtonClassName is schema name of KeyboardButtonClass. -const KeyboardButtonClassName = "KeyboardButton" - -// KeyboardButtonClass represents KeyboardButton generic type. -// -// See https://core.telegram.org/type/KeyboardButton for reference. -// -// Constructors: -// - [KeyboardButton] -// - [KeyboardButtonURL] -// - [KeyboardButtonCallback] -// - [KeyboardButtonRequestPhone] -// - [KeyboardButtonRequestGeoLocation] -// - [KeyboardButtonSwitchInline] -// - [KeyboardButtonGame] -// - [KeyboardButtonBuy] -// - [KeyboardButtonURLAuth] -// - [InputKeyboardButtonURLAuth] -// - [KeyboardButtonRequestPoll] -// - [InputKeyboardButtonUserProfile] -// - [KeyboardButtonUserProfile] -// - [KeyboardButtonWebView] -// - [KeyboardButtonSimpleWebView] -// - [KeyboardButtonRequestPeer] -// - [InputKeyboardButtonRequestPeer] -// - [KeyboardButtonCopy] -// -// Example: -// -// g, err := tg.DecodeKeyboardButton(buf) -// if err != nil { -// panic(err) -// } -// switch v := g.(type) { -// case *tg.KeyboardButton: // keyboardButton#7d170cff -// case *tg.KeyboardButtonURL: // keyboardButtonUrl#d80c25ec -// case *tg.KeyboardButtonCallback: // keyboardButtonCallback#e62bc960 -// case *tg.KeyboardButtonRequestPhone: // keyboardButtonRequestPhone#417efd8f -// case *tg.KeyboardButtonRequestGeoLocation: // keyboardButtonRequestGeoLocation#aa40f94d -// case *tg.KeyboardButtonSwitchInline: // keyboardButtonSwitchInline#991399fc -// case *tg.KeyboardButtonGame: // keyboardButtonGame#89c590f9 -// case *tg.KeyboardButtonBuy: // keyboardButtonBuy#3fa53905 -// case *tg.KeyboardButtonURLAuth: // keyboardButtonUrlAuth#f51006f9 -// case *tg.InputKeyboardButtonURLAuth: // inputKeyboardButtonUrlAuth#68013e72 -// case *tg.KeyboardButtonRequestPoll: // keyboardButtonRequestPoll#7a11d782 -// case *tg.InputKeyboardButtonUserProfile: // inputKeyboardButtonUserProfile#7d5e07c7 -// case *tg.KeyboardButtonUserProfile: // keyboardButtonUserProfile#c0fd5d09 -// case *tg.KeyboardButtonWebView: // keyboardButtonWebView#e846b1a0 -// case *tg.KeyboardButtonSimpleWebView: // keyboardButtonSimpleWebView#e15c4370 -// case *tg.KeyboardButtonRequestPeer: // keyboardButtonRequestPeer#5b0f15f5 -// case *tg.InputKeyboardButtonRequestPeer: // inputKeyboardButtonRequestPeer#2b78156 -// case *tg.KeyboardButtonCopy: // keyboardButtonCopy#bcc4af10 -// default: panic(v) -// } -type KeyboardButtonClass interface { - bin.Encoder - bin.Decoder - bin.BareEncoder - bin.BareDecoder - construct() KeyboardButtonClass - - // TypeID returns type id in TL schema. - // - // See https://core.telegram.org/mtproto/TL-tl#remarks. - TypeID() uint32 - // TypeName returns name of type in TL schema. - TypeName() string - // String implements fmt.Stringer. - String() string - // Zero returns true if current object has a zero value. - Zero() bool - - // Button style, see here »¹ for more info on button styles. - // - // Links: - // 1) https://core.telegram.org/api/bots/buttons#button-styles - GetStyle() (value KeyboardButtonStyle, ok bool) - - // Button text - GetText() (value string) -} - -// DecodeKeyboardButton implements binary de-serialization for KeyboardButtonClass. -func DecodeKeyboardButton(buf *bin.Buffer) (KeyboardButtonClass, error) { - id, err := buf.PeekID() - if err != nil { - return nil, err - } - switch id { - case KeyboardButtonTypeID: - // Decoding keyboardButton#7d170cff. - v := KeyboardButton{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode KeyboardButtonClass: %w", err) - } - return &v, nil - case KeyboardButtonURLTypeID: - // Decoding keyboardButtonUrl#d80c25ec. - v := KeyboardButtonURL{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode KeyboardButtonClass: %w", err) - } - return &v, nil - case KeyboardButtonCallbackTypeID: - // Decoding keyboardButtonCallback#e62bc960. - v := KeyboardButtonCallback{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode KeyboardButtonClass: %w", err) - } - return &v, nil - case KeyboardButtonRequestPhoneTypeID: - // Decoding keyboardButtonRequestPhone#417efd8f. - v := KeyboardButtonRequestPhone{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode KeyboardButtonClass: %w", err) - } - return &v, nil - case KeyboardButtonRequestGeoLocationTypeID: - // Decoding keyboardButtonRequestGeoLocation#aa40f94d. - v := KeyboardButtonRequestGeoLocation{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode KeyboardButtonClass: %w", err) - } - return &v, nil - case KeyboardButtonSwitchInlineTypeID: - // Decoding keyboardButtonSwitchInline#991399fc. - v := KeyboardButtonSwitchInline{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode KeyboardButtonClass: %w", err) - } - return &v, nil - case KeyboardButtonGameTypeID: - // Decoding keyboardButtonGame#89c590f9. - v := KeyboardButtonGame{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode KeyboardButtonClass: %w", err) - } - return &v, nil - case KeyboardButtonBuyTypeID: - // Decoding keyboardButtonBuy#3fa53905. - v := KeyboardButtonBuy{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode KeyboardButtonClass: %w", err) - } - return &v, nil - case KeyboardButtonURLAuthTypeID: - // Decoding keyboardButtonUrlAuth#f51006f9. - v := KeyboardButtonURLAuth{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode KeyboardButtonClass: %w", err) - } - return &v, nil - case InputKeyboardButtonURLAuthTypeID: - // Decoding inputKeyboardButtonUrlAuth#68013e72. - v := InputKeyboardButtonURLAuth{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode KeyboardButtonClass: %w", err) - } - return &v, nil - case KeyboardButtonRequestPollTypeID: - // Decoding keyboardButtonRequestPoll#7a11d782. - v := KeyboardButtonRequestPoll{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode KeyboardButtonClass: %w", err) - } - return &v, nil - case InputKeyboardButtonUserProfileTypeID: - // Decoding inputKeyboardButtonUserProfile#7d5e07c7. - v := InputKeyboardButtonUserProfile{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode KeyboardButtonClass: %w", err) - } - return &v, nil - case KeyboardButtonUserProfileTypeID: - // Decoding keyboardButtonUserProfile#c0fd5d09. - v := KeyboardButtonUserProfile{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode KeyboardButtonClass: %w", err) - } - return &v, nil - case KeyboardButtonWebViewTypeID: - // Decoding keyboardButtonWebView#e846b1a0. - v := KeyboardButtonWebView{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode KeyboardButtonClass: %w", err) - } - return &v, nil - case KeyboardButtonSimpleWebViewTypeID: - // Decoding keyboardButtonSimpleWebView#e15c4370. - v := KeyboardButtonSimpleWebView{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode KeyboardButtonClass: %w", err) - } - return &v, nil - case KeyboardButtonRequestPeerTypeID: - // Decoding keyboardButtonRequestPeer#5b0f15f5. - v := KeyboardButtonRequestPeer{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode KeyboardButtonClass: %w", err) - } - return &v, nil - case InputKeyboardButtonRequestPeerTypeID: - // Decoding inputKeyboardButtonRequestPeer#2b78156. - v := InputKeyboardButtonRequestPeer{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode KeyboardButtonClass: %w", err) - } - return &v, nil - case KeyboardButtonCopyTypeID: - // Decoding keyboardButtonCopy#bcc4af10. - v := KeyboardButtonCopy{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode KeyboardButtonClass: %w", err) - } - return &v, nil - default: - return nil, fmt.Errorf("unable to decode KeyboardButtonClass: %w", bin.NewUnexpectedID(id)) - } -} - -// KeyboardButton boxes the KeyboardButtonClass providing a helper. -type KeyboardButtonBox struct { - KeyboardButton KeyboardButtonClass -} - -// Decode implements bin.Decoder for KeyboardButtonBox. -func (b *KeyboardButtonBox) Decode(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("unable to decode KeyboardButtonBox to nil") - } - v, err := DecodeKeyboardButton(buf) - if err != nil { - return fmt.Errorf("unable to decode boxed value: %w", err) - } - b.KeyboardButton = v - return nil -} - -// Encode implements bin.Encode for KeyboardButtonBox. -func (b *KeyboardButtonBox) Encode(buf *bin.Buffer) error { - if b == nil || b.KeyboardButton == nil { - return fmt.Errorf("unable to encode KeyboardButtonClass as nil") - } - return b.KeyboardButton.Encode(buf) + return k.Type } diff --git a/tg/tl_keyboard_button_row_gen.go b/tg/tl_keyboard_button_row_gen.go index 987d076e43..9d97562879 100644 --- a/tg/tl_keyboard_button_row_gen.go +++ b/tg/tl_keyboard_button_row_gen.go @@ -37,7 +37,7 @@ var ( // See https://core.telegram.org/constructor/keyboardButtonRow for reference. type KeyboardButtonRow struct { // Bot or inline keyboard buttons - Buttons []KeyboardButtonClass + Buttons []KeyboardButton } // KeyboardButtonRowTypeID is TL type id of KeyboardButtonRow. @@ -73,7 +73,7 @@ func (k *KeyboardButtonRow) String() string { // FillFrom fills KeyboardButtonRow from given interface. func (k *KeyboardButtonRow) FillFrom(from interface { - GetButtons() (value []KeyboardButtonClass) + GetButtons() (value []KeyboardButton) }) { k.Buttons = from.GetButtons() } @@ -125,9 +125,6 @@ func (k *KeyboardButtonRow) EncodeBare(b *bin.Buffer) error { } b.PutVectorHeader(len(k.Buttons)) for idx, v := range k.Buttons { - if v == nil { - return fmt.Errorf("unable to encode keyboardButtonRow#77608b83: field buttons element with index %d is nil", idx) - } if err := v.Encode(b); err != nil { return fmt.Errorf("unable to encode keyboardButtonRow#77608b83: field buttons element with index %d: %w", idx, err) } @@ -158,11 +155,11 @@ func (k *KeyboardButtonRow) DecodeBare(b *bin.Buffer) error { } if headerLen > 0 { - k.Buttons = make([]KeyboardButtonClass, 0, headerLen%bin.PreallocateLimit) + k.Buttons = make([]KeyboardButton, 0, headerLen%bin.PreallocateLimit) } for idx := 0; idx < headerLen; idx++ { - value, err := DecodeKeyboardButton(b) - if err != nil { + var value KeyboardButton + if err := value.Decode(b); err != nil { return fmt.Errorf("unable to decode keyboardButtonRow#77608b83: field buttons: %w", err) } k.Buttons = append(k.Buttons, value) @@ -172,14 +169,9 @@ func (k *KeyboardButtonRow) DecodeBare(b *bin.Buffer) error { } // GetButtons returns value of Buttons field. -func (k *KeyboardButtonRow) GetButtons() (value []KeyboardButtonClass) { +func (k *KeyboardButtonRow) GetButtons() (value []KeyboardButton) { if k == nil { return } return k.Buttons } - -// MapButtons returns field Buttons wrapped in KeyboardButtonClassArray helper. -func (k *KeyboardButtonRow) MapButtons() (value KeyboardButtonClassArray) { - return KeyboardButtonClassArray(k.Buttons) -} diff --git a/tg/tl_keyboard_button_slices_gen.go b/tg/tl_keyboard_button_slices_gen.go index 3f83ff131b..fe21471a4c 100644 --- a/tg/tl_keyboard_button_slices_gen.go +++ b/tg/tl_keyboard_button_slices_gen.go @@ -33,1795 +33,3 @@ var ( _ = tgerr.Error{} _ = tdjson.Encoder{} ) - -// KeyboardButtonClassArray is adapter for slice of KeyboardButtonClass. -type KeyboardButtonClassArray []KeyboardButtonClass - -// Sort sorts slice of KeyboardButtonClass. -func (s KeyboardButtonClassArray) Sort(less func(a, b KeyboardButtonClass) bool) KeyboardButtonClassArray { - sort.Slice(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// SortStable sorts slice of KeyboardButtonClass. -func (s KeyboardButtonClassArray) SortStable(less func(a, b KeyboardButtonClass) bool) KeyboardButtonClassArray { - sort.SliceStable(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// Retain filters in-place slice of KeyboardButtonClass. -func (s KeyboardButtonClassArray) Retain(keep func(x KeyboardButtonClass) bool) KeyboardButtonClassArray { - 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 KeyboardButtonClassArray) First() (v KeyboardButtonClass, ok bool) { - if len(s) < 1 { - return - } - return s[0], true -} - -// Last returns last element of slice (if exists). -func (s KeyboardButtonClassArray) Last() (v KeyboardButtonClass, 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 *KeyboardButtonClassArray) PopFirst() (v KeyboardButtonClass, 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 KeyboardButtonClass - 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 *KeyboardButtonClassArray) Pop() (v KeyboardButtonClass, 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 -} - -// AsKeyboardButton returns copy with only KeyboardButton constructors. -func (s KeyboardButtonClassArray) AsKeyboardButton() (to KeyboardButtonArray) { - for _, elem := range s { - value, ok := elem.(*KeyboardButton) - if !ok { - continue - } - to = append(to, *value) - } - - return to -} - -// AsKeyboardButtonURL returns copy with only KeyboardButtonURL constructors. -func (s KeyboardButtonClassArray) AsKeyboardButtonURL() (to KeyboardButtonURLArray) { - for _, elem := range s { - value, ok := elem.(*KeyboardButtonURL) - if !ok { - continue - } - to = append(to, *value) - } - - return to -} - -// AsKeyboardButtonCallback returns copy with only KeyboardButtonCallback constructors. -func (s KeyboardButtonClassArray) AsKeyboardButtonCallback() (to KeyboardButtonCallbackArray) { - for _, elem := range s { - value, ok := elem.(*KeyboardButtonCallback) - if !ok { - continue - } - to = append(to, *value) - } - - return to -} - -// AsKeyboardButtonRequestPhone returns copy with only KeyboardButtonRequestPhone constructors. -func (s KeyboardButtonClassArray) AsKeyboardButtonRequestPhone() (to KeyboardButtonRequestPhoneArray) { - for _, elem := range s { - value, ok := elem.(*KeyboardButtonRequestPhone) - if !ok { - continue - } - to = append(to, *value) - } - - return to -} - -// AsKeyboardButtonRequestGeoLocation returns copy with only KeyboardButtonRequestGeoLocation constructors. -func (s KeyboardButtonClassArray) AsKeyboardButtonRequestGeoLocation() (to KeyboardButtonRequestGeoLocationArray) { - for _, elem := range s { - value, ok := elem.(*KeyboardButtonRequestGeoLocation) - if !ok { - continue - } - to = append(to, *value) - } - - return to -} - -// AsKeyboardButtonSwitchInline returns copy with only KeyboardButtonSwitchInline constructors. -func (s KeyboardButtonClassArray) AsKeyboardButtonSwitchInline() (to KeyboardButtonSwitchInlineArray) { - for _, elem := range s { - value, ok := elem.(*KeyboardButtonSwitchInline) - if !ok { - continue - } - to = append(to, *value) - } - - return to -} - -// AsKeyboardButtonGame returns copy with only KeyboardButtonGame constructors. -func (s KeyboardButtonClassArray) AsKeyboardButtonGame() (to KeyboardButtonGameArray) { - for _, elem := range s { - value, ok := elem.(*KeyboardButtonGame) - if !ok { - continue - } - to = append(to, *value) - } - - return to -} - -// AsKeyboardButtonBuy returns copy with only KeyboardButtonBuy constructors. -func (s KeyboardButtonClassArray) AsKeyboardButtonBuy() (to KeyboardButtonBuyArray) { - for _, elem := range s { - value, ok := elem.(*KeyboardButtonBuy) - if !ok { - continue - } - to = append(to, *value) - } - - return to -} - -// AsKeyboardButtonURLAuth returns copy with only KeyboardButtonURLAuth constructors. -func (s KeyboardButtonClassArray) AsKeyboardButtonURLAuth() (to KeyboardButtonURLAuthArray) { - for _, elem := range s { - value, ok := elem.(*KeyboardButtonURLAuth) - if !ok { - continue - } - to = append(to, *value) - } - - return to -} - -// AsInputKeyboardButtonURLAuth returns copy with only InputKeyboardButtonURLAuth constructors. -func (s KeyboardButtonClassArray) AsInputKeyboardButtonURLAuth() (to InputKeyboardButtonURLAuthArray) { - for _, elem := range s { - value, ok := elem.(*InputKeyboardButtonURLAuth) - if !ok { - continue - } - to = append(to, *value) - } - - return to -} - -// AsKeyboardButtonRequestPoll returns copy with only KeyboardButtonRequestPoll constructors. -func (s KeyboardButtonClassArray) AsKeyboardButtonRequestPoll() (to KeyboardButtonRequestPollArray) { - for _, elem := range s { - value, ok := elem.(*KeyboardButtonRequestPoll) - if !ok { - continue - } - to = append(to, *value) - } - - return to -} - -// AsInputKeyboardButtonUserProfile returns copy with only InputKeyboardButtonUserProfile constructors. -func (s KeyboardButtonClassArray) AsInputKeyboardButtonUserProfile() (to InputKeyboardButtonUserProfileArray) { - for _, elem := range s { - value, ok := elem.(*InputKeyboardButtonUserProfile) - if !ok { - continue - } - to = append(to, *value) - } - - return to -} - -// AsKeyboardButtonUserProfile returns copy with only KeyboardButtonUserProfile constructors. -func (s KeyboardButtonClassArray) AsKeyboardButtonUserProfile() (to KeyboardButtonUserProfileArray) { - for _, elem := range s { - value, ok := elem.(*KeyboardButtonUserProfile) - if !ok { - continue - } - to = append(to, *value) - } - - return to -} - -// AsKeyboardButtonWebView returns copy with only KeyboardButtonWebView constructors. -func (s KeyboardButtonClassArray) AsKeyboardButtonWebView() (to KeyboardButtonWebViewArray) { - for _, elem := range s { - value, ok := elem.(*KeyboardButtonWebView) - if !ok { - continue - } - to = append(to, *value) - } - - return to -} - -// AsKeyboardButtonSimpleWebView returns copy with only KeyboardButtonSimpleWebView constructors. -func (s KeyboardButtonClassArray) AsKeyboardButtonSimpleWebView() (to KeyboardButtonSimpleWebViewArray) { - for _, elem := range s { - value, ok := elem.(*KeyboardButtonSimpleWebView) - if !ok { - continue - } - to = append(to, *value) - } - - return to -} - -// AsKeyboardButtonRequestPeer returns copy with only KeyboardButtonRequestPeer constructors. -func (s KeyboardButtonClassArray) AsKeyboardButtonRequestPeer() (to KeyboardButtonRequestPeerArray) { - for _, elem := range s { - value, ok := elem.(*KeyboardButtonRequestPeer) - if !ok { - continue - } - to = append(to, *value) - } - - return to -} - -// AsInputKeyboardButtonRequestPeer returns copy with only InputKeyboardButtonRequestPeer constructors. -func (s KeyboardButtonClassArray) AsInputKeyboardButtonRequestPeer() (to InputKeyboardButtonRequestPeerArray) { - for _, elem := range s { - value, ok := elem.(*InputKeyboardButtonRequestPeer) - if !ok { - continue - } - to = append(to, *value) - } - - return to -} - -// AsKeyboardButtonCopy returns copy with only KeyboardButtonCopy constructors. -func (s KeyboardButtonClassArray) AsKeyboardButtonCopy() (to KeyboardButtonCopyArray) { - for _, elem := range s { - value, ok := elem.(*KeyboardButtonCopy) - if !ok { - continue - } - to = append(to, *value) - } - - return to -} - -// KeyboardButtonArray is adapter for slice of KeyboardButton. -type KeyboardButtonArray []KeyboardButton - -// Sort sorts slice of KeyboardButton. -func (s KeyboardButtonArray) Sort(less func(a, b KeyboardButton) bool) KeyboardButtonArray { - sort.Slice(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// SortStable sorts slice of KeyboardButton. -func (s KeyboardButtonArray) SortStable(less func(a, b KeyboardButton) bool) KeyboardButtonArray { - sort.SliceStable(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// Retain filters in-place slice of KeyboardButton. -func (s KeyboardButtonArray) Retain(keep func(x KeyboardButton) bool) KeyboardButtonArray { - 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 KeyboardButtonArray) First() (v KeyboardButton, ok bool) { - if len(s) < 1 { - return - } - return s[0], true -} - -// Last returns last element of slice (if exists). -func (s KeyboardButtonArray) Last() (v KeyboardButton, 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 *KeyboardButtonArray) PopFirst() (v KeyboardButton, 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 KeyboardButton - 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 *KeyboardButtonArray) Pop() (v KeyboardButton, 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 -} - -// KeyboardButtonURLArray is adapter for slice of KeyboardButtonURL. -type KeyboardButtonURLArray []KeyboardButtonURL - -// Sort sorts slice of KeyboardButtonURL. -func (s KeyboardButtonURLArray) Sort(less func(a, b KeyboardButtonURL) bool) KeyboardButtonURLArray { - sort.Slice(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// SortStable sorts slice of KeyboardButtonURL. -func (s KeyboardButtonURLArray) SortStable(less func(a, b KeyboardButtonURL) bool) KeyboardButtonURLArray { - sort.SliceStable(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// Retain filters in-place slice of KeyboardButtonURL. -func (s KeyboardButtonURLArray) Retain(keep func(x KeyboardButtonURL) bool) KeyboardButtonURLArray { - 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 KeyboardButtonURLArray) First() (v KeyboardButtonURL, ok bool) { - if len(s) < 1 { - return - } - return s[0], true -} - -// Last returns last element of slice (if exists). -func (s KeyboardButtonURLArray) Last() (v KeyboardButtonURL, 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 *KeyboardButtonURLArray) PopFirst() (v KeyboardButtonURL, 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 KeyboardButtonURL - 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 *KeyboardButtonURLArray) Pop() (v KeyboardButtonURL, 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 -} - -// KeyboardButtonCallbackArray is adapter for slice of KeyboardButtonCallback. -type KeyboardButtonCallbackArray []KeyboardButtonCallback - -// Sort sorts slice of KeyboardButtonCallback. -func (s KeyboardButtonCallbackArray) Sort(less func(a, b KeyboardButtonCallback) bool) KeyboardButtonCallbackArray { - sort.Slice(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// SortStable sorts slice of KeyboardButtonCallback. -func (s KeyboardButtonCallbackArray) SortStable(less func(a, b KeyboardButtonCallback) bool) KeyboardButtonCallbackArray { - sort.SliceStable(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// Retain filters in-place slice of KeyboardButtonCallback. -func (s KeyboardButtonCallbackArray) Retain(keep func(x KeyboardButtonCallback) bool) KeyboardButtonCallbackArray { - 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 KeyboardButtonCallbackArray) First() (v KeyboardButtonCallback, ok bool) { - if len(s) < 1 { - return - } - return s[0], true -} - -// Last returns last element of slice (if exists). -func (s KeyboardButtonCallbackArray) Last() (v KeyboardButtonCallback, 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 *KeyboardButtonCallbackArray) PopFirst() (v KeyboardButtonCallback, 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 KeyboardButtonCallback - 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 *KeyboardButtonCallbackArray) Pop() (v KeyboardButtonCallback, 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 -} - -// KeyboardButtonRequestPhoneArray is adapter for slice of KeyboardButtonRequestPhone. -type KeyboardButtonRequestPhoneArray []KeyboardButtonRequestPhone - -// Sort sorts slice of KeyboardButtonRequestPhone. -func (s KeyboardButtonRequestPhoneArray) Sort(less func(a, b KeyboardButtonRequestPhone) bool) KeyboardButtonRequestPhoneArray { - sort.Slice(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// SortStable sorts slice of KeyboardButtonRequestPhone. -func (s KeyboardButtonRequestPhoneArray) SortStable(less func(a, b KeyboardButtonRequestPhone) bool) KeyboardButtonRequestPhoneArray { - sort.SliceStable(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// Retain filters in-place slice of KeyboardButtonRequestPhone. -func (s KeyboardButtonRequestPhoneArray) Retain(keep func(x KeyboardButtonRequestPhone) bool) KeyboardButtonRequestPhoneArray { - 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 KeyboardButtonRequestPhoneArray) First() (v KeyboardButtonRequestPhone, ok bool) { - if len(s) < 1 { - return - } - return s[0], true -} - -// Last returns last element of slice (if exists). -func (s KeyboardButtonRequestPhoneArray) Last() (v KeyboardButtonRequestPhone, 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 *KeyboardButtonRequestPhoneArray) PopFirst() (v KeyboardButtonRequestPhone, 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 KeyboardButtonRequestPhone - 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 *KeyboardButtonRequestPhoneArray) Pop() (v KeyboardButtonRequestPhone, 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 -} - -// KeyboardButtonRequestGeoLocationArray is adapter for slice of KeyboardButtonRequestGeoLocation. -type KeyboardButtonRequestGeoLocationArray []KeyboardButtonRequestGeoLocation - -// Sort sorts slice of KeyboardButtonRequestGeoLocation. -func (s KeyboardButtonRequestGeoLocationArray) Sort(less func(a, b KeyboardButtonRequestGeoLocation) bool) KeyboardButtonRequestGeoLocationArray { - sort.Slice(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// SortStable sorts slice of KeyboardButtonRequestGeoLocation. -func (s KeyboardButtonRequestGeoLocationArray) SortStable(less func(a, b KeyboardButtonRequestGeoLocation) bool) KeyboardButtonRequestGeoLocationArray { - sort.SliceStable(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// Retain filters in-place slice of KeyboardButtonRequestGeoLocation. -func (s KeyboardButtonRequestGeoLocationArray) Retain(keep func(x KeyboardButtonRequestGeoLocation) bool) KeyboardButtonRequestGeoLocationArray { - 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 KeyboardButtonRequestGeoLocationArray) First() (v KeyboardButtonRequestGeoLocation, ok bool) { - if len(s) < 1 { - return - } - return s[0], true -} - -// Last returns last element of slice (if exists). -func (s KeyboardButtonRequestGeoLocationArray) Last() (v KeyboardButtonRequestGeoLocation, 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 *KeyboardButtonRequestGeoLocationArray) PopFirst() (v KeyboardButtonRequestGeoLocation, 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 KeyboardButtonRequestGeoLocation - 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 *KeyboardButtonRequestGeoLocationArray) Pop() (v KeyboardButtonRequestGeoLocation, 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 -} - -// KeyboardButtonSwitchInlineArray is adapter for slice of KeyboardButtonSwitchInline. -type KeyboardButtonSwitchInlineArray []KeyboardButtonSwitchInline - -// Sort sorts slice of KeyboardButtonSwitchInline. -func (s KeyboardButtonSwitchInlineArray) Sort(less func(a, b KeyboardButtonSwitchInline) bool) KeyboardButtonSwitchInlineArray { - sort.Slice(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// SortStable sorts slice of KeyboardButtonSwitchInline. -func (s KeyboardButtonSwitchInlineArray) SortStable(less func(a, b KeyboardButtonSwitchInline) bool) KeyboardButtonSwitchInlineArray { - sort.SliceStable(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// Retain filters in-place slice of KeyboardButtonSwitchInline. -func (s KeyboardButtonSwitchInlineArray) Retain(keep func(x KeyboardButtonSwitchInline) bool) KeyboardButtonSwitchInlineArray { - 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 KeyboardButtonSwitchInlineArray) First() (v KeyboardButtonSwitchInline, ok bool) { - if len(s) < 1 { - return - } - return s[0], true -} - -// Last returns last element of slice (if exists). -func (s KeyboardButtonSwitchInlineArray) Last() (v KeyboardButtonSwitchInline, 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 *KeyboardButtonSwitchInlineArray) PopFirst() (v KeyboardButtonSwitchInline, 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 KeyboardButtonSwitchInline - 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 *KeyboardButtonSwitchInlineArray) Pop() (v KeyboardButtonSwitchInline, 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 -} - -// KeyboardButtonGameArray is adapter for slice of KeyboardButtonGame. -type KeyboardButtonGameArray []KeyboardButtonGame - -// Sort sorts slice of KeyboardButtonGame. -func (s KeyboardButtonGameArray) Sort(less func(a, b KeyboardButtonGame) bool) KeyboardButtonGameArray { - sort.Slice(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// SortStable sorts slice of KeyboardButtonGame. -func (s KeyboardButtonGameArray) SortStable(less func(a, b KeyboardButtonGame) bool) KeyboardButtonGameArray { - sort.SliceStable(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// Retain filters in-place slice of KeyboardButtonGame. -func (s KeyboardButtonGameArray) Retain(keep func(x KeyboardButtonGame) bool) KeyboardButtonGameArray { - 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 KeyboardButtonGameArray) First() (v KeyboardButtonGame, ok bool) { - if len(s) < 1 { - return - } - return s[0], true -} - -// Last returns last element of slice (if exists). -func (s KeyboardButtonGameArray) Last() (v KeyboardButtonGame, 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 *KeyboardButtonGameArray) PopFirst() (v KeyboardButtonGame, 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 KeyboardButtonGame - 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 *KeyboardButtonGameArray) Pop() (v KeyboardButtonGame, 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 -} - -// KeyboardButtonBuyArray is adapter for slice of KeyboardButtonBuy. -type KeyboardButtonBuyArray []KeyboardButtonBuy - -// Sort sorts slice of KeyboardButtonBuy. -func (s KeyboardButtonBuyArray) Sort(less func(a, b KeyboardButtonBuy) bool) KeyboardButtonBuyArray { - sort.Slice(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// SortStable sorts slice of KeyboardButtonBuy. -func (s KeyboardButtonBuyArray) SortStable(less func(a, b KeyboardButtonBuy) bool) KeyboardButtonBuyArray { - sort.SliceStable(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// Retain filters in-place slice of KeyboardButtonBuy. -func (s KeyboardButtonBuyArray) Retain(keep func(x KeyboardButtonBuy) bool) KeyboardButtonBuyArray { - 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 KeyboardButtonBuyArray) First() (v KeyboardButtonBuy, ok bool) { - if len(s) < 1 { - return - } - return s[0], true -} - -// Last returns last element of slice (if exists). -func (s KeyboardButtonBuyArray) Last() (v KeyboardButtonBuy, 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 *KeyboardButtonBuyArray) PopFirst() (v KeyboardButtonBuy, 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 KeyboardButtonBuy - 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 *KeyboardButtonBuyArray) Pop() (v KeyboardButtonBuy, 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 -} - -// KeyboardButtonURLAuthArray is adapter for slice of KeyboardButtonURLAuth. -type KeyboardButtonURLAuthArray []KeyboardButtonURLAuth - -// Sort sorts slice of KeyboardButtonURLAuth. -func (s KeyboardButtonURLAuthArray) Sort(less func(a, b KeyboardButtonURLAuth) bool) KeyboardButtonURLAuthArray { - sort.Slice(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// SortStable sorts slice of KeyboardButtonURLAuth. -func (s KeyboardButtonURLAuthArray) SortStable(less func(a, b KeyboardButtonURLAuth) bool) KeyboardButtonURLAuthArray { - sort.SliceStable(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// Retain filters in-place slice of KeyboardButtonURLAuth. -func (s KeyboardButtonURLAuthArray) Retain(keep func(x KeyboardButtonURLAuth) bool) KeyboardButtonURLAuthArray { - 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 KeyboardButtonURLAuthArray) First() (v KeyboardButtonURLAuth, ok bool) { - if len(s) < 1 { - return - } - return s[0], true -} - -// Last returns last element of slice (if exists). -func (s KeyboardButtonURLAuthArray) Last() (v KeyboardButtonURLAuth, 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 *KeyboardButtonURLAuthArray) PopFirst() (v KeyboardButtonURLAuth, 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 KeyboardButtonURLAuth - 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 *KeyboardButtonURLAuthArray) Pop() (v KeyboardButtonURLAuth, 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 -} - -// InputKeyboardButtonURLAuthArray is adapter for slice of InputKeyboardButtonURLAuth. -type InputKeyboardButtonURLAuthArray []InputKeyboardButtonURLAuth - -// Sort sorts slice of InputKeyboardButtonURLAuth. -func (s InputKeyboardButtonURLAuthArray) Sort(less func(a, b InputKeyboardButtonURLAuth) bool) InputKeyboardButtonURLAuthArray { - sort.Slice(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// SortStable sorts slice of InputKeyboardButtonURLAuth. -func (s InputKeyboardButtonURLAuthArray) SortStable(less func(a, b InputKeyboardButtonURLAuth) bool) InputKeyboardButtonURLAuthArray { - sort.SliceStable(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// Retain filters in-place slice of InputKeyboardButtonURLAuth. -func (s InputKeyboardButtonURLAuthArray) Retain(keep func(x InputKeyboardButtonURLAuth) bool) InputKeyboardButtonURLAuthArray { - 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 InputKeyboardButtonURLAuthArray) First() (v InputKeyboardButtonURLAuth, ok bool) { - if len(s) < 1 { - return - } - return s[0], true -} - -// Last returns last element of slice (if exists). -func (s InputKeyboardButtonURLAuthArray) Last() (v InputKeyboardButtonURLAuth, 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 *InputKeyboardButtonURLAuthArray) PopFirst() (v InputKeyboardButtonURLAuth, 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 InputKeyboardButtonURLAuth - 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 *InputKeyboardButtonURLAuthArray) Pop() (v InputKeyboardButtonURLAuth, 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 -} - -// KeyboardButtonRequestPollArray is adapter for slice of KeyboardButtonRequestPoll. -type KeyboardButtonRequestPollArray []KeyboardButtonRequestPoll - -// Sort sorts slice of KeyboardButtonRequestPoll. -func (s KeyboardButtonRequestPollArray) Sort(less func(a, b KeyboardButtonRequestPoll) bool) KeyboardButtonRequestPollArray { - sort.Slice(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// SortStable sorts slice of KeyboardButtonRequestPoll. -func (s KeyboardButtonRequestPollArray) SortStable(less func(a, b KeyboardButtonRequestPoll) bool) KeyboardButtonRequestPollArray { - sort.SliceStable(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// Retain filters in-place slice of KeyboardButtonRequestPoll. -func (s KeyboardButtonRequestPollArray) Retain(keep func(x KeyboardButtonRequestPoll) bool) KeyboardButtonRequestPollArray { - 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 KeyboardButtonRequestPollArray) First() (v KeyboardButtonRequestPoll, ok bool) { - if len(s) < 1 { - return - } - return s[0], true -} - -// Last returns last element of slice (if exists). -func (s KeyboardButtonRequestPollArray) Last() (v KeyboardButtonRequestPoll, 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 *KeyboardButtonRequestPollArray) PopFirst() (v KeyboardButtonRequestPoll, 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 KeyboardButtonRequestPoll - 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 *KeyboardButtonRequestPollArray) Pop() (v KeyboardButtonRequestPoll, 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 -} - -// InputKeyboardButtonUserProfileArray is adapter for slice of InputKeyboardButtonUserProfile. -type InputKeyboardButtonUserProfileArray []InputKeyboardButtonUserProfile - -// Sort sorts slice of InputKeyboardButtonUserProfile. -func (s InputKeyboardButtonUserProfileArray) Sort(less func(a, b InputKeyboardButtonUserProfile) bool) InputKeyboardButtonUserProfileArray { - sort.Slice(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// SortStable sorts slice of InputKeyboardButtonUserProfile. -func (s InputKeyboardButtonUserProfileArray) SortStable(less func(a, b InputKeyboardButtonUserProfile) bool) InputKeyboardButtonUserProfileArray { - sort.SliceStable(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// Retain filters in-place slice of InputKeyboardButtonUserProfile. -func (s InputKeyboardButtonUserProfileArray) Retain(keep func(x InputKeyboardButtonUserProfile) bool) InputKeyboardButtonUserProfileArray { - 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 InputKeyboardButtonUserProfileArray) First() (v InputKeyboardButtonUserProfile, ok bool) { - if len(s) < 1 { - return - } - return s[0], true -} - -// Last returns last element of slice (if exists). -func (s InputKeyboardButtonUserProfileArray) Last() (v InputKeyboardButtonUserProfile, 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 *InputKeyboardButtonUserProfileArray) PopFirst() (v InputKeyboardButtonUserProfile, 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 InputKeyboardButtonUserProfile - 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 *InputKeyboardButtonUserProfileArray) Pop() (v InputKeyboardButtonUserProfile, 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 -} - -// KeyboardButtonUserProfileArray is adapter for slice of KeyboardButtonUserProfile. -type KeyboardButtonUserProfileArray []KeyboardButtonUserProfile - -// Sort sorts slice of KeyboardButtonUserProfile. -func (s KeyboardButtonUserProfileArray) Sort(less func(a, b KeyboardButtonUserProfile) bool) KeyboardButtonUserProfileArray { - sort.Slice(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// SortStable sorts slice of KeyboardButtonUserProfile. -func (s KeyboardButtonUserProfileArray) SortStable(less func(a, b KeyboardButtonUserProfile) bool) KeyboardButtonUserProfileArray { - sort.SliceStable(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// Retain filters in-place slice of KeyboardButtonUserProfile. -func (s KeyboardButtonUserProfileArray) Retain(keep func(x KeyboardButtonUserProfile) bool) KeyboardButtonUserProfileArray { - 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 KeyboardButtonUserProfileArray) First() (v KeyboardButtonUserProfile, ok bool) { - if len(s) < 1 { - return - } - return s[0], true -} - -// Last returns last element of slice (if exists). -func (s KeyboardButtonUserProfileArray) Last() (v KeyboardButtonUserProfile, 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 *KeyboardButtonUserProfileArray) PopFirst() (v KeyboardButtonUserProfile, 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 KeyboardButtonUserProfile - 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 *KeyboardButtonUserProfileArray) Pop() (v KeyboardButtonUserProfile, 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 -} - -// KeyboardButtonWebViewArray is adapter for slice of KeyboardButtonWebView. -type KeyboardButtonWebViewArray []KeyboardButtonWebView - -// Sort sorts slice of KeyboardButtonWebView. -func (s KeyboardButtonWebViewArray) Sort(less func(a, b KeyboardButtonWebView) bool) KeyboardButtonWebViewArray { - sort.Slice(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// SortStable sorts slice of KeyboardButtonWebView. -func (s KeyboardButtonWebViewArray) SortStable(less func(a, b KeyboardButtonWebView) bool) KeyboardButtonWebViewArray { - sort.SliceStable(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// Retain filters in-place slice of KeyboardButtonWebView. -func (s KeyboardButtonWebViewArray) Retain(keep func(x KeyboardButtonWebView) bool) KeyboardButtonWebViewArray { - 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 KeyboardButtonWebViewArray) First() (v KeyboardButtonWebView, ok bool) { - if len(s) < 1 { - return - } - return s[0], true -} - -// Last returns last element of slice (if exists). -func (s KeyboardButtonWebViewArray) Last() (v KeyboardButtonWebView, 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 *KeyboardButtonWebViewArray) PopFirst() (v KeyboardButtonWebView, 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 KeyboardButtonWebView - 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 *KeyboardButtonWebViewArray) Pop() (v KeyboardButtonWebView, 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 -} - -// KeyboardButtonSimpleWebViewArray is adapter for slice of KeyboardButtonSimpleWebView. -type KeyboardButtonSimpleWebViewArray []KeyboardButtonSimpleWebView - -// Sort sorts slice of KeyboardButtonSimpleWebView. -func (s KeyboardButtonSimpleWebViewArray) Sort(less func(a, b KeyboardButtonSimpleWebView) bool) KeyboardButtonSimpleWebViewArray { - sort.Slice(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// SortStable sorts slice of KeyboardButtonSimpleWebView. -func (s KeyboardButtonSimpleWebViewArray) SortStable(less func(a, b KeyboardButtonSimpleWebView) bool) KeyboardButtonSimpleWebViewArray { - sort.SliceStable(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// Retain filters in-place slice of KeyboardButtonSimpleWebView. -func (s KeyboardButtonSimpleWebViewArray) Retain(keep func(x KeyboardButtonSimpleWebView) bool) KeyboardButtonSimpleWebViewArray { - 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 KeyboardButtonSimpleWebViewArray) First() (v KeyboardButtonSimpleWebView, ok bool) { - if len(s) < 1 { - return - } - return s[0], true -} - -// Last returns last element of slice (if exists). -func (s KeyboardButtonSimpleWebViewArray) Last() (v KeyboardButtonSimpleWebView, 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 *KeyboardButtonSimpleWebViewArray) PopFirst() (v KeyboardButtonSimpleWebView, 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 KeyboardButtonSimpleWebView - 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 *KeyboardButtonSimpleWebViewArray) Pop() (v KeyboardButtonSimpleWebView, 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 -} - -// KeyboardButtonRequestPeerArray is adapter for slice of KeyboardButtonRequestPeer. -type KeyboardButtonRequestPeerArray []KeyboardButtonRequestPeer - -// Sort sorts slice of KeyboardButtonRequestPeer. -func (s KeyboardButtonRequestPeerArray) Sort(less func(a, b KeyboardButtonRequestPeer) bool) KeyboardButtonRequestPeerArray { - sort.Slice(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// SortStable sorts slice of KeyboardButtonRequestPeer. -func (s KeyboardButtonRequestPeerArray) SortStable(less func(a, b KeyboardButtonRequestPeer) bool) KeyboardButtonRequestPeerArray { - sort.SliceStable(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// Retain filters in-place slice of KeyboardButtonRequestPeer. -func (s KeyboardButtonRequestPeerArray) Retain(keep func(x KeyboardButtonRequestPeer) bool) KeyboardButtonRequestPeerArray { - 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 KeyboardButtonRequestPeerArray) First() (v KeyboardButtonRequestPeer, ok bool) { - if len(s) < 1 { - return - } - return s[0], true -} - -// Last returns last element of slice (if exists). -func (s KeyboardButtonRequestPeerArray) Last() (v KeyboardButtonRequestPeer, 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 *KeyboardButtonRequestPeerArray) PopFirst() (v KeyboardButtonRequestPeer, 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 KeyboardButtonRequestPeer - 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 *KeyboardButtonRequestPeerArray) Pop() (v KeyboardButtonRequestPeer, 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 -} - -// InputKeyboardButtonRequestPeerArray is adapter for slice of InputKeyboardButtonRequestPeer. -type InputKeyboardButtonRequestPeerArray []InputKeyboardButtonRequestPeer - -// Sort sorts slice of InputKeyboardButtonRequestPeer. -func (s InputKeyboardButtonRequestPeerArray) Sort(less func(a, b InputKeyboardButtonRequestPeer) bool) InputKeyboardButtonRequestPeerArray { - sort.Slice(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// SortStable sorts slice of InputKeyboardButtonRequestPeer. -func (s InputKeyboardButtonRequestPeerArray) SortStable(less func(a, b InputKeyboardButtonRequestPeer) bool) InputKeyboardButtonRequestPeerArray { - sort.SliceStable(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// Retain filters in-place slice of InputKeyboardButtonRequestPeer. -func (s InputKeyboardButtonRequestPeerArray) Retain(keep func(x InputKeyboardButtonRequestPeer) bool) InputKeyboardButtonRequestPeerArray { - 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 InputKeyboardButtonRequestPeerArray) First() (v InputKeyboardButtonRequestPeer, ok bool) { - if len(s) < 1 { - return - } - return s[0], true -} - -// Last returns last element of slice (if exists). -func (s InputKeyboardButtonRequestPeerArray) Last() (v InputKeyboardButtonRequestPeer, 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 *InputKeyboardButtonRequestPeerArray) PopFirst() (v InputKeyboardButtonRequestPeer, 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 InputKeyboardButtonRequestPeer - 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 *InputKeyboardButtonRequestPeerArray) Pop() (v InputKeyboardButtonRequestPeer, 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 -} - -// KeyboardButtonCopyArray is adapter for slice of KeyboardButtonCopy. -type KeyboardButtonCopyArray []KeyboardButtonCopy - -// Sort sorts slice of KeyboardButtonCopy. -func (s KeyboardButtonCopyArray) Sort(less func(a, b KeyboardButtonCopy) bool) KeyboardButtonCopyArray { - sort.Slice(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// SortStable sorts slice of KeyboardButtonCopy. -func (s KeyboardButtonCopyArray) SortStable(less func(a, b KeyboardButtonCopy) bool) KeyboardButtonCopyArray { - sort.SliceStable(s, func(i, j int) bool { - return less(s[i], s[j]) - }) - return s -} - -// Retain filters in-place slice of KeyboardButtonCopy. -func (s KeyboardButtonCopyArray) Retain(keep func(x KeyboardButtonCopy) bool) KeyboardButtonCopyArray { - 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 KeyboardButtonCopyArray) First() (v KeyboardButtonCopy, ok bool) { - if len(s) < 1 { - return - } - return s[0], true -} - -// Last returns last element of slice (if exists). -func (s KeyboardButtonCopyArray) Last() (v KeyboardButtonCopy, 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 *KeyboardButtonCopyArray) PopFirst() (v KeyboardButtonCopy, 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 KeyboardButtonCopy - 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 *KeyboardButtonCopyArray) Pop() (v KeyboardButtonCopy, 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_keyboard_inline_button_gen.go b/tg/tl_keyboard_inline_button_gen.go new file mode 100644 index 0000000000..c6fb6b479c --- /dev/null +++ b/tg/tl_keyboard_inline_button_gen.go @@ -0,0 +1,259 @@ +// 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{} +) + +// KeyboardInlineButton represents TL type `keyboardInlineButton#11c1a322`. +// +// See https://core.telegram.org/constructor/keyboardInlineButton for reference. +type KeyboardInlineButton struct { + // Flags field of KeyboardInlineButton. + Flags bin.Fields + // Style field of KeyboardInlineButton. + // + // Use SetStyle and GetStyle helpers. + Style KeyboardButtonStyle + // Text field of KeyboardInlineButton. + Text string + // Type field of KeyboardInlineButton. + Type InlineButtonTypeClass +} + +// KeyboardInlineButtonTypeID is TL type id of KeyboardInlineButton. +const KeyboardInlineButtonTypeID = 0x11c1a322 + +// Ensuring interfaces in compile-time for KeyboardInlineButton. +var ( + _ bin.Encoder = &KeyboardInlineButton{} + _ bin.Decoder = &KeyboardInlineButton{} + _ bin.BareEncoder = &KeyboardInlineButton{} + _ bin.BareDecoder = &KeyboardInlineButton{} +) + +func (k *KeyboardInlineButton) Zero() bool { + if k == nil { + return true + } + if !(k.Flags.Zero()) { + return false + } + if !(k.Style.Zero()) { + return false + } + if !(k.Text == "") { + return false + } + if !(k.Type == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (k *KeyboardInlineButton) String() string { + if k == nil { + return "KeyboardInlineButton(nil)" + } + type Alias KeyboardInlineButton + return fmt.Sprintf("KeyboardInlineButton%+v", Alias(*k)) +} + +// FillFrom fills KeyboardInlineButton from given interface. +func (k *KeyboardInlineButton) FillFrom(from interface { + GetStyle() (value KeyboardButtonStyle, ok bool) + GetText() (value string) + GetType() (value InlineButtonTypeClass) +}) { + if val, ok := from.GetStyle(); ok { + k.Style = val + } + + k.Text = from.GetText() + k.Type = from.GetType() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*KeyboardInlineButton) TypeID() uint32 { + return KeyboardInlineButtonTypeID +} + +// TypeName returns name of type in TL schema. +func (*KeyboardInlineButton) TypeName() string { + return "keyboardInlineButton" +} + +// TypeInfo returns info about TL type. +func (k *KeyboardInlineButton) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "keyboardInlineButton", + ID: KeyboardInlineButtonTypeID, + } + if k == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Style", + SchemaName: "style", + Null: !k.Flags.Has(10), + }, + { + Name: "Text", + SchemaName: "text", + }, + { + Name: "Type", + SchemaName: "type", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (k *KeyboardInlineButton) SetFlags() { + if !(k.Style.Zero()) { + k.Flags.Set(10) + } +} + +// Encode implements bin.Encoder. +func (k *KeyboardInlineButton) Encode(b *bin.Buffer) error { + if k == nil { + return fmt.Errorf("can't encode keyboardInlineButton#11c1a322 as nil") + } + b.PutID(KeyboardInlineButtonTypeID) + return k.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (k *KeyboardInlineButton) EncodeBare(b *bin.Buffer) error { + if k == nil { + return fmt.Errorf("can't encode keyboardInlineButton#11c1a322 as nil") + } + k.SetFlags() + if err := k.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode keyboardInlineButton#11c1a322: field flags: %w", err) + } + if k.Flags.Has(10) { + if err := k.Style.Encode(b); err != nil { + return fmt.Errorf("unable to encode keyboardInlineButton#11c1a322: field style: %w", err) + } + } + b.PutString(k.Text) + if k.Type == nil { + return fmt.Errorf("unable to encode keyboardInlineButton#11c1a322: field type is nil") + } + if err := k.Type.Encode(b); err != nil { + return fmt.Errorf("unable to encode keyboardInlineButton#11c1a322: field type: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (k *KeyboardInlineButton) Decode(b *bin.Buffer) error { + if k == nil { + return fmt.Errorf("can't decode keyboardInlineButton#11c1a322 to nil") + } + if err := b.ConsumeID(KeyboardInlineButtonTypeID); err != nil { + return fmt.Errorf("unable to decode keyboardInlineButton#11c1a322: %w", err) + } + return k.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (k *KeyboardInlineButton) DecodeBare(b *bin.Buffer) error { + if k == nil { + return fmt.Errorf("can't decode keyboardInlineButton#11c1a322 to nil") + } + { + if err := k.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode keyboardInlineButton#11c1a322: field flags: %w", err) + } + } + if k.Flags.Has(10) { + if err := k.Style.Decode(b); err != nil { + return fmt.Errorf("unable to decode keyboardInlineButton#11c1a322: field style: %w", err) + } + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode keyboardInlineButton#11c1a322: field text: %w", err) + } + k.Text = value + } + { + value, err := DecodeInlineButtonType(b) + if err != nil { + return fmt.Errorf("unable to decode keyboardInlineButton#11c1a322: field type: %w", err) + } + k.Type = value + } + return nil +} + +// SetStyle sets value of Style conditional field. +func (k *KeyboardInlineButton) SetStyle(value KeyboardButtonStyle) { + k.Flags.Set(10) + k.Style = value +} + +// GetStyle returns value of Style conditional field and +// boolean which is true if field was set. +func (k *KeyboardInlineButton) GetStyle() (value KeyboardButtonStyle, ok bool) { + if k == nil { + return + } + if !k.Flags.Has(10) { + return value, false + } + return k.Style, true +} + +// GetText returns value of Text field. +func (k *KeyboardInlineButton) GetText() (value string) { + if k == nil { + return + } + return k.Text +} + +// GetType returns value of Type field. +func (k *KeyboardInlineButton) GetType() (value InlineButtonTypeClass) { + if k == nil { + return + } + return k.Type +} diff --git a/tg/tl_keyboard_inline_button_row_gen.go b/tg/tl_keyboard_inline_button_row_gen.go new file mode 100644 index 0000000000..219d1974ed --- /dev/null +++ b/tg/tl_keyboard_inline_button_row_gen.go @@ -0,0 +1,176 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// KeyboardInlineButtonRow represents TL type `keyboardInlineButtonRow#19420af6`. +// +// See https://core.telegram.org/constructor/keyboardInlineButtonRow for reference. +type KeyboardInlineButtonRow struct { + // Buttons field of KeyboardInlineButtonRow. + Buttons []KeyboardInlineButton +} + +// KeyboardInlineButtonRowTypeID is TL type id of KeyboardInlineButtonRow. +const KeyboardInlineButtonRowTypeID = 0x19420af6 + +// Ensuring interfaces in compile-time for KeyboardInlineButtonRow. +var ( + _ bin.Encoder = &KeyboardInlineButtonRow{} + _ bin.Decoder = &KeyboardInlineButtonRow{} + _ bin.BareEncoder = &KeyboardInlineButtonRow{} + _ bin.BareDecoder = &KeyboardInlineButtonRow{} +) + +func (k *KeyboardInlineButtonRow) Zero() bool { + if k == nil { + return true + } + if !(k.Buttons == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (k *KeyboardInlineButtonRow) String() string { + if k == nil { + return "KeyboardInlineButtonRow(nil)" + } + type Alias KeyboardInlineButtonRow + return fmt.Sprintf("KeyboardInlineButtonRow%+v", Alias(*k)) +} + +// FillFrom fills KeyboardInlineButtonRow from given interface. +func (k *KeyboardInlineButtonRow) FillFrom(from interface { + GetButtons() (value []KeyboardInlineButton) +}) { + k.Buttons = from.GetButtons() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*KeyboardInlineButtonRow) TypeID() uint32 { + return KeyboardInlineButtonRowTypeID +} + +// TypeName returns name of type in TL schema. +func (*KeyboardInlineButtonRow) TypeName() string { + return "keyboardInlineButtonRow" +} + +// TypeInfo returns info about TL type. +func (k *KeyboardInlineButtonRow) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "keyboardInlineButtonRow", + ID: KeyboardInlineButtonRowTypeID, + } + if k == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Buttons", + SchemaName: "buttons", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (k *KeyboardInlineButtonRow) Encode(b *bin.Buffer) error { + if k == nil { + return fmt.Errorf("can't encode keyboardInlineButtonRow#19420af6 as nil") + } + b.PutID(KeyboardInlineButtonRowTypeID) + return k.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (k *KeyboardInlineButtonRow) EncodeBare(b *bin.Buffer) error { + if k == nil { + return fmt.Errorf("can't encode keyboardInlineButtonRow#19420af6 as nil") + } + b.PutVectorHeader(len(k.Buttons)) + for idx, v := range k.Buttons { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode keyboardInlineButtonRow#19420af6: field buttons element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (k *KeyboardInlineButtonRow) Decode(b *bin.Buffer) error { + if k == nil { + return fmt.Errorf("can't decode keyboardInlineButtonRow#19420af6 to nil") + } + if err := b.ConsumeID(KeyboardInlineButtonRowTypeID); err != nil { + return fmt.Errorf("unable to decode keyboardInlineButtonRow#19420af6: %w", err) + } + return k.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (k *KeyboardInlineButtonRow) DecodeBare(b *bin.Buffer) error { + if k == nil { + return fmt.Errorf("can't decode keyboardInlineButtonRow#19420af6 to nil") + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode keyboardInlineButtonRow#19420af6: field buttons: %w", err) + } + + if headerLen > 0 { + k.Buttons = make([]KeyboardInlineButton, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value KeyboardInlineButton + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode keyboardInlineButtonRow#19420af6: field buttons: %w", err) + } + k.Buttons = append(k.Buttons, value) + } + } + return nil +} + +// GetButtons returns value of Buttons field. +func (k *KeyboardInlineButtonRow) GetButtons() (value []KeyboardInlineButton) { + if k == nil { + return + } + return k.Buttons +} diff --git a/tg/tl_keyboard_inline_button_row_slices_gen.go b/tg/tl_keyboard_inline_button_row_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_keyboard_inline_button_row_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_keyboard_inline_button_slices_gen.go b/tg/tl_keyboard_inline_button_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_keyboard_inline_button_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_message_action_gen.go b/tg/tl_message_action_gen.go index 95f2ab04c9..7b9e9af35f 100644 --- a/tg/tl_message_action_gen.go +++ b/tg/tl_message_action_gen.go @@ -10457,7 +10457,7 @@ func (m *MessageActionStarGift) GetGiftNum() (value int, ok bool) { return m.GiftNum, true } -// MessageActionStarGiftUnique represents TL type `messageActionStarGiftUnique#e6c31522`. +// MessageActionStarGiftUnique represents TL type `messageActionStarGiftUnique#7e1c1187`. // A gift »¹ was upgraded to a collectible gift »². // // Links: @@ -10513,6 +10513,8 @@ type MessageActionStarGiftUnique struct { // Links: // 1) https://core.telegram.org/api/gifts#crafting-collectible-gifts Craft bool + // NameHidden field of MessageActionStarGiftUnique. + NameHidden bool // The collectible gift. Gift StarGiftClass // If set, indicates that the current gift can't be exported to the TON blockchain »¹ @@ -10583,10 +10585,14 @@ type MessageActionStarGiftUnique struct { // // Use SetCanCraftAt and GetCanCraftAt helpers. CanCraftAt int + // Message field of MessageActionStarGiftUnique. + // + // Use SetMessage and GetMessage helpers. + Message TextWithEntities } // MessageActionStarGiftUniqueTypeID is TL type id of MessageActionStarGiftUnique. -const MessageActionStarGiftUniqueTypeID = 0xe6c31522 +const MessageActionStarGiftUniqueTypeID = 0x7e1c1187 // construct implements constructor of MessageActionClass. func (m MessageActionStarGiftUnique) construct() MessageActionClass { return &m } @@ -10632,6 +10638,9 @@ func (m *MessageActionStarGiftUnique) Zero() bool { if !(m.Craft == false) { return false } + if !(m.NameHidden == false) { + return false + } if !(m.Gift == nil) { return false } @@ -10665,6 +10674,9 @@ func (m *MessageActionStarGiftUnique) Zero() bool { if !(m.CanCraftAt == 0) { return false } + if !(m.Message.Zero()) { + return false + } return true } @@ -10688,6 +10700,7 @@ func (m *MessageActionStarGiftUnique) FillFrom(from interface { GetAssigned() (value bool) GetFromOffer() (value bool) GetCraft() (value bool) + GetNameHidden() (value bool) GetGift() (value StarGiftClass) GetCanExportAt() (value int, ok bool) GetTransferStars() (value int64, ok bool) @@ -10699,6 +10712,7 @@ func (m *MessageActionStarGiftUnique) FillFrom(from interface { GetCanResellAt() (value int, ok bool) GetDropOriginalDetailsStars() (value int64, ok bool) GetCanCraftAt() (value int, ok bool) + GetMessage() (value TextWithEntities, ok bool) }) { m.Upgrade = from.GetUpgrade() m.Transferred = from.GetTransferred() @@ -10708,6 +10722,7 @@ func (m *MessageActionStarGiftUnique) FillFrom(from interface { m.Assigned = from.GetAssigned() m.FromOffer = from.GetFromOffer() m.Craft = from.GetCraft() + m.NameHidden = from.GetNameHidden() m.Gift = from.GetGift() if val, ok := from.GetCanExportAt(); ok { m.CanExportAt = val @@ -10749,6 +10764,10 @@ func (m *MessageActionStarGiftUnique) FillFrom(from interface { m.CanCraftAt = val } + if val, ok := from.GetMessage(); ok { + m.Message = val + } + } // TypeID returns type id in TL schema. @@ -10814,6 +10833,11 @@ func (m *MessageActionStarGiftUnique) TypeInfo() tdp.Type { SchemaName: "craft", Null: !m.Flags.Has(16), }, + { + Name: "NameHidden", + SchemaName: "name_hidden", + Null: !m.Flags.Has(17), + }, { Name: "Gift", SchemaName: "gift", @@ -10868,6 +10892,11 @@ func (m *MessageActionStarGiftUnique) TypeInfo() tdp.Type { SchemaName: "can_craft_at", Null: !m.Flags.Has(15), }, + { + Name: "Message", + SchemaName: "message", + Null: !m.Flags.Has(18), + }, } return typ } @@ -10898,6 +10927,9 @@ func (m *MessageActionStarGiftUnique) SetFlags() { if !(m.Craft == false) { m.Flags.Set(16) } + if !(m.NameHidden == false) { + m.Flags.Set(17) + } if !(m.CanExportAt == 0) { m.Flags.Set(3) } @@ -10928,12 +10960,15 @@ func (m *MessageActionStarGiftUnique) SetFlags() { if !(m.CanCraftAt == 0) { m.Flags.Set(15) } + if !(m.Message.Zero()) { + m.Flags.Set(18) + } } // Encode implements bin.Encoder. func (m *MessageActionStarGiftUnique) Encode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageActionStarGiftUnique#e6c31522 as nil") + return fmt.Errorf("can't encode messageActionStarGiftUnique#7e1c1187 as nil") } b.PutID(MessageActionStarGiftUniqueTypeID) return m.EncodeBare(b) @@ -10942,17 +10977,17 @@ func (m *MessageActionStarGiftUnique) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (m *MessageActionStarGiftUnique) EncodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't encode messageActionStarGiftUnique#e6c31522 as nil") + return fmt.Errorf("can't encode messageActionStarGiftUnique#7e1c1187 as nil") } m.SetFlags() if err := m.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode messageActionStarGiftUnique#e6c31522: field flags: %w", err) + return fmt.Errorf("unable to encode messageActionStarGiftUnique#7e1c1187: field flags: %w", err) } if m.Gift == nil { - return fmt.Errorf("unable to encode messageActionStarGiftUnique#e6c31522: field gift is nil") + return fmt.Errorf("unable to encode messageActionStarGiftUnique#7e1c1187: field gift is nil") } if err := m.Gift.Encode(b); err != nil { - return fmt.Errorf("unable to encode messageActionStarGiftUnique#e6c31522: field gift: %w", err) + return fmt.Errorf("unable to encode messageActionStarGiftUnique#7e1c1187: field gift: %w", err) } if m.Flags.Has(3) { b.PutInt(m.CanExportAt) @@ -10962,18 +10997,18 @@ func (m *MessageActionStarGiftUnique) EncodeBare(b *bin.Buffer) error { } if m.Flags.Has(6) { if m.FromID == nil { - return fmt.Errorf("unable to encode messageActionStarGiftUnique#e6c31522: field from_id is nil") + return fmt.Errorf("unable to encode messageActionStarGiftUnique#7e1c1187: field from_id is nil") } if err := m.FromID.Encode(b); err != nil { - return fmt.Errorf("unable to encode messageActionStarGiftUnique#e6c31522: field from_id: %w", err) + return fmt.Errorf("unable to encode messageActionStarGiftUnique#7e1c1187: field from_id: %w", err) } } if m.Flags.Has(7) { if m.Peer == nil { - return fmt.Errorf("unable to encode messageActionStarGiftUnique#e6c31522: field peer is nil") + return fmt.Errorf("unable to encode messageActionStarGiftUnique#7e1c1187: field peer is nil") } if err := m.Peer.Encode(b); err != nil { - return fmt.Errorf("unable to encode messageActionStarGiftUnique#e6c31522: field peer: %w", err) + return fmt.Errorf("unable to encode messageActionStarGiftUnique#7e1c1187: field peer: %w", err) } } if m.Flags.Has(7) { @@ -10981,10 +11016,10 @@ func (m *MessageActionStarGiftUnique) EncodeBare(b *bin.Buffer) error { } if m.Flags.Has(8) { if m.ResaleAmount == nil { - return fmt.Errorf("unable to encode messageActionStarGiftUnique#e6c31522: field resale_amount is nil") + return fmt.Errorf("unable to encode messageActionStarGiftUnique#7e1c1187: field resale_amount is nil") } if err := m.ResaleAmount.Encode(b); err != nil { - return fmt.Errorf("unable to encode messageActionStarGiftUnique#e6c31522: field resale_amount: %w", err) + return fmt.Errorf("unable to encode messageActionStarGiftUnique#7e1c1187: field resale_amount: %w", err) } } if m.Flags.Has(9) { @@ -10999,16 +11034,21 @@ func (m *MessageActionStarGiftUnique) EncodeBare(b *bin.Buffer) error { if m.Flags.Has(15) { b.PutInt(m.CanCraftAt) } + if m.Flags.Has(18) { + if err := m.Message.Encode(b); err != nil { + return fmt.Errorf("unable to encode messageActionStarGiftUnique#7e1c1187: field message: %w", err) + } + } return nil } // Decode implements bin.Decoder. func (m *MessageActionStarGiftUnique) Decode(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageActionStarGiftUnique#e6c31522 to nil") + return fmt.Errorf("can't decode messageActionStarGiftUnique#7e1c1187 to nil") } if err := b.ConsumeID(MessageActionStarGiftUniqueTypeID); err != nil { - return fmt.Errorf("unable to decode messageActionStarGiftUnique#e6c31522: %w", err) + return fmt.Errorf("unable to decode messageActionStarGiftUnique#7e1c1187: %w", err) } return m.DecodeBare(b) } @@ -11016,11 +11056,11 @@ func (m *MessageActionStarGiftUnique) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (m *MessageActionStarGiftUnique) DecodeBare(b *bin.Buffer) error { if m == nil { - return fmt.Errorf("can't decode messageActionStarGiftUnique#e6c31522 to nil") + return fmt.Errorf("can't decode messageActionStarGiftUnique#7e1c1187 to nil") } { if err := m.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode messageActionStarGiftUnique#e6c31522: field flags: %w", err) + return fmt.Errorf("unable to decode messageActionStarGiftUnique#7e1c1187: field flags: %w", err) } } m.Upgrade = m.Flags.Has(0) @@ -11031,83 +11071,89 @@ func (m *MessageActionStarGiftUnique) DecodeBare(b *bin.Buffer) error { m.Assigned = m.Flags.Has(13) m.FromOffer = m.Flags.Has(14) m.Craft = m.Flags.Has(16) + m.NameHidden = m.Flags.Has(17) { value, err := DecodeStarGift(b) if err != nil { - return fmt.Errorf("unable to decode messageActionStarGiftUnique#e6c31522: field gift: %w", err) + return fmt.Errorf("unable to decode messageActionStarGiftUnique#7e1c1187: field gift: %w", err) } m.Gift = value } if m.Flags.Has(3) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messageActionStarGiftUnique#e6c31522: field can_export_at: %w", err) + return fmt.Errorf("unable to decode messageActionStarGiftUnique#7e1c1187: field can_export_at: %w", err) } m.CanExportAt = value } if m.Flags.Has(4) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode messageActionStarGiftUnique#e6c31522: field transfer_stars: %w", err) + return fmt.Errorf("unable to decode messageActionStarGiftUnique#7e1c1187: field transfer_stars: %w", err) } m.TransferStars = value } if m.Flags.Has(6) { value, err := DecodePeer(b) if err != nil { - return fmt.Errorf("unable to decode messageActionStarGiftUnique#e6c31522: field from_id: %w", err) + return fmt.Errorf("unable to decode messageActionStarGiftUnique#7e1c1187: field from_id: %w", err) } m.FromID = value } if m.Flags.Has(7) { value, err := DecodePeer(b) if err != nil { - return fmt.Errorf("unable to decode messageActionStarGiftUnique#e6c31522: field peer: %w", err) + return fmt.Errorf("unable to decode messageActionStarGiftUnique#7e1c1187: field peer: %w", err) } m.Peer = value } if m.Flags.Has(7) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode messageActionStarGiftUnique#e6c31522: field saved_id: %w", err) + return fmt.Errorf("unable to decode messageActionStarGiftUnique#7e1c1187: field saved_id: %w", err) } m.SavedID = value } if m.Flags.Has(8) { value, err := DecodeStarsAmount(b) if err != nil { - return fmt.Errorf("unable to decode messageActionStarGiftUnique#e6c31522: field resale_amount: %w", err) + return fmt.Errorf("unable to decode messageActionStarGiftUnique#7e1c1187: field resale_amount: %w", err) } m.ResaleAmount = value } if m.Flags.Has(9) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messageActionStarGiftUnique#e6c31522: field can_transfer_at: %w", err) + return fmt.Errorf("unable to decode messageActionStarGiftUnique#7e1c1187: field can_transfer_at: %w", err) } m.CanTransferAt = value } if m.Flags.Has(10) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messageActionStarGiftUnique#e6c31522: field can_resell_at: %w", err) + return fmt.Errorf("unable to decode messageActionStarGiftUnique#7e1c1187: field can_resell_at: %w", err) } m.CanResellAt = value } if m.Flags.Has(12) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode messageActionStarGiftUnique#e6c31522: field drop_original_details_stars: %w", err) + return fmt.Errorf("unable to decode messageActionStarGiftUnique#7e1c1187: field drop_original_details_stars: %w", err) } m.DropOriginalDetailsStars = value } if m.Flags.Has(15) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode messageActionStarGiftUnique#e6c31522: field can_craft_at: %w", err) + return fmt.Errorf("unable to decode messageActionStarGiftUnique#7e1c1187: field can_craft_at: %w", err) } m.CanCraftAt = value } + if m.Flags.Has(18) { + if err := m.Message.Decode(b); err != nil { + return fmt.Errorf("unable to decode messageActionStarGiftUnique#7e1c1187: field message: %w", err) + } + } return nil } @@ -11263,6 +11309,25 @@ func (m *MessageActionStarGiftUnique) GetCraft() (value bool) { return m.Flags.Has(16) } +// SetNameHidden sets value of NameHidden conditional field. +func (m *MessageActionStarGiftUnique) SetNameHidden(value bool) { + if value { + m.Flags.Set(17) + m.NameHidden = true + } else { + m.Flags.Unset(17) + m.NameHidden = false + } +} + +// GetNameHidden returns value of NameHidden conditional field. +func (m *MessageActionStarGiftUnique) GetNameHidden() (value bool) { + if m == nil { + return + } + return m.Flags.Has(17) +} + // GetGift returns value of Gift field. func (m *MessageActionStarGiftUnique) GetGift() (value StarGiftClass) { if m == nil { @@ -11451,6 +11516,24 @@ func (m *MessageActionStarGiftUnique) GetCanCraftAt() (value int, ok bool) { return m.CanCraftAt, true } +// SetMessage sets value of Message conditional field. +func (m *MessageActionStarGiftUnique) SetMessage(value TextWithEntities) { + m.Flags.Set(18) + m.Message = value +} + +// GetMessage returns value of Message conditional field and +// boolean which is true if field was set. +func (m *MessageActionStarGiftUnique) GetMessage() (value TextWithEntities, ok bool) { + if m == nil { + return + } + if !m.Flags.Has(18) { + return value, false + } + return m.Message, true +} + // MessageActionPaidMessagesRefunded represents TL type `messageActionPaidMessagesRefunded#ac1f1fcd`. // Sent from peer A to B, indicates that A refunded all stars¹ B previously paid to send // messages to A, see here »² for more info on paid messages. @@ -15450,6 +15533,140 @@ func (m *MessageActionChangeCommunity) GetCommunityID() (value int64, ok bool) { return m.CommunityID, true } +// MessageActionChatJoinedViaCommunity represents TL type `messageActionChatJoinedViaCommunity#4a8bfe80`. +// +// See https://core.telegram.org/constructor/messageActionChatJoinedViaCommunity for reference. +type MessageActionChatJoinedViaCommunity struct { + // CommunityID field of MessageActionChatJoinedViaCommunity. + CommunityID int64 +} + +// MessageActionChatJoinedViaCommunityTypeID is TL type id of MessageActionChatJoinedViaCommunity. +const MessageActionChatJoinedViaCommunityTypeID = 0x4a8bfe80 + +// construct implements constructor of MessageActionClass. +func (m MessageActionChatJoinedViaCommunity) construct() MessageActionClass { return &m } + +// Ensuring interfaces in compile-time for MessageActionChatJoinedViaCommunity. +var ( + _ bin.Encoder = &MessageActionChatJoinedViaCommunity{} + _ bin.Decoder = &MessageActionChatJoinedViaCommunity{} + _ bin.BareEncoder = &MessageActionChatJoinedViaCommunity{} + _ bin.BareDecoder = &MessageActionChatJoinedViaCommunity{} + + _ MessageActionClass = &MessageActionChatJoinedViaCommunity{} +) + +func (m *MessageActionChatJoinedViaCommunity) Zero() bool { + if m == nil { + return true + } + if !(m.CommunityID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (m *MessageActionChatJoinedViaCommunity) String() string { + if m == nil { + return "MessageActionChatJoinedViaCommunity(nil)" + } + type Alias MessageActionChatJoinedViaCommunity + return fmt.Sprintf("MessageActionChatJoinedViaCommunity%+v", Alias(*m)) +} + +// FillFrom fills MessageActionChatJoinedViaCommunity from given interface. +func (m *MessageActionChatJoinedViaCommunity) FillFrom(from interface { + GetCommunityID() (value int64) +}) { + m.CommunityID = from.GetCommunityID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessageActionChatJoinedViaCommunity) TypeID() uint32 { + return MessageActionChatJoinedViaCommunityTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessageActionChatJoinedViaCommunity) TypeName() string { + return "messageActionChatJoinedViaCommunity" +} + +// TypeInfo returns info about TL type. +func (m *MessageActionChatJoinedViaCommunity) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messageActionChatJoinedViaCommunity", + ID: MessageActionChatJoinedViaCommunityTypeID, + } + if m == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "CommunityID", + SchemaName: "community_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (m *MessageActionChatJoinedViaCommunity) Encode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionChatJoinedViaCommunity#4a8bfe80 as nil") + } + b.PutID(MessageActionChatJoinedViaCommunityTypeID) + return m.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (m *MessageActionChatJoinedViaCommunity) EncodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionChatJoinedViaCommunity#4a8bfe80 as nil") + } + b.PutLong(m.CommunityID) + return nil +} + +// Decode implements bin.Decoder. +func (m *MessageActionChatJoinedViaCommunity) Decode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionChatJoinedViaCommunity#4a8bfe80 to nil") + } + if err := b.ConsumeID(MessageActionChatJoinedViaCommunityTypeID); err != nil { + return fmt.Errorf("unable to decode messageActionChatJoinedViaCommunity#4a8bfe80: %w", err) + } + return m.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (m *MessageActionChatJoinedViaCommunity) DecodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionChatJoinedViaCommunity#4a8bfe80 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messageActionChatJoinedViaCommunity#4a8bfe80: field community_id: %w", err) + } + m.CommunityID = value + } + return nil +} + +// GetCommunityID returns value of CommunityID field. +func (m *MessageActionChatJoinedViaCommunity) GetCommunityID() (value int64) { + if m == nil { + return + } + return m.CommunityID +} + // MessageActionClassName is schema name of MessageActionClass. const MessageActionClassName = "MessageAction" @@ -15526,6 +15743,7 @@ const MessageActionClassName = "MessageAction" // - [MessageActionPollDeleteAnswer] // - [MessageActionManagedBotCreated] // - [MessageActionChangeCommunity] +// - [MessageActionChatJoinedViaCommunity] // // Example: // @@ -15581,7 +15799,7 @@ const MessageActionClassName = "MessageAction" // case *tg.MessageActionGiftStars: // messageActionGiftStars#45d5b021 // case *tg.MessageActionPrizeStars: // messageActionPrizeStars#b00c47a2 // case *tg.MessageActionStarGift: // messageActionStarGift#ea2c31d3 -// case *tg.MessageActionStarGiftUnique: // messageActionStarGiftUnique#e6c31522 +// case *tg.MessageActionStarGiftUnique: // messageActionStarGiftUnique#7e1c1187 // case *tg.MessageActionPaidMessagesRefunded: // messageActionPaidMessagesRefunded#ac1f1fcd // case *tg.MessageActionPaidMessagesPrice: // messageActionPaidMessagesPrice#84b88578 // case *tg.MessageActionConferenceCall: // messageActionConferenceCall#2ffe2f7a @@ -15602,6 +15820,7 @@ const MessageActionClassName = "MessageAction" // case *tg.MessageActionPollDeleteAnswer: // messageActionPollDeleteAnswer#399674dc // case *tg.MessageActionManagedBotCreated: // messageActionManagedBotCreated#16605e3e // case *tg.MessageActionChangeCommunity: // messageActionChangeCommunity#5d20bae8 +// case *tg.MessageActionChatJoinedViaCommunity: // messageActionChatJoinedViaCommunity#4a8bfe80 // default: panic(v) // } type MessageActionClass interface { @@ -15960,7 +16179,7 @@ func DecodeMessageAction(buf *bin.Buffer) (MessageActionClass, error) { } return &v, nil case MessageActionStarGiftUniqueTypeID: - // Decoding messageActionStarGiftUnique#e6c31522. + // Decoding messageActionStarGiftUnique#7e1c1187. v := MessageActionStarGiftUnique{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err) @@ -16106,6 +16325,13 @@ func DecodeMessageAction(buf *bin.Buffer) (MessageActionClass, error) { return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err) } return &v, nil + case MessageActionChatJoinedViaCommunityTypeID: + // Decoding messageActionChatJoinedViaCommunity#4a8bfe80. + v := MessageActionChatJoinedViaCommunity{} + 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 4b5bf29cc2..faf5d32d63 100644 --- a/tg/tl_message_action_slices_gen.go +++ b/tg/tl_message_action_slices_gen.go @@ -909,6 +909,19 @@ func (s MessageActionClassArray) AsMessageActionChangeCommunity() (to MessageAct return to } +// AsMessageActionChatJoinedViaCommunity returns copy with only MessageActionChatJoinedViaCommunity constructors. +func (s MessageActionClassArray) AsMessageActionChatJoinedViaCommunity() (to MessageActionChatJoinedViaCommunityArray) { + for _, elem := range s { + value, ok := elem.(*MessageActionChatJoinedViaCommunity) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // MessageActionChatCreateArray is adapter for slice of MessageActionChatCreate. type MessageActionChatCreateArray []MessageActionChatCreate @@ -5910,3 +5923,85 @@ func (s *MessageActionChangeCommunityArray) Pop() (v MessageActionChangeCommunit return v, true } + +// MessageActionChatJoinedViaCommunityArray is adapter for slice of MessageActionChatJoinedViaCommunity. +type MessageActionChatJoinedViaCommunityArray []MessageActionChatJoinedViaCommunity + +// Sort sorts slice of MessageActionChatJoinedViaCommunity. +func (s MessageActionChatJoinedViaCommunityArray) Sort(less func(a, b MessageActionChatJoinedViaCommunity) bool) MessageActionChatJoinedViaCommunityArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessageActionChatJoinedViaCommunity. +func (s MessageActionChatJoinedViaCommunityArray) SortStable(less func(a, b MessageActionChatJoinedViaCommunity) bool) MessageActionChatJoinedViaCommunityArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessageActionChatJoinedViaCommunity. +func (s MessageActionChatJoinedViaCommunityArray) Retain(keep func(x MessageActionChatJoinedViaCommunity) bool) MessageActionChatJoinedViaCommunityArray { + 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 MessageActionChatJoinedViaCommunityArray) First() (v MessageActionChatJoinedViaCommunity, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessageActionChatJoinedViaCommunityArray) Last() (v MessageActionChatJoinedViaCommunity, 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 *MessageActionChatJoinedViaCommunityArray) PopFirst() (v MessageActionChatJoinedViaCommunity, 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 MessageActionChatJoinedViaCommunity + 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 *MessageActionChatJoinedViaCommunityArray) Pop() (v MessageActionChatJoinedViaCommunity, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_messages_forward_messages_gen.go b/tg/tl_messages_forward_messages_gen.go index de3a93de22..160948ef44 100644 --- a/tg/tl_messages_forward_messages_gen.go +++ b/tg/tl_messages_forward_messages_gen.go @@ -65,6 +65,8 @@ type MessagesForwardMessagesRequest struct { // Links: // 1) https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once AllowPaidFloodskip bool + // FromEphemeral field of MessagesForwardMessagesRequest. + FromEphemeral bool // Source of messages FromPeer InputPeerClass // IDs of messages @@ -181,6 +183,9 @@ func (f *MessagesForwardMessagesRequest) Zero() bool { if !(f.AllowPaidFloodskip == false) { return false } + if !(f.FromEphemeral == false) { + return false + } if !(f.FromPeer == nil) { return false } @@ -245,6 +250,7 @@ func (f *MessagesForwardMessagesRequest) FillFrom(from interface { GetDropMediaCaptions() (value bool) GetNoforwards() (value bool) GetAllowPaidFloodskip() (value bool) + GetFromEphemeral() (value bool) GetFromPeer() (value InputPeerClass) GetID() (value []int) GetRandomID() (value []int64) @@ -267,6 +273,7 @@ func (f *MessagesForwardMessagesRequest) FillFrom(from interface { f.DropMediaCaptions = from.GetDropMediaCaptions() f.Noforwards = from.GetNoforwards() f.AllowPaidFloodskip = from.GetAllowPaidFloodskip() + f.FromEphemeral = from.GetFromEphemeral() f.FromPeer = from.GetFromPeer() f.ID = from.GetID() f.RandomID = from.GetRandomID() @@ -371,6 +378,11 @@ func (f *MessagesForwardMessagesRequest) TypeInfo() tdp.Type { SchemaName: "allow_paid_floodskip", Null: !f.Flags.Has(19), }, + { + Name: "FromEphemeral", + SchemaName: "from_ephemeral", + Null: !f.Flags.Has(25), + }, { Name: "FromPeer", SchemaName: "from_peer", @@ -464,6 +476,9 @@ func (f *MessagesForwardMessagesRequest) SetFlags() { if !(f.AllowPaidFloodskip == false) { f.Flags.Set(19) } + if !(f.FromEphemeral == false) { + f.Flags.Set(25) + } if !(f.TopMsgID == 0) { f.Flags.Set(9) } @@ -612,6 +627,7 @@ func (f *MessagesForwardMessagesRequest) DecodeBare(b *bin.Buffer) error { f.DropMediaCaptions = f.Flags.Has(12) f.Noforwards = f.Flags.Has(14) f.AllowPaidFloodskip = f.Flags.Has(19) + f.FromEphemeral = f.Flags.Has(25) { value, err := DecodeInputPeer(b) if err != nil { @@ -864,6 +880,25 @@ func (f *MessagesForwardMessagesRequest) GetAllowPaidFloodskip() (value bool) { return f.Flags.Has(19) } +// SetFromEphemeral sets value of FromEphemeral conditional field. +func (f *MessagesForwardMessagesRequest) SetFromEphemeral(value bool) { + if value { + f.Flags.Set(25) + f.FromEphemeral = true + } else { + f.Flags.Unset(25) + f.FromEphemeral = false + } +} + +// GetFromEphemeral returns value of FromEphemeral conditional field. +func (f *MessagesForwardMessagesRequest) GetFromEphemeral() (value bool) { + if f == nil { + return + } + return f.Flags.Has(25) +} + // GetFromPeer returns value of FromPeer field. func (f *MessagesForwardMessagesRequest) GetFromPeer() (value InputPeerClass) { if f == nil { diff --git a/tg/tl_page_block_gen.go b/tg/tl_page_block_gen.go index 3f62947eec..dc3e62360c 100644 --- a/tg/tl_page_block_gen.go +++ b/tg/tl_page_block_gen.go @@ -1702,11 +1702,15 @@ func (p *PageBlockList) MapItems() (value PageListItemClassArray) { return PageListItemClassArray(p.Items) } -// PageBlockBlockquote represents TL type `pageBlockBlockquote#263d7c26`. +// PageBlockBlockquote represents TL type `pageBlockBlockquote#66d1670b`. // Quote (equivalent to the HTML
) // // See https://core.telegram.org/constructor/pageBlockBlockquote for reference. type PageBlockBlockquote struct { + // Flags field of PageBlockBlockquote. + Flags bin.Fields + // Collapsed field of PageBlockBlockquote. + Collapsed bool // Quote contents Text RichTextClass // Caption @@ -1714,7 +1718,7 @@ type PageBlockBlockquote struct { } // PageBlockBlockquoteTypeID is TL type id of PageBlockBlockquote. -const PageBlockBlockquoteTypeID = 0x263d7c26 +const PageBlockBlockquoteTypeID = 0x66d1670b // construct implements constructor of PageBlockClass. func (p PageBlockBlockquote) construct() PageBlockClass { return &p } @@ -1733,6 +1737,12 @@ func (p *PageBlockBlockquote) Zero() bool { if p == nil { return true } + if !(p.Flags.Zero()) { + return false + } + if !(p.Collapsed == false) { + return false + } if !(p.Text == nil) { return false } @@ -1754,9 +1764,11 @@ func (p *PageBlockBlockquote) String() string { // FillFrom fills PageBlockBlockquote from given interface. func (p *PageBlockBlockquote) FillFrom(from interface { + GetCollapsed() (value bool) GetText() (value RichTextClass) GetCaption() (value RichTextClass) }) { + p.Collapsed = from.GetCollapsed() p.Text = from.GetText() p.Caption = from.GetCaption() } @@ -1784,6 +1796,11 @@ func (p *PageBlockBlockquote) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "Collapsed", + SchemaName: "collapsed", + Null: !p.Flags.Has(0), + }, { Name: "Text", SchemaName: "text", @@ -1796,10 +1813,17 @@ func (p *PageBlockBlockquote) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (p *PageBlockBlockquote) SetFlags() { + if !(p.Collapsed == false) { + p.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (p *PageBlockBlockquote) Encode(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't encode pageBlockBlockquote#263d7c26 as nil") + return fmt.Errorf("can't encode pageBlockBlockquote#66d1670b as nil") } b.PutID(PageBlockBlockquoteTypeID) return p.EncodeBare(b) @@ -1808,19 +1832,23 @@ func (p *PageBlockBlockquote) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (p *PageBlockBlockquote) EncodeBare(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't encode pageBlockBlockquote#263d7c26 as nil") + return fmt.Errorf("can't encode pageBlockBlockquote#66d1670b as nil") + } + p.SetFlags() + if err := p.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode pageBlockBlockquote#66d1670b: field flags: %w", err) } if p.Text == nil { - return fmt.Errorf("unable to encode pageBlockBlockquote#263d7c26: field text is nil") + return fmt.Errorf("unable to encode pageBlockBlockquote#66d1670b: field text is nil") } if err := p.Text.Encode(b); err != nil { - return fmt.Errorf("unable to encode pageBlockBlockquote#263d7c26: field text: %w", err) + return fmt.Errorf("unable to encode pageBlockBlockquote#66d1670b: field text: %w", err) } if p.Caption == nil { - return fmt.Errorf("unable to encode pageBlockBlockquote#263d7c26: field caption is nil") + return fmt.Errorf("unable to encode pageBlockBlockquote#66d1670b: field caption is nil") } if err := p.Caption.Encode(b); err != nil { - return fmt.Errorf("unable to encode pageBlockBlockquote#263d7c26: field caption: %w", err) + return fmt.Errorf("unable to encode pageBlockBlockquote#66d1670b: field caption: %w", err) } return nil } @@ -1828,10 +1856,10 @@ func (p *PageBlockBlockquote) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (p *PageBlockBlockquote) Decode(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't decode pageBlockBlockquote#263d7c26 to nil") + return fmt.Errorf("can't decode pageBlockBlockquote#66d1670b to nil") } if err := b.ConsumeID(PageBlockBlockquoteTypeID); err != nil { - return fmt.Errorf("unable to decode pageBlockBlockquote#263d7c26: %w", err) + return fmt.Errorf("unable to decode pageBlockBlockquote#66d1670b: %w", err) } return p.DecodeBare(b) } @@ -1839,25 +1867,50 @@ func (p *PageBlockBlockquote) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (p *PageBlockBlockquote) DecodeBare(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't decode pageBlockBlockquote#263d7c26 to nil") + return fmt.Errorf("can't decode pageBlockBlockquote#66d1670b to nil") } + { + if err := p.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode pageBlockBlockquote#66d1670b: field flags: %w", err) + } + } + p.Collapsed = p.Flags.Has(0) { value, err := DecodeRichText(b) if err != nil { - return fmt.Errorf("unable to decode pageBlockBlockquote#263d7c26: field text: %w", err) + return fmt.Errorf("unable to decode pageBlockBlockquote#66d1670b: field text: %w", err) } p.Text = value } { value, err := DecodeRichText(b) if err != nil { - return fmt.Errorf("unable to decode pageBlockBlockquote#263d7c26: field caption: %w", err) + return fmt.Errorf("unable to decode pageBlockBlockquote#66d1670b: field caption: %w", err) } p.Caption = value } return nil } +// SetCollapsed sets value of Collapsed conditional field. +func (p *PageBlockBlockquote) SetCollapsed(value bool) { + if value { + p.Flags.Set(0) + p.Collapsed = true + } else { + p.Flags.Unset(0) + p.Collapsed = false + } +} + +// GetCollapsed returns value of Collapsed conditional field. +func (p *PageBlockBlockquote) GetCollapsed() (value bool) { + if p == nil { + return + } + return p.Flags.Has(0) +} + // GetText returns value of Text field. func (p *PageBlockBlockquote) GetText() (value RichTextClass) { if p == nil { @@ -4403,6 +4456,8 @@ type PageBlockTable struct { Bordered bool // Is the table striped? Striped bool + // Compact field of PageBlockTable. + Compact bool // Title Title RichTextClass // Table rows @@ -4438,6 +4493,9 @@ func (p *PageBlockTable) Zero() bool { if !(p.Striped == false) { return false } + if !(p.Compact == false) { + return false + } if !(p.Title == nil) { return false } @@ -4461,11 +4519,13 @@ func (p *PageBlockTable) String() string { func (p *PageBlockTable) FillFrom(from interface { GetBordered() (value bool) GetStriped() (value bool) + GetCompact() (value bool) GetTitle() (value RichTextClass) GetRows() (value []PageTableRow) }) { p.Bordered = from.GetBordered() p.Striped = from.GetStriped() + p.Compact = from.GetCompact() p.Title = from.GetTitle() p.Rows = from.GetRows() } @@ -4503,6 +4563,11 @@ func (p *PageBlockTable) TypeInfo() tdp.Type { SchemaName: "striped", Null: !p.Flags.Has(1), }, + { + Name: "Compact", + SchemaName: "compact", + Null: !p.Flags.Has(2), + }, { Name: "Title", SchemaName: "title", @@ -4523,6 +4588,9 @@ func (p *PageBlockTable) SetFlags() { if !(p.Striped == false) { p.Flags.Set(1) } + if !(p.Compact == false) { + p.Flags.Set(2) + } } // Encode implements bin.Encoder. @@ -4581,6 +4649,7 @@ func (p *PageBlockTable) DecodeBare(b *bin.Buffer) error { } p.Bordered = p.Flags.Has(0) p.Striped = p.Flags.Has(1) + p.Compact = p.Flags.Has(2) { value, err := DecodeRichText(b) if err != nil { @@ -4646,6 +4715,25 @@ func (p *PageBlockTable) GetStriped() (value bool) { return p.Flags.Has(1) } +// SetCompact sets value of Compact conditional field. +func (p *PageBlockTable) SetCompact(value bool) { + if value { + p.Flags.Set(2) + p.Compact = true + } else { + p.Flags.Unset(2) + p.Compact = false + } +} + +// GetCompact returns value of Compact conditional field. +func (p *PageBlockTable) GetCompact() (value bool) { + if p == nil { + return + } + return p.Flags.Has(2) +} + // GetTitle returns value of Title field. func (p *PageBlockTable) GetTitle() (value RichTextClass) { if p == nil { @@ -7188,6 +7276,439 @@ func (p *PageBlockBlockquoteBlocks) MapBlocks() (value PageBlockClassArray) { return PageBlockClassArray(p.Blocks) } +// PageBlockButtonRow represents TL type `pageBlockButtonRow#6d640318`. +// +// See https://core.telegram.org/constructor/pageBlockButtonRow for reference. +type PageBlockButtonRow struct { + // Flags field of PageBlockButtonRow. + Flags bin.Fields + // AlignLeft field of PageBlockButtonRow. + AlignLeft bool + // AlignCenter field of PageBlockButtonRow. + AlignCenter bool + // AlignRight field of PageBlockButtonRow. + AlignRight bool + // Buttons field of PageBlockButtonRow. + Buttons []PageButton +} + +// PageBlockButtonRowTypeID is TL type id of PageBlockButtonRow. +const PageBlockButtonRowTypeID = 0x6d640318 + +// construct implements constructor of PageBlockClass. +func (p PageBlockButtonRow) construct() PageBlockClass { return &p } + +// Ensuring interfaces in compile-time for PageBlockButtonRow. +var ( + _ bin.Encoder = &PageBlockButtonRow{} + _ bin.Decoder = &PageBlockButtonRow{} + _ bin.BareEncoder = &PageBlockButtonRow{} + _ bin.BareDecoder = &PageBlockButtonRow{} + + _ PageBlockClass = &PageBlockButtonRow{} +) + +func (p *PageBlockButtonRow) Zero() bool { + if p == nil { + return true + } + if !(p.Flags.Zero()) { + return false + } + if !(p.AlignLeft == false) { + return false + } + if !(p.AlignCenter == false) { + return false + } + if !(p.AlignRight == false) { + return false + } + if !(p.Buttons == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (p *PageBlockButtonRow) String() string { + if p == nil { + return "PageBlockButtonRow(nil)" + } + type Alias PageBlockButtonRow + return fmt.Sprintf("PageBlockButtonRow%+v", Alias(*p)) +} + +// FillFrom fills PageBlockButtonRow from given interface. +func (p *PageBlockButtonRow) FillFrom(from interface { + GetAlignLeft() (value bool) + GetAlignCenter() (value bool) + GetAlignRight() (value bool) + GetButtons() (value []PageButton) +}) { + p.AlignLeft = from.GetAlignLeft() + p.AlignCenter = from.GetAlignCenter() + p.AlignRight = from.GetAlignRight() + p.Buttons = from.GetButtons() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PageBlockButtonRow) TypeID() uint32 { + return PageBlockButtonRowTypeID +} + +// TypeName returns name of type in TL schema. +func (*PageBlockButtonRow) TypeName() string { + return "pageBlockButtonRow" +} + +// TypeInfo returns info about TL type. +func (p *PageBlockButtonRow) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "pageBlockButtonRow", + ID: PageBlockButtonRowTypeID, + } + if p == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "AlignLeft", + SchemaName: "align_left", + Null: !p.Flags.Has(0), + }, + { + Name: "AlignCenter", + SchemaName: "align_center", + Null: !p.Flags.Has(1), + }, + { + Name: "AlignRight", + SchemaName: "align_right", + Null: !p.Flags.Has(2), + }, + { + Name: "Buttons", + SchemaName: "buttons", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (p *PageBlockButtonRow) SetFlags() { + if !(p.AlignLeft == false) { + p.Flags.Set(0) + } + if !(p.AlignCenter == false) { + p.Flags.Set(1) + } + if !(p.AlignRight == false) { + p.Flags.Set(2) + } +} + +// Encode implements bin.Encoder. +func (p *PageBlockButtonRow) Encode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode pageBlockButtonRow#6d640318 as nil") + } + b.PutID(PageBlockButtonRowTypeID) + return p.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (p *PageBlockButtonRow) EncodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode pageBlockButtonRow#6d640318 as nil") + } + p.SetFlags() + if err := p.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode pageBlockButtonRow#6d640318: field flags: %w", err) + } + b.PutVectorHeader(len(p.Buttons)) + for idx, v := range p.Buttons { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode pageBlockButtonRow#6d640318: field buttons element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (p *PageBlockButtonRow) Decode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode pageBlockButtonRow#6d640318 to nil") + } + if err := b.ConsumeID(PageBlockButtonRowTypeID); err != nil { + return fmt.Errorf("unable to decode pageBlockButtonRow#6d640318: %w", err) + } + return p.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (p *PageBlockButtonRow) DecodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode pageBlockButtonRow#6d640318 to nil") + } + { + if err := p.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode pageBlockButtonRow#6d640318: field flags: %w", err) + } + } + p.AlignLeft = p.Flags.Has(0) + p.AlignCenter = p.Flags.Has(1) + p.AlignRight = p.Flags.Has(2) + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode pageBlockButtonRow#6d640318: field buttons: %w", err) + } + + if headerLen > 0 { + p.Buttons = make([]PageButton, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value PageButton + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode pageBlockButtonRow#6d640318: field buttons: %w", err) + } + p.Buttons = append(p.Buttons, value) + } + } + return nil +} + +// SetAlignLeft sets value of AlignLeft conditional field. +func (p *PageBlockButtonRow) SetAlignLeft(value bool) { + if value { + p.Flags.Set(0) + p.AlignLeft = true + } else { + p.Flags.Unset(0) + p.AlignLeft = false + } +} + +// GetAlignLeft returns value of AlignLeft conditional field. +func (p *PageBlockButtonRow) GetAlignLeft() (value bool) { + if p == nil { + return + } + return p.Flags.Has(0) +} + +// SetAlignCenter sets value of AlignCenter conditional field. +func (p *PageBlockButtonRow) SetAlignCenter(value bool) { + if value { + p.Flags.Set(1) + p.AlignCenter = true + } else { + p.Flags.Unset(1) + p.AlignCenter = false + } +} + +// GetAlignCenter returns value of AlignCenter conditional field. +func (p *PageBlockButtonRow) GetAlignCenter() (value bool) { + if p == nil { + return + } + return p.Flags.Has(1) +} + +// SetAlignRight sets value of AlignRight conditional field. +func (p *PageBlockButtonRow) SetAlignRight(value bool) { + if value { + p.Flags.Set(2) + p.AlignRight = true + } else { + p.Flags.Unset(2) + p.AlignRight = false + } +} + +// GetAlignRight returns value of AlignRight conditional field. +func (p *PageBlockButtonRow) GetAlignRight() (value bool) { + if p == nil { + return + } + return p.Flags.Has(2) +} + +// GetButtons returns value of Buttons field. +func (p *PageBlockButtonRow) GetButtons() (value []PageButton) { + if p == nil { + return + } + return p.Buttons +} + +// PageBlockDocument represents TL type `pageBlockDocument#38fa3ba3`. +// +// See https://core.telegram.org/constructor/pageBlockDocument for reference. +type PageBlockDocument struct { + // DocumentID field of PageBlockDocument. + DocumentID int64 + // Caption field of PageBlockDocument. + Caption PageCaption +} + +// PageBlockDocumentTypeID is TL type id of PageBlockDocument. +const PageBlockDocumentTypeID = 0x38fa3ba3 + +// construct implements constructor of PageBlockClass. +func (p PageBlockDocument) construct() PageBlockClass { return &p } + +// Ensuring interfaces in compile-time for PageBlockDocument. +var ( + _ bin.Encoder = &PageBlockDocument{} + _ bin.Decoder = &PageBlockDocument{} + _ bin.BareEncoder = &PageBlockDocument{} + _ bin.BareDecoder = &PageBlockDocument{} + + _ PageBlockClass = &PageBlockDocument{} +) + +func (p *PageBlockDocument) Zero() bool { + if p == nil { + return true + } + if !(p.DocumentID == 0) { + return false + } + if !(p.Caption.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (p *PageBlockDocument) String() string { + if p == nil { + return "PageBlockDocument(nil)" + } + type Alias PageBlockDocument + return fmt.Sprintf("PageBlockDocument%+v", Alias(*p)) +} + +// FillFrom fills PageBlockDocument from given interface. +func (p *PageBlockDocument) FillFrom(from interface { + GetDocumentID() (value int64) + GetCaption() (value PageCaption) +}) { + p.DocumentID = from.GetDocumentID() + p.Caption = from.GetCaption() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PageBlockDocument) TypeID() uint32 { + return PageBlockDocumentTypeID +} + +// TypeName returns name of type in TL schema. +func (*PageBlockDocument) TypeName() string { + return "pageBlockDocument" +} + +// TypeInfo returns info about TL type. +func (p *PageBlockDocument) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "pageBlockDocument", + ID: PageBlockDocumentTypeID, + } + if p == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "DocumentID", + SchemaName: "document_id", + }, + { + Name: "Caption", + SchemaName: "caption", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (p *PageBlockDocument) Encode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode pageBlockDocument#38fa3ba3 as nil") + } + b.PutID(PageBlockDocumentTypeID) + return p.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (p *PageBlockDocument) EncodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode pageBlockDocument#38fa3ba3 as nil") + } + b.PutLong(p.DocumentID) + if err := p.Caption.Encode(b); err != nil { + return fmt.Errorf("unable to encode pageBlockDocument#38fa3ba3: field caption: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (p *PageBlockDocument) Decode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode pageBlockDocument#38fa3ba3 to nil") + } + if err := b.ConsumeID(PageBlockDocumentTypeID); err != nil { + return fmt.Errorf("unable to decode pageBlockDocument#38fa3ba3: %w", err) + } + return p.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (p *PageBlockDocument) DecodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode pageBlockDocument#38fa3ba3 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode pageBlockDocument#38fa3ba3: field document_id: %w", err) + } + p.DocumentID = value + } + { + if err := p.Caption.Decode(b); err != nil { + return fmt.Errorf("unable to decode pageBlockDocument#38fa3ba3: field caption: %w", err) + } + } + return nil +} + +// GetDocumentID returns value of DocumentID field. +func (p *PageBlockDocument) GetDocumentID() (value int64) { + if p == nil { + return + } + return p.DocumentID +} + +// GetCaption returns value of Caption field. +func (p *PageBlockDocument) GetCaption() (value PageCaption) { + if p == nil { + return + } + return p.Caption +} + // PageBlockClassName is schema name of PageBlockClass. const PageBlockClassName = "PageBlock" @@ -7235,6 +7756,8 @@ const PageBlockClassName = "PageBlock" // - [PageBlockThinking] // - [InputPageBlockMap] // - [PageBlockBlockquoteBlocks] +// - [PageBlockButtonRow] +// - [PageBlockDocument] // // Example: // @@ -7255,7 +7778,7 @@ const PageBlockClassName = "PageBlock" // case *tg.PageBlockDivider: // pageBlockDivider#db20b188 // case *tg.PageBlockAnchor: // pageBlockAnchor#ce0d37b0 // case *tg.PageBlockList: // pageBlockList#e4e88011 -// case *tg.PageBlockBlockquote: // pageBlockBlockquote#263d7c26 +// case *tg.PageBlockBlockquote: // pageBlockBlockquote#66d1670b // case *tg.PageBlockPullquote: // pageBlockPullquote#4f4456d3 // case *tg.PageBlockPhoto: // pageBlockPhoto#1759c560 // case *tg.PageBlockVideo: // pageBlockVideo#7c8fe7b6 @@ -7282,6 +7805,8 @@ const PageBlockClassName = "PageBlock" // case *tg.PageBlockThinking: // pageBlockThinking#3c29a3e2 // case *tg.InputPageBlockMap: // inputPageBlockMap#574b617f // case *tg.PageBlockBlockquoteBlocks: // pageBlockBlockquoteBlocks#e6e47c4 +// case *tg.PageBlockButtonRow: // pageBlockButtonRow#6d640318 +// case *tg.PageBlockDocument: // pageBlockDocument#38fa3ba3 // default: panic(v) // } type PageBlockClass interface { @@ -7395,7 +7920,7 @@ func DecodePageBlock(buf *bin.Buffer) (PageBlockClass, error) { } return &v, nil case PageBlockBlockquoteTypeID: - // Decoding pageBlockBlockquote#263d7c26. + // Decoding pageBlockBlockquote#66d1670b. v := PageBlockBlockquote{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err) @@ -7583,6 +8108,20 @@ func DecodePageBlock(buf *bin.Buffer) (PageBlockClass, error) { return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err) } return &v, nil + case PageBlockButtonRowTypeID: + // Decoding pageBlockButtonRow#6d640318. + v := PageBlockButtonRow{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err) + } + return &v, nil + case PageBlockDocumentTypeID: + // Decoding pageBlockDocument#38fa3ba3. + v := PageBlockDocument{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode PageBlockClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_page_block_slices_gen.go b/tg/tl_page_block_slices_gen.go index f8af2e000f..7c78e28856 100644 --- a/tg/tl_page_block_slices_gen.go +++ b/tg/tl_page_block_slices_gen.go @@ -597,6 +597,32 @@ func (s PageBlockClassArray) AsPageBlockBlockquoteBlocks() (to PageBlockBlockquo return to } +// AsPageBlockButtonRow returns copy with only PageBlockButtonRow constructors. +func (s PageBlockClassArray) AsPageBlockButtonRow() (to PageBlockButtonRowArray) { + for _, elem := range s { + value, ok := elem.(*PageBlockButtonRow) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsPageBlockDocument returns copy with only PageBlockDocument constructors. +func (s PageBlockClassArray) AsPageBlockDocument() (to PageBlockDocumentArray) { + for _, elem := range s { + value, ok := elem.(*PageBlockDocument) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // PageBlockTitleArray is adapter for slice of PageBlockTitle. type PageBlockTitleArray []PageBlockTitle @@ -3644,3 +3670,167 @@ func (s *PageBlockBlockquoteBlocksArray) Pop() (v PageBlockBlockquoteBlocks, ok return v, true } + +// PageBlockButtonRowArray is adapter for slice of PageBlockButtonRow. +type PageBlockButtonRowArray []PageBlockButtonRow + +// Sort sorts slice of PageBlockButtonRow. +func (s PageBlockButtonRowArray) Sort(less func(a, b PageBlockButtonRow) bool) PageBlockButtonRowArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of PageBlockButtonRow. +func (s PageBlockButtonRowArray) SortStable(less func(a, b PageBlockButtonRow) bool) PageBlockButtonRowArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of PageBlockButtonRow. +func (s PageBlockButtonRowArray) Retain(keep func(x PageBlockButtonRow) bool) PageBlockButtonRowArray { + 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 PageBlockButtonRowArray) First() (v PageBlockButtonRow, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s PageBlockButtonRowArray) Last() (v PageBlockButtonRow, 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 *PageBlockButtonRowArray) PopFirst() (v PageBlockButtonRow, 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 PageBlockButtonRow + 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 *PageBlockButtonRowArray) Pop() (v PageBlockButtonRow, 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 +} + +// PageBlockDocumentArray is adapter for slice of PageBlockDocument. +type PageBlockDocumentArray []PageBlockDocument + +// Sort sorts slice of PageBlockDocument. +func (s PageBlockDocumentArray) Sort(less func(a, b PageBlockDocument) bool) PageBlockDocumentArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of PageBlockDocument. +func (s PageBlockDocumentArray) SortStable(less func(a, b PageBlockDocument) bool) PageBlockDocumentArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of PageBlockDocument. +func (s PageBlockDocumentArray) Retain(keep func(x PageBlockDocument) bool) PageBlockDocumentArray { + 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 PageBlockDocumentArray) First() (v PageBlockDocument, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s PageBlockDocumentArray) Last() (v PageBlockDocument, 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 *PageBlockDocumentArray) PopFirst() (v PageBlockDocument, 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 PageBlockDocument + 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 *PageBlockDocumentArray) Pop() (v PageBlockDocument, 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_page_button_gen.go b/tg/tl_page_button_gen.go new file mode 100644 index 0000000000..ad21d776f1 --- /dev/null +++ b/tg/tl_page_button_gen.go @@ -0,0 +1,264 @@ +// 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{} +) + +// PageButton represents TL type `pageButton#692a5488`. +// +// See https://core.telegram.org/constructor/pageButton for reference. +type PageButton struct { + // Flags field of PageButton. + Flags bin.Fields + // Text field of PageButton. + Text RichTextClass + // Type field of PageButton. + Type InlineButtonTypeClass + // Style field of PageButton. + // + // Use SetStyle and GetStyle helpers. + Style RichButtonStyle +} + +// PageButtonTypeID is TL type id of PageButton. +const PageButtonTypeID = 0x692a5488 + +// Ensuring interfaces in compile-time for PageButton. +var ( + _ bin.Encoder = &PageButton{} + _ bin.Decoder = &PageButton{} + _ bin.BareEncoder = &PageButton{} + _ bin.BareDecoder = &PageButton{} +) + +func (p *PageButton) Zero() bool { + if p == nil { + return true + } + if !(p.Flags.Zero()) { + return false + } + if !(p.Text == nil) { + return false + } + if !(p.Type == nil) { + return false + } + if !(p.Style.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (p *PageButton) String() string { + if p == nil { + return "PageButton(nil)" + } + type Alias PageButton + return fmt.Sprintf("PageButton%+v", Alias(*p)) +} + +// FillFrom fills PageButton from given interface. +func (p *PageButton) FillFrom(from interface { + GetText() (value RichTextClass) + GetType() (value InlineButtonTypeClass) + GetStyle() (value RichButtonStyle, ok bool) +}) { + p.Text = from.GetText() + p.Type = from.GetType() + if val, ok := from.GetStyle(); ok { + p.Style = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*PageButton) TypeID() uint32 { + return PageButtonTypeID +} + +// TypeName returns name of type in TL schema. +func (*PageButton) TypeName() string { + return "pageButton" +} + +// TypeInfo returns info about TL type. +func (p *PageButton) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "pageButton", + ID: PageButtonTypeID, + } + if p == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Text", + SchemaName: "text", + }, + { + Name: "Type", + SchemaName: "type", + }, + { + Name: "Style", + SchemaName: "style", + Null: !p.Flags.Has(0), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (p *PageButton) SetFlags() { + if !(p.Style.Zero()) { + p.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (p *PageButton) Encode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode pageButton#692a5488 as nil") + } + b.PutID(PageButtonTypeID) + return p.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (p *PageButton) EncodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode pageButton#692a5488 as nil") + } + p.SetFlags() + if err := p.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode pageButton#692a5488: field flags: %w", err) + } + if p.Text == nil { + return fmt.Errorf("unable to encode pageButton#692a5488: field text is nil") + } + if err := p.Text.Encode(b); err != nil { + return fmt.Errorf("unable to encode pageButton#692a5488: field text: %w", err) + } + if p.Type == nil { + return fmt.Errorf("unable to encode pageButton#692a5488: field type is nil") + } + if err := p.Type.Encode(b); err != nil { + return fmt.Errorf("unable to encode pageButton#692a5488: field type: %w", err) + } + if p.Flags.Has(0) { + if err := p.Style.Encode(b); err != nil { + return fmt.Errorf("unable to encode pageButton#692a5488: field style: %w", err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (p *PageButton) Decode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode pageButton#692a5488 to nil") + } + if err := b.ConsumeID(PageButtonTypeID); err != nil { + return fmt.Errorf("unable to decode pageButton#692a5488: %w", err) + } + return p.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (p *PageButton) DecodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode pageButton#692a5488 to nil") + } + { + if err := p.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode pageButton#692a5488: field flags: %w", err) + } + } + { + value, err := DecodeRichText(b) + if err != nil { + return fmt.Errorf("unable to decode pageButton#692a5488: field text: %w", err) + } + p.Text = value + } + { + value, err := DecodeInlineButtonType(b) + if err != nil { + return fmt.Errorf("unable to decode pageButton#692a5488: field type: %w", err) + } + p.Type = value + } + if p.Flags.Has(0) { + if err := p.Style.Decode(b); err != nil { + return fmt.Errorf("unable to decode pageButton#692a5488: field style: %w", err) + } + } + return nil +} + +// GetText returns value of Text field. +func (p *PageButton) GetText() (value RichTextClass) { + if p == nil { + return + } + return p.Text +} + +// GetType returns value of Type field. +func (p *PageButton) GetType() (value InlineButtonTypeClass) { + if p == nil { + return + } + return p.Type +} + +// SetStyle sets value of Style conditional field. +func (p *PageButton) SetStyle(value RichButtonStyle) { + p.Flags.Set(0) + p.Style = value +} + +// GetStyle returns value of Style conditional field and +// boolean which is true if field was set. +func (p *PageButton) GetStyle() (value RichButtonStyle, ok bool) { + if p == nil { + return + } + if !p.Flags.Has(0) { + return value, false + } + return p.Style, true +} diff --git a/tg/tl_page_button_slices_gen.go b/tg/tl_page_button_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_page_button_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_registry_gen.go b/tg/tl_registry_gen.go index 427d513aea..e5b007977c 100644 --- a/tg/tl_registry_gen.go +++ b/tg/tl_registry_gen.go @@ -32,7 +32,7 @@ var ( ) // Layer version of schema. -const Layer = 228 +const Layer = 229 // TypesMap returns mapping from type ids to TL type names. func TypesMap() map[uint32]string { @@ -203,7 +203,7 @@ func TypesMap() map[uint32]string { MessageActionGiftStarsTypeID: "messageActionGiftStars#45d5b021", MessageActionPrizeStarsTypeID: "messageActionPrizeStars#b00c47a2", MessageActionStarGiftTypeID: "messageActionStarGift#ea2c31d3", - MessageActionStarGiftUniqueTypeID: "messageActionStarGiftUnique#e6c31522", + MessageActionStarGiftUniqueTypeID: "messageActionStarGiftUnique#7e1c1187", MessageActionPaidMessagesRefundedTypeID: "messageActionPaidMessagesRefunded#ac1f1fcd", MessageActionPaidMessagesPriceTypeID: "messageActionPaidMessagesPrice#84b88578", MessageActionConferenceCallTypeID: "messageActionConferenceCall#2ffe2f7a", @@ -224,6 +224,7 @@ func TypesMap() map[uint32]string { MessageActionPollDeleteAnswerTypeID: "messageActionPollDeleteAnswer#399674dc", MessageActionManagedBotCreatedTypeID: "messageActionManagedBotCreated#16605e3e", MessageActionChangeCommunityTypeID: "messageActionChangeCommunity#5d20bae8", + MessageActionChatJoinedViaCommunityTypeID: "messageActionChatJoinedViaCommunity#4a8bfe80", DialogTypeID: "dialog#fc89f7f3", DialogFolderTypeID: "dialogFolder#71bd134c", DialogCommunityTypeID: "dialogCommunity#f78a0973", @@ -465,6 +466,7 @@ func TypesMap() map[uint32]string { UpdateNewEphemeralMessageTypeID: "updateNewEphemeralMessage#20bcbba1", UpdateDeleteEphemeralMessagesTypeID: "updateDeleteEphemeralMessages#56dbfcf8", UpdateEditEphemeralMessageTypeID: "updateEditEphemeralMessage#4bbb8f01", + UpdateEphemeralBotCallbackQueryTypeID: "updateEphemeralBotCallbackQuery#7c1079d6", UpdateBotStarsSubscriptionTypeID: "updateBotStarsSubscription#6c0d8e23", UpdatesStateTypeID: "updates.state#a56c2a3e", UpdatesDifferenceEmptyTypeID: "updates.differenceEmpty#5d75a138", @@ -536,9 +538,10 @@ func TypesMap() map[uint32]string { SendMessageChooseStickerActionTypeID: "sendMessageChooseStickerAction#b05ac6b1", SendMessageEmojiInteractionTypeID: "sendMessageEmojiInteraction#25972bcb", SendMessageEmojiInteractionSeenTypeID: "sendMessageEmojiInteractionSeen#b665902e", - SendMessageTextDraftActionTypeID: "sendMessageTextDraftAction#376d975c", - InputSendMessageRichMessageDraftActionTypeID: "inputSendMessageRichMessageDraftAction#e2b23b51", - SendMessageRichMessageDraftActionTypeID: "sendMessageRichMessageDraftAction#a2cb24f9", + SendMessageTextDraftActionTypeID: "sendMessageTextDraftAction#3630b85a", + InputSendMessageRichMessageDraftActionTypeID: "inputSendMessageRichMessageDraftAction#a937c7be", + SendMessageRichMessageDraftActionTypeID: "sendMessageRichMessageDraftAction#52564893", + SendMessageStopDraftActionTypeID: "sendMessageStopDraftAction#fbf902b0", ContactsFoundTypeID: "contacts.found#b3134d9d", InputPrivacyKeyStatusTimestampTypeID: "inputPrivacyKeyStatusTimestamp#4f96cb18", InputPrivacyKeyChatInviteTypeID: "inputPrivacyKeyChatInvite#bdfb0426", @@ -641,29 +644,12 @@ func TypesMap() map[uint32]string { MessagesStickerSetNotModifiedTypeID: "messages.stickerSetNotModified#d3f924eb", BotCommandTypeID: "botCommand#9852d6d2", BotInfoTypeID: "botInfo#4d8a0299", - KeyboardButtonTypeID: "keyboardButton#7d170cff", - KeyboardButtonURLTypeID: "keyboardButtonUrl#d80c25ec", - KeyboardButtonCallbackTypeID: "keyboardButtonCallback#e62bc960", - KeyboardButtonRequestPhoneTypeID: "keyboardButtonRequestPhone#417efd8f", - KeyboardButtonRequestGeoLocationTypeID: "keyboardButtonRequestGeoLocation#aa40f94d", - KeyboardButtonSwitchInlineTypeID: "keyboardButtonSwitchInline#991399fc", - KeyboardButtonGameTypeID: "keyboardButtonGame#89c590f9", - KeyboardButtonBuyTypeID: "keyboardButtonBuy#3fa53905", - KeyboardButtonURLAuthTypeID: "keyboardButtonUrlAuth#f51006f9", - InputKeyboardButtonURLAuthTypeID: "inputKeyboardButtonUrlAuth#68013e72", - KeyboardButtonRequestPollTypeID: "keyboardButtonRequestPoll#7a11d782", - InputKeyboardButtonUserProfileTypeID: "inputKeyboardButtonUserProfile#7d5e07c7", - KeyboardButtonUserProfileTypeID: "keyboardButtonUserProfile#c0fd5d09", - KeyboardButtonWebViewTypeID: "keyboardButtonWebView#e846b1a0", - KeyboardButtonSimpleWebViewTypeID: "keyboardButtonSimpleWebView#e15c4370", - KeyboardButtonRequestPeerTypeID: "keyboardButtonRequestPeer#5b0f15f5", - InputKeyboardButtonRequestPeerTypeID: "inputKeyboardButtonRequestPeer#2b78156", - KeyboardButtonCopyTypeID: "keyboardButtonCopy#bcc4af10", + KeyboardButtonTypeID: "keyboardButton#2f67a72f", KeyboardButtonRowTypeID: "keyboardButtonRow#77608b83", ReplyKeyboardHideTypeID: "replyKeyboardHide#a03e5b85", ReplyKeyboardForceReplyTypeID: "replyKeyboardForceReply#86b40b08", ReplyKeyboardMarkupTypeID: "replyKeyboardMarkup#85dd99d1", - ReplyInlineMarkupTypeID: "replyInlineMarkup#48a30254", + ReplyInlineMarkupTypeID: "replyInlineMarkup#b2b15770", MessageEntityUnknownTypeID: "messageEntityUnknown#bb92ba95", MessageEntityMentionTypeID: "messageEntityMention#fa04579d", MessageEntityHashtagTypeID: "messageEntityHashtag#6f635b0d", @@ -833,6 +819,7 @@ func TypesMap() map[uint32]string { TextMentionNameTypeID: "textMentionName#1a9fbfc", TextDateTypeID: "textDate#a5b45e2b", TextDiffTypeID: "textDiff#9686cb50", + TextButtonTypeID: "textButton#afc79cd6", PageBlockUnsupportedTypeID: "pageBlockUnsupported#13567e8a", PageBlockTitleTypeID: "pageBlockTitle#70abc3fd", PageBlockSubtitleTypeID: "pageBlockSubtitle#8ffa9a1f", @@ -845,7 +832,7 @@ func TypesMap() map[uint32]string { PageBlockDividerTypeID: "pageBlockDivider#db20b188", PageBlockAnchorTypeID: "pageBlockAnchor#ce0d37b0", PageBlockListTypeID: "pageBlockList#e4e88011", - PageBlockBlockquoteTypeID: "pageBlockBlockquote#263d7c26", + PageBlockBlockquoteTypeID: "pageBlockBlockquote#66d1670b", PageBlockPullquoteTypeID: "pageBlockPullquote#4f4456d3", PageBlockPhotoTypeID: "pageBlockPhoto#1759c560", PageBlockVideoTypeID: "pageBlockVideo#7c8fe7b6", @@ -872,6 +859,8 @@ func TypesMap() map[uint32]string { PageBlockThinkingTypeID: "pageBlockThinking#3c29a3e2", InputPageBlockMapTypeID: "inputPageBlockMap#574b617f", PageBlockBlockquoteBlocksTypeID: "pageBlockBlockquoteBlocks#e6e47c4", + PageBlockButtonRowTypeID: "pageBlockButtonRow#6d640318", + PageBlockDocumentTypeID: "pageBlockDocument#38fa3ba3", PhoneCallDiscardReasonMissedTypeID: "phoneCallDiscardReasonMissed#85e42301", PhoneCallDiscardReasonDisconnectTypeID: "phoneCallDiscardReasonDisconnect#e095c1a0", PhoneCallDiscardReasonHangupTypeID: "phoneCallDiscardReasonHangup#57adc690", @@ -1275,7 +1264,7 @@ func TypesMap() map[uint32]string { InputInvoiceStarGiftTransferTypeID: "inputInvoiceStarGiftTransfer#4a5f5bd9", InputInvoicePremiumGiftStarsTypeID: "inputInvoicePremiumGiftStars#dabab2ef", InputInvoiceBusinessBotTransferStarsTypeID: "inputInvoiceBusinessBotTransferStars#f4997e42", - InputInvoiceStarGiftResaleTypeID: "inputInvoiceStarGiftResale#c39f5324", + InputInvoiceStarGiftResaleTypeID: "inputInvoiceStarGiftResale#e9b0c658", InputInvoiceStarGiftPrepaidUpgradeTypeID: "inputInvoiceStarGiftPrepaidUpgrade#9a0b48b8", InputInvoicePremiumAuthCodeTypeID: "inputInvoicePremiumAuthCode#3e77f614", InputInvoiceStarGiftDropOriginalDetailsTypeID: "inputInvoiceStarGiftDropOriginalDetails#923d8d1", @@ -1675,10 +1664,36 @@ func TypesMap() map[uint32]string { CommunityPeerTypeID: "communityPeer#76141ebd", CommunityPeerRequestTypeID: "communityPeerRequest#7beafa85", CommunitiesPeerLinkRequestsTypeID: "communities.peerLinkRequests#2244afad", - EphemeralMessageTypeID: "ephemeralMessage#d9c6dc1a", + EphemeralMessageTypeID: "ephemeralMessage#dd27bee9", CommunitiesParticipantJoinedChatsTypeID: "communities.participantJoinedChats#8d78512a", MessagesTranslatedRichMessageTypeID: "messages.translatedRichMessage#4203998f", MessagesComposedRichMessageWithAITypeID: "messages.composedRichMessageWithAI#4c4537c8", + ButtonTypeDefaultTypeID: "buttonTypeDefault#c9dd90e9", + ButtonTypeRequestPhoneTypeID: "buttonTypeRequestPhone#df3d36f9", + ButtonTypeRequestGeoLocationTypeID: "buttonTypeRequestGeoLocation#9beee140", + ButtonTypeRequestPollTypeID: "buttonTypeRequestPoll#aacfff84", + ButtonTypeRequestPeerTypeID: "buttonTypeRequestPeer#4f58a237", + InputButtonTypeRequestPeerTypeID: "inputButtonTypeRequestPeer#3fe268fe", + ButtonTypeSimpleWebViewTypeID: "buttonTypeSimpleWebView#c01a597a", + InlineButtonTypeURLTypeID: "inlineButtonTypeUrl#eca4f8d4", + InlineButtonTypeURLAuthTypeID: "inlineButtonTypeUrlAuth#bfd02da2", + InputInlineButtonTypeURLAuthTypeID: "inputInlineButtonTypeUrlAuth#9961bcb4", + InlineButtonTypeWebViewTypeID: "inlineButtonTypeWebView#3bcab5b4", + InlineButtonTypeCallbackTypeID: "inlineButtonTypeCallback#2955bc38", + InlineButtonTypeGameTypeID: "inlineButtonTypeGame#5cd3709d", + InlineButtonTypeBuyTypeID: "inlineButtonTypeBuy#48bad7a5", + InlineButtonTypeSwitchInlineTypeID: "inlineButtonTypeSwitchInline#93773ff5", + InlineButtonTypeUserProfileTypeID: "inlineButtonTypeUserProfile#3fa33fcf", + InputInlineButtonTypeUserProfileTypeID: "inputInlineButtonTypeUserProfile#53f3ce5a", + InlineButtonTypeCopyTypeID: "inlineButtonTypeCopy#b41d3272", + InlineButtonTypeDisabledTypeID: "inlineButtonTypeDisabled#a438619d", + KeyboardInlineButtonTypeID: "keyboardInlineButton#11c1a322", + KeyboardInlineButtonRowTypeID: "keyboardInlineButtonRow#19420af6", + RichButtonStyleTypeID: "richButtonStyle#3c610bd", + PageButtonTypeID: "pageButton#692a5488", + EphemeralWelcomeMessagesNotModifiedTypeID: "ephemeral.welcomeMessagesNotModified#59ffdb31", + EphemeralWelcomeMessagesTypeID: "ephemeral.welcomeMessages#104fc872", + AuthFirebasePnvIntentTypeID: "auth.firebasePnvIntent#df5ac00c", InvokeAfterMsgRequestTypeID: "invokeAfterMsg#cb9f372d", InvokeAfterMsgsRequestTypeID: "invokeAfterMsgs#3dc4b4f0", InitConnectionRequestTypeID: "initConnection#c1cd5ea9", @@ -1716,6 +1731,9 @@ func TypesMap() map[uint32]string { AuthCheckPaidAuthRequestTypeID: "auth.checkPaidAuth#56e59f9c", AuthInitPasskeyLoginRequestTypeID: "auth.initPasskeyLogin#518ad0b7", AuthFinishPasskeyLoginRequestTypeID: "auth.finishPasskeyLogin#9857ad07", + AuthInitFirebasePnvLoginRequestTypeID: "auth.initFirebasePnvLogin#777df37a", + AuthFinishFirebasePnvLoginRequestTypeID: "auth.finishFirebasePnvLogin#2c85094c", + AuthFirebasePnvSignUpRequestTypeID: "auth.firebasePnvSignUp#783f6b56", AccountRegisterDeviceRequestTypeID: "account.registerDevice#ec86017a", AccountUnregisterDeviceRequestTypeID: "account.unregisterDevice#6a0d3206", AccountUpdateNotifySettingsRequestTypeID: "account.updateNotifySettings#84be5b93", @@ -2481,10 +2499,14 @@ func TypesMap() map[uint32]string { CommunitiesToggleAllPeerLinkRequestApprovalRequestTypeID: "communities.toggleAllPeerLinkRequestApproval#bfe3dd3d", CommunitiesToggleParticipantBannedRequestTypeID: "communities.toggleParticipantBanned#9967ad0f", CommunitiesGetParticipantJoinedChatsRequestTypeID: "communities.getParticipantJoinedChats#f87eabab", - EphemeralSendMessageRequestTypeID: "ephemeral.sendMessage#68cbd09f", - EphemeralDeleteMessageRequestTypeID: "ephemeral.deleteMessage#a3c0d511", + EphemeralSendMessageRequestTypeID: "ephemeral.sendMessage#ba8d5f35", + EphemeralDeleteMessageRequestTypeID: "ephemeral.deleteMessage#92f6e797", EphemeralReportMessageRequestTypeID: "ephemeral.reportMessage#8704f2bf", EphemeralGetCallbackAnswerRequestTypeID: "ephemeral.getCallbackAnswer#3fa464c8", + EphemeralEditMessageRequestTypeID: "ephemeral.editMessage#cf9c725b", + EphemeralDeleteWelcomeMessageRequestTypeID: "ephemeral.deleteWelcomeMessage#e882a9e1", + EphemeralDeleteAllWelcomeMessagesRequestTypeID: "ephemeral.deleteAllWelcomeMessages#734f9721", + EphemeralGetWelcomeMessagesRequestTypeID: "ephemeral.getWelcomeMessages#db9ac18d", IntTypeID: "int#a8509bda", LongTypeID: "long#22076cba", DoubleTypeID: "double#2210c154", @@ -2691,6 +2713,7 @@ func NamesMap() map[string]uint32 { "messageActionPollDeleteAnswer": MessageActionPollDeleteAnswerTypeID, "messageActionManagedBotCreated": MessageActionManagedBotCreatedTypeID, "messageActionChangeCommunity": MessageActionChangeCommunityTypeID, + "messageActionChatJoinedViaCommunity": MessageActionChatJoinedViaCommunityTypeID, "dialog": DialogTypeID, "dialogFolder": DialogFolderTypeID, "dialogCommunity": DialogCommunityTypeID, @@ -2932,6 +2955,7 @@ func NamesMap() map[string]uint32 { "updateNewEphemeralMessage": UpdateNewEphemeralMessageTypeID, "updateDeleteEphemeralMessages": UpdateDeleteEphemeralMessagesTypeID, "updateEditEphemeralMessage": UpdateEditEphemeralMessageTypeID, + "updateEphemeralBotCallbackQuery": UpdateEphemeralBotCallbackQueryTypeID, "updateBotStarsSubscription": UpdateBotStarsSubscriptionTypeID, "updates.state": UpdatesStateTypeID, "updates.differenceEmpty": UpdatesDifferenceEmptyTypeID, @@ -3006,6 +3030,7 @@ func NamesMap() map[string]uint32 { "sendMessageTextDraftAction": SendMessageTextDraftActionTypeID, "inputSendMessageRichMessageDraftAction": InputSendMessageRichMessageDraftActionTypeID, "sendMessageRichMessageDraftAction": SendMessageRichMessageDraftActionTypeID, + "sendMessageStopDraftAction": SendMessageStopDraftActionTypeID, "contacts.found": ContactsFoundTypeID, "inputPrivacyKeyStatusTimestamp": InputPrivacyKeyStatusTimestampTypeID, "inputPrivacyKeyChatInvite": InputPrivacyKeyChatInviteTypeID, @@ -3109,23 +3134,6 @@ func NamesMap() map[string]uint32 { "botCommand": BotCommandTypeID, "botInfo": BotInfoTypeID, "keyboardButton": KeyboardButtonTypeID, - "keyboardButtonUrl": KeyboardButtonURLTypeID, - "keyboardButtonCallback": KeyboardButtonCallbackTypeID, - "keyboardButtonRequestPhone": KeyboardButtonRequestPhoneTypeID, - "keyboardButtonRequestGeoLocation": KeyboardButtonRequestGeoLocationTypeID, - "keyboardButtonSwitchInline": KeyboardButtonSwitchInlineTypeID, - "keyboardButtonGame": KeyboardButtonGameTypeID, - "keyboardButtonBuy": KeyboardButtonBuyTypeID, - "keyboardButtonUrlAuth": KeyboardButtonURLAuthTypeID, - "inputKeyboardButtonUrlAuth": InputKeyboardButtonURLAuthTypeID, - "keyboardButtonRequestPoll": KeyboardButtonRequestPollTypeID, - "inputKeyboardButtonUserProfile": InputKeyboardButtonUserProfileTypeID, - "keyboardButtonUserProfile": KeyboardButtonUserProfileTypeID, - "keyboardButtonWebView": KeyboardButtonWebViewTypeID, - "keyboardButtonSimpleWebView": KeyboardButtonSimpleWebViewTypeID, - "keyboardButtonRequestPeer": KeyboardButtonRequestPeerTypeID, - "inputKeyboardButtonRequestPeer": InputKeyboardButtonRequestPeerTypeID, - "keyboardButtonCopy": KeyboardButtonCopyTypeID, "keyboardButtonRow": KeyboardButtonRowTypeID, "replyKeyboardHide": ReplyKeyboardHideTypeID, "replyKeyboardForceReply": ReplyKeyboardForceReplyTypeID, @@ -3300,6 +3308,7 @@ func NamesMap() map[string]uint32 { "textMentionName": TextMentionNameTypeID, "textDate": TextDateTypeID, "textDiff": TextDiffTypeID, + "textButton": TextButtonTypeID, "pageBlockUnsupported": PageBlockUnsupportedTypeID, "pageBlockTitle": PageBlockTitleTypeID, "pageBlockSubtitle": PageBlockSubtitleTypeID, @@ -3339,6 +3348,8 @@ func NamesMap() map[string]uint32 { "pageBlockThinking": PageBlockThinkingTypeID, "inputPageBlockMap": InputPageBlockMapTypeID, "pageBlockBlockquoteBlocks": PageBlockBlockquoteBlocksTypeID, + "pageBlockButtonRow": PageBlockButtonRowTypeID, + "pageBlockDocument": PageBlockDocumentTypeID, "phoneCallDiscardReasonMissed": PhoneCallDiscardReasonMissedTypeID, "phoneCallDiscardReasonDisconnect": PhoneCallDiscardReasonDisconnectTypeID, "phoneCallDiscardReasonHangup": PhoneCallDiscardReasonHangupTypeID, @@ -4146,6 +4157,32 @@ func NamesMap() map[string]uint32 { "communities.participantJoinedChats": CommunitiesParticipantJoinedChatsTypeID, "messages.translatedRichMessage": MessagesTranslatedRichMessageTypeID, "messages.composedRichMessageWithAI": MessagesComposedRichMessageWithAITypeID, + "buttonTypeDefault": ButtonTypeDefaultTypeID, + "buttonTypeRequestPhone": ButtonTypeRequestPhoneTypeID, + "buttonTypeRequestGeoLocation": ButtonTypeRequestGeoLocationTypeID, + "buttonTypeRequestPoll": ButtonTypeRequestPollTypeID, + "buttonTypeRequestPeer": ButtonTypeRequestPeerTypeID, + "inputButtonTypeRequestPeer": InputButtonTypeRequestPeerTypeID, + "buttonTypeSimpleWebView": ButtonTypeSimpleWebViewTypeID, + "inlineButtonTypeUrl": InlineButtonTypeURLTypeID, + "inlineButtonTypeUrlAuth": InlineButtonTypeURLAuthTypeID, + "inputInlineButtonTypeUrlAuth": InputInlineButtonTypeURLAuthTypeID, + "inlineButtonTypeWebView": InlineButtonTypeWebViewTypeID, + "inlineButtonTypeCallback": InlineButtonTypeCallbackTypeID, + "inlineButtonTypeGame": InlineButtonTypeGameTypeID, + "inlineButtonTypeBuy": InlineButtonTypeBuyTypeID, + "inlineButtonTypeSwitchInline": InlineButtonTypeSwitchInlineTypeID, + "inlineButtonTypeUserProfile": InlineButtonTypeUserProfileTypeID, + "inputInlineButtonTypeUserProfile": InputInlineButtonTypeUserProfileTypeID, + "inlineButtonTypeCopy": InlineButtonTypeCopyTypeID, + "inlineButtonTypeDisabled": InlineButtonTypeDisabledTypeID, + "keyboardInlineButton": KeyboardInlineButtonTypeID, + "keyboardInlineButtonRow": KeyboardInlineButtonRowTypeID, + "richButtonStyle": RichButtonStyleTypeID, + "pageButton": PageButtonTypeID, + "ephemeral.welcomeMessagesNotModified": EphemeralWelcomeMessagesNotModifiedTypeID, + "ephemeral.welcomeMessages": EphemeralWelcomeMessagesTypeID, + "auth.firebasePnvIntent": AuthFirebasePnvIntentTypeID, "invokeAfterMsg": InvokeAfterMsgRequestTypeID, "invokeAfterMsgs": InvokeAfterMsgsRequestTypeID, "initConnection": InitConnectionRequestTypeID, @@ -4183,6 +4220,9 @@ func NamesMap() map[string]uint32 { "auth.checkPaidAuth": AuthCheckPaidAuthRequestTypeID, "auth.initPasskeyLogin": AuthInitPasskeyLoginRequestTypeID, "auth.finishPasskeyLogin": AuthFinishPasskeyLoginRequestTypeID, + "auth.initFirebasePnvLogin": AuthInitFirebasePnvLoginRequestTypeID, + "auth.finishFirebasePnvLogin": AuthFinishFirebasePnvLoginRequestTypeID, + "auth.firebasePnvSignUp": AuthFirebasePnvSignUpRequestTypeID, "account.registerDevice": AccountRegisterDeviceRequestTypeID, "account.unregisterDevice": AccountUnregisterDeviceRequestTypeID, "account.updateNotifySettings": AccountUpdateNotifySettingsRequestTypeID, @@ -4952,6 +4992,10 @@ func NamesMap() map[string]uint32 { "ephemeral.deleteMessage": EphemeralDeleteMessageRequestTypeID, "ephemeral.reportMessage": EphemeralReportMessageRequestTypeID, "ephemeral.getCallbackAnswer": EphemeralGetCallbackAnswerRequestTypeID, + "ephemeral.editMessage": EphemeralEditMessageRequestTypeID, + "ephemeral.deleteWelcomeMessage": EphemeralDeleteWelcomeMessageRequestTypeID, + "ephemeral.deleteAllWelcomeMessages": EphemeralDeleteAllWelcomeMessagesRequestTypeID, + "ephemeral.getWelcomeMessages": EphemeralGetWelcomeMessagesRequestTypeID, "int": IntTypeID, "long": LongTypeID, "double": DoubleTypeID, @@ -5158,6 +5202,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MessageActionPollDeleteAnswerTypeID: func() bin.Object { return &MessageActionPollDeleteAnswer{} }, MessageActionManagedBotCreatedTypeID: func() bin.Object { return &MessageActionManagedBotCreated{} }, MessageActionChangeCommunityTypeID: func() bin.Object { return &MessageActionChangeCommunity{} }, + MessageActionChatJoinedViaCommunityTypeID: func() bin.Object { return &MessageActionChatJoinedViaCommunity{} }, DialogTypeID: func() bin.Object { return &Dialog{} }, DialogFolderTypeID: func() bin.Object { return &DialogFolder{} }, DialogCommunityTypeID: func() bin.Object { return &DialogCommunity{} }, @@ -5399,6 +5444,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { UpdateNewEphemeralMessageTypeID: func() bin.Object { return &UpdateNewEphemeralMessage{} }, UpdateDeleteEphemeralMessagesTypeID: func() bin.Object { return &UpdateDeleteEphemeralMessages{} }, UpdateEditEphemeralMessageTypeID: func() bin.Object { return &UpdateEditEphemeralMessage{} }, + UpdateEphemeralBotCallbackQueryTypeID: func() bin.Object { return &UpdateEphemeralBotCallbackQuery{} }, UpdateBotStarsSubscriptionTypeID: func() bin.Object { return &UpdateBotStarsSubscription{} }, UpdatesStateTypeID: func() bin.Object { return &UpdatesState{} }, UpdatesDifferenceEmptyTypeID: func() bin.Object { return &UpdatesDifferenceEmpty{} }, @@ -5473,6 +5519,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { SendMessageTextDraftActionTypeID: func() bin.Object { return &SendMessageTextDraftAction{} }, InputSendMessageRichMessageDraftActionTypeID: func() bin.Object { return &InputSendMessageRichMessageDraftAction{} }, SendMessageRichMessageDraftActionTypeID: func() bin.Object { return &SendMessageRichMessageDraftAction{} }, + SendMessageStopDraftActionTypeID: func() bin.Object { return &SendMessageStopDraftAction{} }, ContactsFoundTypeID: func() bin.Object { return &ContactsFound{} }, InputPrivacyKeyStatusTimestampTypeID: func() bin.Object { return &InputPrivacyKeyStatusTimestamp{} }, InputPrivacyKeyChatInviteTypeID: func() bin.Object { return &InputPrivacyKeyChatInvite{} }, @@ -5576,23 +5623,6 @@ func TypesConstructorMap() map[uint32]func() bin.Object { BotCommandTypeID: func() bin.Object { return &BotCommand{} }, BotInfoTypeID: func() bin.Object { return &BotInfo{} }, KeyboardButtonTypeID: func() bin.Object { return &KeyboardButton{} }, - KeyboardButtonURLTypeID: func() bin.Object { return &KeyboardButtonURL{} }, - KeyboardButtonCallbackTypeID: func() bin.Object { return &KeyboardButtonCallback{} }, - KeyboardButtonRequestPhoneTypeID: func() bin.Object { return &KeyboardButtonRequestPhone{} }, - KeyboardButtonRequestGeoLocationTypeID: func() bin.Object { return &KeyboardButtonRequestGeoLocation{} }, - KeyboardButtonSwitchInlineTypeID: func() bin.Object { return &KeyboardButtonSwitchInline{} }, - KeyboardButtonGameTypeID: func() bin.Object { return &KeyboardButtonGame{} }, - KeyboardButtonBuyTypeID: func() bin.Object { return &KeyboardButtonBuy{} }, - KeyboardButtonURLAuthTypeID: func() bin.Object { return &KeyboardButtonURLAuth{} }, - InputKeyboardButtonURLAuthTypeID: func() bin.Object { return &InputKeyboardButtonURLAuth{} }, - KeyboardButtonRequestPollTypeID: func() bin.Object { return &KeyboardButtonRequestPoll{} }, - InputKeyboardButtonUserProfileTypeID: func() bin.Object { return &InputKeyboardButtonUserProfile{} }, - KeyboardButtonUserProfileTypeID: func() bin.Object { return &KeyboardButtonUserProfile{} }, - KeyboardButtonWebViewTypeID: func() bin.Object { return &KeyboardButtonWebView{} }, - KeyboardButtonSimpleWebViewTypeID: func() bin.Object { return &KeyboardButtonSimpleWebView{} }, - KeyboardButtonRequestPeerTypeID: func() bin.Object { return &KeyboardButtonRequestPeer{} }, - InputKeyboardButtonRequestPeerTypeID: func() bin.Object { return &InputKeyboardButtonRequestPeer{} }, - KeyboardButtonCopyTypeID: func() bin.Object { return &KeyboardButtonCopy{} }, KeyboardButtonRowTypeID: func() bin.Object { return &KeyboardButtonRow{} }, ReplyKeyboardHideTypeID: func() bin.Object { return &ReplyKeyboardHide{} }, ReplyKeyboardForceReplyTypeID: func() bin.Object { return &ReplyKeyboardForceReply{} }, @@ -5767,6 +5797,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { TextMentionNameTypeID: func() bin.Object { return &TextMentionName{} }, TextDateTypeID: func() bin.Object { return &TextDate{} }, TextDiffTypeID: func() bin.Object { return &TextDiff{} }, + TextButtonTypeID: func() bin.Object { return &TextButton{} }, PageBlockUnsupportedTypeID: func() bin.Object { return &PageBlockUnsupported{} }, PageBlockTitleTypeID: func() bin.Object { return &PageBlockTitle{} }, PageBlockSubtitleTypeID: func() bin.Object { return &PageBlockSubtitle{} }, @@ -5806,6 +5837,8 @@ func TypesConstructorMap() map[uint32]func() bin.Object { PageBlockThinkingTypeID: func() bin.Object { return &PageBlockThinking{} }, InputPageBlockMapTypeID: func() bin.Object { return &InputPageBlockMap{} }, PageBlockBlockquoteBlocksTypeID: func() bin.Object { return &PageBlockBlockquoteBlocks{} }, + PageBlockButtonRowTypeID: func() bin.Object { return &PageBlockButtonRow{} }, + PageBlockDocumentTypeID: func() bin.Object { return &PageBlockDocument{} }, PhoneCallDiscardReasonMissedTypeID: func() bin.Object { return &PhoneCallDiscardReasonMissed{} }, PhoneCallDiscardReasonDisconnectTypeID: func() bin.Object { return &PhoneCallDiscardReasonDisconnect{} }, PhoneCallDiscardReasonHangupTypeID: func() bin.Object { return &PhoneCallDiscardReasonHangup{} }, @@ -6613,6 +6646,32 @@ func TypesConstructorMap() map[uint32]func() bin.Object { CommunitiesParticipantJoinedChatsTypeID: func() bin.Object { return &CommunitiesParticipantJoinedChats{} }, MessagesTranslatedRichMessageTypeID: func() bin.Object { return &MessagesTranslatedRichMessage{} }, MessagesComposedRichMessageWithAITypeID: func() bin.Object { return &MessagesComposedRichMessageWithAI{} }, + ButtonTypeDefaultTypeID: func() bin.Object { return &ButtonTypeDefault{} }, + ButtonTypeRequestPhoneTypeID: func() bin.Object { return &ButtonTypeRequestPhone{} }, + ButtonTypeRequestGeoLocationTypeID: func() bin.Object { return &ButtonTypeRequestGeoLocation{} }, + ButtonTypeRequestPollTypeID: func() bin.Object { return &ButtonTypeRequestPoll{} }, + ButtonTypeRequestPeerTypeID: func() bin.Object { return &ButtonTypeRequestPeer{} }, + InputButtonTypeRequestPeerTypeID: func() bin.Object { return &InputButtonTypeRequestPeer{} }, + ButtonTypeSimpleWebViewTypeID: func() bin.Object { return &ButtonTypeSimpleWebView{} }, + InlineButtonTypeURLTypeID: func() bin.Object { return &InlineButtonTypeURL{} }, + InlineButtonTypeURLAuthTypeID: func() bin.Object { return &InlineButtonTypeURLAuth{} }, + InputInlineButtonTypeURLAuthTypeID: func() bin.Object { return &InputInlineButtonTypeURLAuth{} }, + InlineButtonTypeWebViewTypeID: func() bin.Object { return &InlineButtonTypeWebView{} }, + InlineButtonTypeCallbackTypeID: func() bin.Object { return &InlineButtonTypeCallback{} }, + InlineButtonTypeGameTypeID: func() bin.Object { return &InlineButtonTypeGame{} }, + InlineButtonTypeBuyTypeID: func() bin.Object { return &InlineButtonTypeBuy{} }, + InlineButtonTypeSwitchInlineTypeID: func() bin.Object { return &InlineButtonTypeSwitchInline{} }, + InlineButtonTypeUserProfileTypeID: func() bin.Object { return &InlineButtonTypeUserProfile{} }, + InputInlineButtonTypeUserProfileTypeID: func() bin.Object { return &InputInlineButtonTypeUserProfile{} }, + InlineButtonTypeCopyTypeID: func() bin.Object { return &InlineButtonTypeCopy{} }, + InlineButtonTypeDisabledTypeID: func() bin.Object { return &InlineButtonTypeDisabled{} }, + KeyboardInlineButtonTypeID: func() bin.Object { return &KeyboardInlineButton{} }, + KeyboardInlineButtonRowTypeID: func() bin.Object { return &KeyboardInlineButtonRow{} }, + RichButtonStyleTypeID: func() bin.Object { return &RichButtonStyle{} }, + PageButtonTypeID: func() bin.Object { return &PageButton{} }, + EphemeralWelcomeMessagesNotModifiedTypeID: func() bin.Object { return &EphemeralWelcomeMessagesNotModified{} }, + EphemeralWelcomeMessagesTypeID: func() bin.Object { return &EphemeralWelcomeMessages{} }, + AuthFirebasePnvIntentTypeID: func() bin.Object { return &AuthFirebasePnvIntent{} }, InvokeAfterMsgRequestTypeID: func() bin.Object { return &InvokeAfterMsgRequest{} }, InvokeAfterMsgsRequestTypeID: func() bin.Object { return &InvokeAfterMsgsRequest{} }, InitConnectionRequestTypeID: func() bin.Object { return &InitConnectionRequest{} }, @@ -6650,6 +6709,9 @@ func TypesConstructorMap() map[uint32]func() bin.Object { AuthCheckPaidAuthRequestTypeID: func() bin.Object { return &AuthCheckPaidAuthRequest{} }, AuthInitPasskeyLoginRequestTypeID: func() bin.Object { return &AuthInitPasskeyLoginRequest{} }, AuthFinishPasskeyLoginRequestTypeID: func() bin.Object { return &AuthFinishPasskeyLoginRequest{} }, + AuthInitFirebasePnvLoginRequestTypeID: func() bin.Object { return &AuthInitFirebasePnvLoginRequest{} }, + AuthFinishFirebasePnvLoginRequestTypeID: func() bin.Object { return &AuthFinishFirebasePnvLoginRequest{} }, + AuthFirebasePnvSignUpRequestTypeID: func() bin.Object { return &AuthFirebasePnvSignUpRequest{} }, AccountRegisterDeviceRequestTypeID: func() bin.Object { return &AccountRegisterDeviceRequest{} }, AccountUnregisterDeviceRequestTypeID: func() bin.Object { return &AccountUnregisterDeviceRequest{} }, AccountUpdateNotifySettingsRequestTypeID: func() bin.Object { return &AccountUpdateNotifySettingsRequest{} }, @@ -7419,6 +7481,10 @@ func TypesConstructorMap() map[uint32]func() bin.Object { EphemeralDeleteMessageRequestTypeID: func() bin.Object { return &EphemeralDeleteMessageRequest{} }, EphemeralReportMessageRequestTypeID: func() bin.Object { return &EphemeralReportMessageRequest{} }, EphemeralGetCallbackAnswerRequestTypeID: func() bin.Object { return &EphemeralGetCallbackAnswerRequest{} }, + EphemeralEditMessageRequestTypeID: func() bin.Object { return &EphemeralEditMessageRequest{} }, + EphemeralDeleteWelcomeMessageRequestTypeID: func() bin.Object { return &EphemeralDeleteWelcomeMessageRequest{} }, + EphemeralDeleteAllWelcomeMessagesRequestTypeID: func() bin.Object { return &EphemeralDeleteAllWelcomeMessagesRequest{} }, + EphemeralGetWelcomeMessagesRequestTypeID: func() bin.Object { return &EphemeralGetWelcomeMessagesRequest{} }, IntTypeID: func() bin.Object { return &Int{} }, LongTypeID: func() bin.Object { return &Long{} }, DoubleTypeID: func() bin.Object { return &Double{} }, @@ -7580,6 +7646,15 @@ func ClassConstructorsMap() map[string][]uint32 { BusinessAwayMessageScheduleOutsideWorkHoursTypeID, BusinessAwayMessageScheduleCustomTypeID, }, + ButtonTypeClassName: { + ButtonTypeDefaultTypeID, + ButtonTypeRequestPhoneTypeID, + ButtonTypeRequestGeoLocationTypeID, + ButtonTypeRequestPollTypeID, + ButtonTypeRequestPeerTypeID, + InputButtonTypeRequestPeerTypeID, + ButtonTypeSimpleWebViewTypeID, + }, ChannelAdminLogEventActionClassName: { ChannelAdminLogEventActionChangeTitleTypeID, ChannelAdminLogEventActionChangeAboutTypeID, @@ -7808,6 +7883,10 @@ func ClassConstructorsMap() map[string][]uint32 { EncryptedMessageTypeID, EncryptedMessageServiceTypeID, }, + EphemeralWelcomeMessagesClassName: { + EphemeralWelcomeMessagesNotModifiedTypeID, + EphemeralWelcomeMessagesTypeID, + }, ExportedChatInviteClassName: { ChatInviteExportedTypeID, ChatInvitePublicJoinRequestsTypeID, @@ -7872,6 +7951,20 @@ func ClassConstructorsMap() map[string][]uint32 { IPPortTypeID, IPPortSecretTypeID, }, + InlineButtonTypeClassName: { + InlineButtonTypeURLTypeID, + InlineButtonTypeURLAuthTypeID, + InputInlineButtonTypeURLAuthTypeID, + InlineButtonTypeWebViewTypeID, + InlineButtonTypeCallbackTypeID, + InlineButtonTypeGameTypeID, + InlineButtonTypeBuyTypeID, + InlineButtonTypeSwitchInlineTypeID, + InlineButtonTypeUserProfileTypeID, + InputInlineButtonTypeUserProfileTypeID, + InlineButtonTypeCopyTypeID, + InlineButtonTypeDisabledTypeID, + }, InlineQueryPeerTypeClassName: { InlineQueryPeerTypeSameBotPMTypeID, InlineQueryPeerTypePMTypeID, @@ -8185,26 +8278,6 @@ func ClassConstructorsMap() map[string][]uint32 { JoinChatBotResultQueuedTypeID, JoinChatBotResultWebViewTypeID, }, - KeyboardButtonClassName: { - KeyboardButtonTypeID, - KeyboardButtonURLTypeID, - KeyboardButtonCallbackTypeID, - KeyboardButtonRequestPhoneTypeID, - KeyboardButtonRequestGeoLocationTypeID, - KeyboardButtonSwitchInlineTypeID, - KeyboardButtonGameTypeID, - KeyboardButtonBuyTypeID, - KeyboardButtonURLAuthTypeID, - InputKeyboardButtonURLAuthTypeID, - KeyboardButtonRequestPollTypeID, - InputKeyboardButtonUserProfileTypeID, - KeyboardButtonUserProfileTypeID, - KeyboardButtonWebViewTypeID, - KeyboardButtonSimpleWebViewTypeID, - KeyboardButtonRequestPeerTypeID, - InputKeyboardButtonRequestPeerTypeID, - KeyboardButtonCopyTypeID, - }, LangPackStringClassName: { LangPackStringTypeID, LangPackStringPluralizedTypeID, @@ -8290,6 +8363,7 @@ func ClassConstructorsMap() map[string][]uint32 { MessageActionPollDeleteAnswerTypeID, MessageActionManagedBotCreatedTypeID, MessageActionChangeCommunityTypeID, + MessageActionChatJoinedViaCommunityTypeID, }, MessageClassName: { MessageEmptyTypeID, @@ -8539,6 +8613,8 @@ func ClassConstructorsMap() map[string][]uint32 { PageBlockThinkingTypeID, InputPageBlockMapTypeID, PageBlockBlockquoteBlocksTypeID, + PageBlockButtonRowTypeID, + PageBlockDocumentTypeID, }, PageListItemClassName: { PageListItemTextTypeID, @@ -8782,6 +8858,7 @@ func ClassConstructorsMap() map[string][]uint32 { TextMentionNameTypeID, TextDateTypeID, TextDiffTypeID, + TextButtonTypeID, }, SavedDialogClassName: { SavedDialogTypeID, @@ -8852,6 +8929,7 @@ func ClassConstructorsMap() map[string][]uint32 { SendMessageTextDraftActionTypeID, InputSendMessageRichMessageDraftActionTypeID, SendMessageRichMessageDraftActionTypeID, + SendMessageStopDraftActionTypeID, }, StarGiftAttributeClassName: { StarGiftAttributeModelTypeID, @@ -9125,6 +9203,7 @@ func ClassConstructorsMap() map[string][]uint32 { UpdateNewEphemeralMessageTypeID, UpdateDeleteEphemeralMessagesTypeID, UpdateEditEphemeralMessageTypeID, + UpdateEphemeralBotCallbackQueryTypeID, UpdateBotStarsSubscriptionTypeID, }, UpdatesChannelDifferenceClassName: { diff --git a/tg/tl_reply_markup_gen.go b/tg/tl_reply_markup_gen.go index 52f5798537..dc473a4d38 100644 --- a/tg/tl_reply_markup_gen.go +++ b/tg/tl_reply_markup_gen.go @@ -482,6 +482,8 @@ type ReplyKeyboardMarkup struct { Selective bool // Requests clients to always show the keyboard when the regular keyboard is hidden. Persistent bool + // ForceReply field of ReplyKeyboardMarkup. + ForceReply bool // Button row Rows []KeyboardButtonRow // The placeholder to be shown in the input field when the keyboard is active; 1-64 @@ -526,6 +528,9 @@ func (r *ReplyKeyboardMarkup) Zero() bool { if !(r.Persistent == false) { return false } + if !(r.ForceReply == false) { + return false + } if !(r.Rows == nil) { return false } @@ -551,6 +556,7 @@ func (r *ReplyKeyboardMarkup) FillFrom(from interface { GetSingleUse() (value bool) GetSelective() (value bool) GetPersistent() (value bool) + GetForceReply() (value bool) GetRows() (value []KeyboardButtonRow) GetPlaceholder() (value string, ok bool) }) { @@ -558,6 +564,7 @@ func (r *ReplyKeyboardMarkup) FillFrom(from interface { r.SingleUse = from.GetSingleUse() r.Selective = from.GetSelective() r.Persistent = from.GetPersistent() + r.ForceReply = from.GetForceReply() r.Rows = from.GetRows() if val, ok := from.GetPlaceholder(); ok { r.Placeholder = val @@ -608,6 +615,11 @@ func (r *ReplyKeyboardMarkup) TypeInfo() tdp.Type { SchemaName: "persistent", Null: !r.Flags.Has(4), }, + { + Name: "ForceReply", + SchemaName: "force_reply", + Null: !r.Flags.Has(5), + }, { Name: "Rows", SchemaName: "rows", @@ -635,6 +647,9 @@ func (r *ReplyKeyboardMarkup) SetFlags() { if !(r.Persistent == false) { r.Flags.Set(4) } + if !(r.ForceReply == false) { + r.Flags.Set(5) + } if !(r.Placeholder == "") { r.Flags.Set(3) } @@ -695,6 +710,7 @@ func (r *ReplyKeyboardMarkup) DecodeBare(b *bin.Buffer) error { r.SingleUse = r.Flags.Has(1) r.Selective = r.Flags.Has(2) r.Persistent = r.Flags.Has(4) + r.ForceReply = r.Flags.Has(5) { headerLen, err := b.VectorHeader() if err != nil { @@ -798,6 +814,25 @@ func (r *ReplyKeyboardMarkup) GetPersistent() (value bool) { return r.Flags.Has(4) } +// SetForceReply sets value of ForceReply conditional field. +func (r *ReplyKeyboardMarkup) SetForceReply(value bool) { + if value { + r.Flags.Set(5) + r.ForceReply = true + } else { + r.Flags.Unset(5) + r.ForceReply = false + } +} + +// GetForceReply returns value of ForceReply conditional field. +func (r *ReplyKeyboardMarkup) GetForceReply() (value bool) { + if r == nil { + return + } + return r.Flags.Has(5) +} + // GetRows returns value of Rows field. func (r *ReplyKeyboardMarkup) GetRows() (value []KeyboardButtonRow) { if r == nil { @@ -824,17 +859,21 @@ func (r *ReplyKeyboardMarkup) GetPlaceholder() (value string, ok bool) { return r.Placeholder, true } -// ReplyInlineMarkup represents TL type `replyInlineMarkup#48a30254`. +// ReplyInlineMarkup represents TL type `replyInlineMarkup#b2b15770`. // Bot or inline keyboard // // See https://core.telegram.org/constructor/replyInlineMarkup for reference. type ReplyInlineMarkup struct { + // Flags field of ReplyInlineMarkup. + Flags bin.Fields + // ForceReply field of ReplyInlineMarkup. + ForceReply bool // Bot or inline keyboard rows - Rows []KeyboardButtonRow + Rows []KeyboardInlineButtonRow } // ReplyInlineMarkupTypeID is TL type id of ReplyInlineMarkup. -const ReplyInlineMarkupTypeID = 0x48a30254 +const ReplyInlineMarkupTypeID = 0xb2b15770 // construct implements constructor of ReplyMarkupClass. func (r ReplyInlineMarkup) construct() ReplyMarkupClass { return &r } @@ -853,6 +892,12 @@ func (r *ReplyInlineMarkup) Zero() bool { if r == nil { return true } + if !(r.Flags.Zero()) { + return false + } + if !(r.ForceReply == false) { + return false + } if !(r.Rows == nil) { return false } @@ -871,8 +916,10 @@ func (r *ReplyInlineMarkup) String() string { // FillFrom fills ReplyInlineMarkup from given interface. func (r *ReplyInlineMarkup) FillFrom(from interface { - GetRows() (value []KeyboardButtonRow) + GetForceReply() (value bool) + GetRows() (value []KeyboardInlineButtonRow) }) { + r.ForceReply = from.GetForceReply() r.Rows = from.GetRows() } @@ -899,6 +946,11 @@ func (r *ReplyInlineMarkup) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "ForceReply", + SchemaName: "force_reply", + Null: !r.Flags.Has(5), + }, { Name: "Rows", SchemaName: "rows", @@ -907,10 +959,17 @@ func (r *ReplyInlineMarkup) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (r *ReplyInlineMarkup) SetFlags() { + if !(r.ForceReply == false) { + r.Flags.Set(5) + } +} + // Encode implements bin.Encoder. func (r *ReplyInlineMarkup) Encode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode replyInlineMarkup#48a30254 as nil") + return fmt.Errorf("can't encode replyInlineMarkup#b2b15770 as nil") } b.PutID(ReplyInlineMarkupTypeID) return r.EncodeBare(b) @@ -919,12 +978,16 @@ func (r *ReplyInlineMarkup) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (r *ReplyInlineMarkup) EncodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't encode replyInlineMarkup#48a30254 as nil") + return fmt.Errorf("can't encode replyInlineMarkup#b2b15770 as nil") + } + r.SetFlags() + if err := r.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode replyInlineMarkup#b2b15770: field flags: %w", err) } b.PutVectorHeader(len(r.Rows)) for idx, v := range r.Rows { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode replyInlineMarkup#48a30254: field rows element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode replyInlineMarkup#b2b15770: field rows element with index %d: %w", idx, err) } } return nil @@ -933,10 +996,10 @@ func (r *ReplyInlineMarkup) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (r *ReplyInlineMarkup) Decode(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode replyInlineMarkup#48a30254 to nil") + return fmt.Errorf("can't decode replyInlineMarkup#b2b15770 to nil") } if err := b.ConsumeID(ReplyInlineMarkupTypeID); err != nil { - return fmt.Errorf("unable to decode replyInlineMarkup#48a30254: %w", err) + return fmt.Errorf("unable to decode replyInlineMarkup#b2b15770: %w", err) } return r.DecodeBare(b) } @@ -944,21 +1007,27 @@ func (r *ReplyInlineMarkup) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (r *ReplyInlineMarkup) DecodeBare(b *bin.Buffer) error { if r == nil { - return fmt.Errorf("can't decode replyInlineMarkup#48a30254 to nil") + return fmt.Errorf("can't decode replyInlineMarkup#b2b15770 to nil") + } + { + if err := r.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode replyInlineMarkup#b2b15770: field flags: %w", err) + } } + r.ForceReply = r.Flags.Has(5) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode replyInlineMarkup#48a30254: field rows: %w", err) + return fmt.Errorf("unable to decode replyInlineMarkup#b2b15770: field rows: %w", err) } if headerLen > 0 { - r.Rows = make([]KeyboardButtonRow, 0, headerLen%bin.PreallocateLimit) + r.Rows = make([]KeyboardInlineButtonRow, 0, headerLen%bin.PreallocateLimit) } for idx := 0; idx < headerLen; idx++ { - var value KeyboardButtonRow + var value KeyboardInlineButtonRow if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode replyInlineMarkup#48a30254: field rows: %w", err) + return fmt.Errorf("unable to decode replyInlineMarkup#b2b15770: field rows: %w", err) } r.Rows = append(r.Rows, value) } @@ -966,8 +1035,27 @@ func (r *ReplyInlineMarkup) DecodeBare(b *bin.Buffer) error { return nil } +// SetForceReply sets value of ForceReply conditional field. +func (r *ReplyInlineMarkup) SetForceReply(value bool) { + if value { + r.Flags.Set(5) + r.ForceReply = true + } else { + r.Flags.Unset(5) + r.ForceReply = false + } +} + +// GetForceReply returns value of ForceReply conditional field. +func (r *ReplyInlineMarkup) GetForceReply() (value bool) { + if r == nil { + return + } + return r.Flags.Has(5) +} + // GetRows returns value of Rows field. -func (r *ReplyInlineMarkup) GetRows() (value []KeyboardButtonRow) { +func (r *ReplyInlineMarkup) GetRows() (value []KeyboardInlineButtonRow) { if r == nil { return } @@ -997,7 +1085,7 @@ const ReplyMarkupClassName = "ReplyMarkup" // case *tg.ReplyKeyboardHide: // replyKeyboardHide#a03e5b85 // case *tg.ReplyKeyboardForceReply: // replyKeyboardForceReply#86b40b08 // case *tg.ReplyKeyboardMarkup: // replyKeyboardMarkup#85dd99d1 -// case *tg.ReplyInlineMarkup: // replyInlineMarkup#48a30254 +// case *tg.ReplyInlineMarkup: // replyInlineMarkup#b2b15770 // default: panic(v) // } type ReplyMarkupClass interface { @@ -1048,7 +1136,7 @@ func DecodeReplyMarkup(buf *bin.Buffer) (ReplyMarkupClass, error) { } return &v, nil case ReplyInlineMarkupTypeID: - // Decoding replyInlineMarkup#48a30254. + // Decoding replyInlineMarkup#b2b15770. v := ReplyInlineMarkup{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode ReplyMarkupClass: %w", err) diff --git a/tg/tl_rich_button_style_gen.go b/tg/tl_rich_button_style_gen.go new file mode 100644 index 0000000000..53f21868a6 --- /dev/null +++ b/tg/tl_rich_button_style_gen.go @@ -0,0 +1,292 @@ +// 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{} +) + +// RichButtonStyle represents TL type `richButtonStyle#3c610bd`. +// +// See https://core.telegram.org/constructor/richButtonStyle for reference. +type RichButtonStyle struct { + // Flags field of RichButtonStyle. + Flags bin.Fields + // BgPrimary field of RichButtonStyle. + BgPrimary bool + // BgDanger field of RichButtonStyle. + BgDanger bool + // BgSuccess field of RichButtonStyle. + BgSuccess bool + // Link field of RichButtonStyle. + Link bool +} + +// RichButtonStyleTypeID is TL type id of RichButtonStyle. +const RichButtonStyleTypeID = 0x3c610bd + +// Ensuring interfaces in compile-time for RichButtonStyle. +var ( + _ bin.Encoder = &RichButtonStyle{} + _ bin.Decoder = &RichButtonStyle{} + _ bin.BareEncoder = &RichButtonStyle{} + _ bin.BareDecoder = &RichButtonStyle{} +) + +func (r *RichButtonStyle) Zero() bool { + if r == nil { + return true + } + if !(r.Flags.Zero()) { + return false + } + if !(r.BgPrimary == false) { + return false + } + if !(r.BgDanger == false) { + return false + } + if !(r.BgSuccess == false) { + return false + } + if !(r.Link == false) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (r *RichButtonStyle) String() string { + if r == nil { + return "RichButtonStyle(nil)" + } + type Alias RichButtonStyle + return fmt.Sprintf("RichButtonStyle%+v", Alias(*r)) +} + +// FillFrom fills RichButtonStyle from given interface. +func (r *RichButtonStyle) FillFrom(from interface { + GetBgPrimary() (value bool) + GetBgDanger() (value bool) + GetBgSuccess() (value bool) + GetLink() (value bool) +}) { + r.BgPrimary = from.GetBgPrimary() + r.BgDanger = from.GetBgDanger() + r.BgSuccess = from.GetBgSuccess() + r.Link = from.GetLink() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*RichButtonStyle) TypeID() uint32 { + return RichButtonStyleTypeID +} + +// TypeName returns name of type in TL schema. +func (*RichButtonStyle) TypeName() string { + return "richButtonStyle" +} + +// TypeInfo returns info about TL type. +func (r *RichButtonStyle) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "richButtonStyle", + ID: RichButtonStyleTypeID, + } + if r == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "BgPrimary", + SchemaName: "bg_primary", + Null: !r.Flags.Has(0), + }, + { + Name: "BgDanger", + SchemaName: "bg_danger", + Null: !r.Flags.Has(1), + }, + { + Name: "BgSuccess", + SchemaName: "bg_success", + Null: !r.Flags.Has(2), + }, + { + Name: "Link", + SchemaName: "link", + Null: !r.Flags.Has(3), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (r *RichButtonStyle) SetFlags() { + if !(r.BgPrimary == false) { + r.Flags.Set(0) + } + if !(r.BgDanger == false) { + r.Flags.Set(1) + } + if !(r.BgSuccess == false) { + r.Flags.Set(2) + } + if !(r.Link == false) { + r.Flags.Set(3) + } +} + +// Encode implements bin.Encoder. +func (r *RichButtonStyle) Encode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode richButtonStyle#3c610bd as nil") + } + b.PutID(RichButtonStyleTypeID) + return r.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (r *RichButtonStyle) EncodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode richButtonStyle#3c610bd as nil") + } + r.SetFlags() + if err := r.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode richButtonStyle#3c610bd: field flags: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (r *RichButtonStyle) Decode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode richButtonStyle#3c610bd to nil") + } + if err := b.ConsumeID(RichButtonStyleTypeID); err != nil { + return fmt.Errorf("unable to decode richButtonStyle#3c610bd: %w", err) + } + return r.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (r *RichButtonStyle) DecodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode richButtonStyle#3c610bd to nil") + } + { + if err := r.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode richButtonStyle#3c610bd: field flags: %w", err) + } + } + r.BgPrimary = r.Flags.Has(0) + r.BgDanger = r.Flags.Has(1) + r.BgSuccess = r.Flags.Has(2) + r.Link = r.Flags.Has(3) + return nil +} + +// SetBgPrimary sets value of BgPrimary conditional field. +func (r *RichButtonStyle) SetBgPrimary(value bool) { + if value { + r.Flags.Set(0) + r.BgPrimary = true + } else { + r.Flags.Unset(0) + r.BgPrimary = false + } +} + +// GetBgPrimary returns value of BgPrimary conditional field. +func (r *RichButtonStyle) GetBgPrimary() (value bool) { + if r == nil { + return + } + return r.Flags.Has(0) +} + +// SetBgDanger sets value of BgDanger conditional field. +func (r *RichButtonStyle) SetBgDanger(value bool) { + if value { + r.Flags.Set(1) + r.BgDanger = true + } else { + r.Flags.Unset(1) + r.BgDanger = false + } +} + +// GetBgDanger returns value of BgDanger conditional field. +func (r *RichButtonStyle) GetBgDanger() (value bool) { + if r == nil { + return + } + return r.Flags.Has(1) +} + +// SetBgSuccess sets value of BgSuccess conditional field. +func (r *RichButtonStyle) SetBgSuccess(value bool) { + if value { + r.Flags.Set(2) + r.BgSuccess = true + } else { + r.Flags.Unset(2) + r.BgSuccess = false + } +} + +// GetBgSuccess returns value of BgSuccess conditional field. +func (r *RichButtonStyle) GetBgSuccess() (value bool) { + if r == nil { + return + } + return r.Flags.Has(2) +} + +// SetLink sets value of Link conditional field. +func (r *RichButtonStyle) SetLink(value bool) { + if value { + r.Flags.Set(3) + r.Link = true + } else { + r.Flags.Unset(3) + r.Link = false + } +} + +// GetLink returns value of Link conditional field. +func (r *RichButtonStyle) GetLink() (value bool) { + if r == nil { + return + } + return r.Flags.Has(3) +} diff --git a/tg/tl_rich_button_style_slices_gen.go b/tg/tl_rich_button_style_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_rich_button_style_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_rich_text_gen.go b/tg/tl_rich_text_gen.go index 8d02274882..fca9ee166f 100644 --- a/tg/tl_rich_text_gen.go +++ b/tg/tl_rich_text_gen.go @@ -4707,6 +4707,243 @@ func (t *TextDiff) GetOldText() (value RichTextClass) { return t.OldText } +// TextButton represents TL type `textButton#afc79cd6`. +// +// See https://core.telegram.org/constructor/textButton for reference. +type TextButton struct { + // Flags field of TextButton. + Flags bin.Fields + // Text field of TextButton. + Text RichTextClass + // Type field of TextButton. + Type InlineButtonTypeClass + // Style field of TextButton. + // + // Use SetStyle and GetStyle helpers. + Style RichButtonStyle +} + +// TextButtonTypeID is TL type id of TextButton. +const TextButtonTypeID = 0xafc79cd6 + +// construct implements constructor of RichTextClass. +func (t TextButton) construct() RichTextClass { return &t } + +// Ensuring interfaces in compile-time for TextButton. +var ( + _ bin.Encoder = &TextButton{} + _ bin.Decoder = &TextButton{} + _ bin.BareEncoder = &TextButton{} + _ bin.BareDecoder = &TextButton{} + + _ RichTextClass = &TextButton{} +) + +func (t *TextButton) Zero() bool { + if t == nil { + return true + } + if !(t.Flags.Zero()) { + return false + } + if !(t.Text == nil) { + return false + } + if !(t.Type == nil) { + return false + } + if !(t.Style.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (t *TextButton) String() string { + if t == nil { + return "TextButton(nil)" + } + type Alias TextButton + return fmt.Sprintf("TextButton%+v", Alias(*t)) +} + +// FillFrom fills TextButton from given interface. +func (t *TextButton) FillFrom(from interface { + GetText() (value RichTextClass) + GetType() (value InlineButtonTypeClass) + GetStyle() (value RichButtonStyle, ok bool) +}) { + t.Text = from.GetText() + t.Type = from.GetType() + if val, ok := from.GetStyle(); ok { + t.Style = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*TextButton) TypeID() uint32 { + return TextButtonTypeID +} + +// TypeName returns name of type in TL schema. +func (*TextButton) TypeName() string { + return "textButton" +} + +// TypeInfo returns info about TL type. +func (t *TextButton) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "textButton", + ID: TextButtonTypeID, + } + if t == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Text", + SchemaName: "text", + }, + { + Name: "Type", + SchemaName: "type", + }, + { + Name: "Style", + SchemaName: "style", + Null: !t.Flags.Has(0), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (t *TextButton) SetFlags() { + if !(t.Style.Zero()) { + t.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (t *TextButton) Encode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode textButton#afc79cd6 as nil") + } + b.PutID(TextButtonTypeID) + return t.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (t *TextButton) EncodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode textButton#afc79cd6 as nil") + } + t.SetFlags() + if err := t.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode textButton#afc79cd6: field flags: %w", err) + } + if t.Text == nil { + return fmt.Errorf("unable to encode textButton#afc79cd6: field text is nil") + } + if err := t.Text.Encode(b); err != nil { + return fmt.Errorf("unable to encode textButton#afc79cd6: field text: %w", err) + } + if t.Type == nil { + return fmt.Errorf("unable to encode textButton#afc79cd6: field type is nil") + } + if err := t.Type.Encode(b); err != nil { + return fmt.Errorf("unable to encode textButton#afc79cd6: field type: %w", err) + } + if t.Flags.Has(0) { + if err := t.Style.Encode(b); err != nil { + return fmt.Errorf("unable to encode textButton#afc79cd6: field style: %w", err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (t *TextButton) Decode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode textButton#afc79cd6 to nil") + } + if err := b.ConsumeID(TextButtonTypeID); err != nil { + return fmt.Errorf("unable to decode textButton#afc79cd6: %w", err) + } + return t.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (t *TextButton) DecodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode textButton#afc79cd6 to nil") + } + { + if err := t.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode textButton#afc79cd6: field flags: %w", err) + } + } + { + value, err := DecodeRichText(b) + if err != nil { + return fmt.Errorf("unable to decode textButton#afc79cd6: field text: %w", err) + } + t.Text = value + } + { + value, err := DecodeInlineButtonType(b) + if err != nil { + return fmt.Errorf("unable to decode textButton#afc79cd6: field type: %w", err) + } + t.Type = value + } + if t.Flags.Has(0) { + if err := t.Style.Decode(b); err != nil { + return fmt.Errorf("unable to decode textButton#afc79cd6: field style: %w", err) + } + } + return nil +} + +// GetText returns value of Text field. +func (t *TextButton) GetText() (value RichTextClass) { + if t == nil { + return + } + return t.Text +} + +// GetType returns value of Type field. +func (t *TextButton) GetType() (value InlineButtonTypeClass) { + if t == nil { + return + } + return t.Type +} + +// SetStyle sets value of Style conditional field. +func (t *TextButton) SetStyle(value RichButtonStyle) { + t.Flags.Set(0) + t.Style = value +} + +// GetStyle returns value of Style conditional field and +// boolean which is true if field was set. +func (t *TextButton) GetStyle() (value RichButtonStyle, ok bool) { + if t == nil { + return + } + if !t.Flags.Has(0) { + return value, false + } + return t.Style, true +} + // RichTextClassName is schema name of RichTextClass. const RichTextClassName = "RichText" @@ -4745,6 +4982,7 @@ const RichTextClassName = "RichText" // - [TextMentionName] // - [TextDate] // - [TextDiff] +// - [TextButton] // // Example: // @@ -4783,6 +5021,7 @@ const RichTextClassName = "RichText" // case *tg.TextMentionName: // textMentionName#1a9fbfc // case *tg.TextDate: // textDate#a5b45e2b // case *tg.TextDiff: // textDiff#9686cb50 +// case *tg.TextButton: // textButton#afc79cd6 // default: panic(v) // } type RichTextClass interface { @@ -5021,6 +5260,13 @@ func DecodeRichText(buf *bin.Buffer) (RichTextClass, error) { return nil, fmt.Errorf("unable to decode RichTextClass: %w", err) } return &v, nil + case TextButtonTypeID: + // Decoding textButton#afc79cd6. + v := TextButton{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode RichTextClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode RichTextClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_rich_text_slices_gen.go b/tg/tl_rich_text_slices_gen.go index c579331c87..78e5f33555 100644 --- a/tg/tl_rich_text_slices_gen.go +++ b/tg/tl_rich_text_slices_gen.go @@ -493,6 +493,19 @@ func (s RichTextClassArray) AsTextDiff() (to TextDiffArray) { return to } +// AsTextButton returns copy with only TextButton constructors. +func (s RichTextClassArray) AsTextButton() (to TextButtonArray) { + for _, elem := range s { + value, ok := elem.(*TextButton) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // TextPlainArray is adapter for slice of TextPlain. type TextPlainArray []TextPlain @@ -2884,3 +2897,85 @@ func (s *TextDiffArray) Pop() (v TextDiff, ok bool) { return v, true } + +// TextButtonArray is adapter for slice of TextButton. +type TextButtonArray []TextButton + +// Sort sorts slice of TextButton. +func (s TextButtonArray) Sort(less func(a, b TextButton) bool) TextButtonArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of TextButton. +func (s TextButtonArray) SortStable(less func(a, b TextButton) bool) TextButtonArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of TextButton. +func (s TextButtonArray) Retain(keep func(x TextButton) bool) TextButtonArray { + 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 TextButtonArray) First() (v TextButton, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s TextButtonArray) Last() (v TextButton, 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 *TextButtonArray) PopFirst() (v TextButton, 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 TextButton + 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 *TextButtonArray) Pop() (v TextButton, 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_send_message_action_gen.go b/tg/tl_send_message_action_gen.go index 0412226174..8c4c6c67c3 100644 --- a/tg/tl_send_message_action_gen.go +++ b/tg/tl_send_message_action_gen.go @@ -2197,7 +2197,7 @@ func (s *SendMessageEmojiInteractionSeen) GetEmoticon() (value string) { return s.Emoticon } -// SendMessageTextDraftAction represents TL type `sendMessageTextDraftAction#376d975c`. +// SendMessageTextDraftAction represents TL type `sendMessageTextDraftAction#3630b85a`. // Used by bots to implement live message streaming »¹. // // Links: @@ -2205,6 +2205,12 @@ func (s *SendMessageEmojiInteractionSeen) GetEmoticon() (value string) { // // See https://core.telegram.org/constructor/sendMessageTextDraftAction for reference. type SendMessageTextDraftAction struct { + // Flags field of SendMessageTextDraftAction. + Flags bin.Fields + // CanStop field of SendMessageTextDraftAction. + CanStop bool + // KeepOnStop field of SendMessageTextDraftAction. + KeepOnStop bool // Live draft ID: used by graphical clients to slightly change the rendering behavior, // see here »¹ for more info. // @@ -2216,7 +2222,7 @@ type SendMessageTextDraftAction struct { } // SendMessageTextDraftActionTypeID is TL type id of SendMessageTextDraftAction. -const SendMessageTextDraftActionTypeID = 0x376d975c +const SendMessageTextDraftActionTypeID = 0x3630b85a // construct implements constructor of SendMessageActionClass. func (s SendMessageTextDraftAction) construct() SendMessageActionClass { return &s } @@ -2235,6 +2241,15 @@ func (s *SendMessageTextDraftAction) Zero() bool { if s == nil { return true } + if !(s.Flags.Zero()) { + return false + } + if !(s.CanStop == false) { + return false + } + if !(s.KeepOnStop == false) { + return false + } if !(s.RandomID == 0) { return false } @@ -2256,9 +2271,13 @@ func (s *SendMessageTextDraftAction) String() string { // FillFrom fills SendMessageTextDraftAction from given interface. func (s *SendMessageTextDraftAction) FillFrom(from interface { + GetCanStop() (value bool) + GetKeepOnStop() (value bool) GetRandomID() (value int64) GetText() (value TextWithEntities) }) { + s.CanStop = from.GetCanStop() + s.KeepOnStop = from.GetKeepOnStop() s.RandomID = from.GetRandomID() s.Text = from.GetText() } @@ -2286,6 +2305,16 @@ func (s *SendMessageTextDraftAction) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "CanStop", + SchemaName: "can_stop", + Null: !s.Flags.Has(0), + }, + { + Name: "KeepOnStop", + SchemaName: "keep_on_stop", + Null: !s.Flags.Has(1), + }, { Name: "RandomID", SchemaName: "random_id", @@ -2298,10 +2327,20 @@ func (s *SendMessageTextDraftAction) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (s *SendMessageTextDraftAction) SetFlags() { + if !(s.CanStop == false) { + s.Flags.Set(0) + } + if !(s.KeepOnStop == false) { + s.Flags.Set(1) + } +} + // Encode implements bin.Encoder. func (s *SendMessageTextDraftAction) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode sendMessageTextDraftAction#376d975c as nil") + return fmt.Errorf("can't encode sendMessageTextDraftAction#3630b85a as nil") } b.PutID(SendMessageTextDraftActionTypeID) return s.EncodeBare(b) @@ -2310,11 +2349,15 @@ func (s *SendMessageTextDraftAction) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *SendMessageTextDraftAction) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode sendMessageTextDraftAction#376d975c as nil") + return fmt.Errorf("can't encode sendMessageTextDraftAction#3630b85a as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode sendMessageTextDraftAction#3630b85a: field flags: %w", err) } b.PutLong(s.RandomID) if err := s.Text.Encode(b); err != nil { - return fmt.Errorf("unable to encode sendMessageTextDraftAction#376d975c: field text: %w", err) + return fmt.Errorf("unable to encode sendMessageTextDraftAction#3630b85a: field text: %w", err) } return nil } @@ -2322,10 +2365,10 @@ func (s *SendMessageTextDraftAction) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *SendMessageTextDraftAction) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode sendMessageTextDraftAction#376d975c to nil") + return fmt.Errorf("can't decode sendMessageTextDraftAction#3630b85a to nil") } if err := b.ConsumeID(SendMessageTextDraftActionTypeID); err != nil { - return fmt.Errorf("unable to decode sendMessageTextDraftAction#376d975c: %w", err) + return fmt.Errorf("unable to decode sendMessageTextDraftAction#3630b85a: %w", err) } return s.DecodeBare(b) } @@ -2333,23 +2376,68 @@ func (s *SendMessageTextDraftAction) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *SendMessageTextDraftAction) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode sendMessageTextDraftAction#376d975c to nil") + return fmt.Errorf("can't decode sendMessageTextDraftAction#3630b85a to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode sendMessageTextDraftAction#3630b85a: field flags: %w", err) + } } + s.CanStop = s.Flags.Has(0) + s.KeepOnStop = s.Flags.Has(1) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode sendMessageTextDraftAction#376d975c: field random_id: %w", err) + return fmt.Errorf("unable to decode sendMessageTextDraftAction#3630b85a: field random_id: %w", err) } s.RandomID = value } { if err := s.Text.Decode(b); err != nil { - return fmt.Errorf("unable to decode sendMessageTextDraftAction#376d975c: field text: %w", err) + return fmt.Errorf("unable to decode sendMessageTextDraftAction#3630b85a: field text: %w", err) } } return nil } +// SetCanStop sets value of CanStop conditional field. +func (s *SendMessageTextDraftAction) SetCanStop(value bool) { + if value { + s.Flags.Set(0) + s.CanStop = true + } else { + s.Flags.Unset(0) + s.CanStop = false + } +} + +// GetCanStop returns value of CanStop conditional field. +func (s *SendMessageTextDraftAction) GetCanStop() (value bool) { + if s == nil { + return + } + return s.Flags.Has(0) +} + +// SetKeepOnStop sets value of KeepOnStop conditional field. +func (s *SendMessageTextDraftAction) SetKeepOnStop(value bool) { + if value { + s.Flags.Set(1) + s.KeepOnStop = true + } else { + s.Flags.Unset(1) + s.KeepOnStop = false + } +} + +// GetKeepOnStop returns value of KeepOnStop conditional field. +func (s *SendMessageTextDraftAction) GetKeepOnStop() (value bool) { + if s == nil { + return + } + return s.Flags.Has(1) +} + // GetRandomID returns value of RandomID field. func (s *SendMessageTextDraftAction) GetRandomID() (value int64) { if s == nil { @@ -2366,10 +2454,16 @@ func (s *SendMessageTextDraftAction) GetText() (value TextWithEntities) { return s.Text } -// InputSendMessageRichMessageDraftAction represents TL type `inputSendMessageRichMessageDraftAction#e2b23b51`. +// InputSendMessageRichMessageDraftAction represents TL type `inputSendMessageRichMessageDraftAction#a937c7be`. // // See https://core.telegram.org/constructor/inputSendMessageRichMessageDraftAction for reference. type InputSendMessageRichMessageDraftAction struct { + // Flags field of InputSendMessageRichMessageDraftAction. + Flags bin.Fields + // CanStop field of InputSendMessageRichMessageDraftAction. + CanStop bool + // KeepOnStop field of InputSendMessageRichMessageDraftAction. + KeepOnStop bool // RandomID field of InputSendMessageRichMessageDraftAction. RandomID int64 // RichMessage field of InputSendMessageRichMessageDraftAction. @@ -2377,7 +2471,7 @@ type InputSendMessageRichMessageDraftAction struct { } // InputSendMessageRichMessageDraftActionTypeID is TL type id of InputSendMessageRichMessageDraftAction. -const InputSendMessageRichMessageDraftActionTypeID = 0xe2b23b51 +const InputSendMessageRichMessageDraftActionTypeID = 0xa937c7be // construct implements constructor of SendMessageActionClass. func (i InputSendMessageRichMessageDraftAction) construct() SendMessageActionClass { return &i } @@ -2396,6 +2490,15 @@ func (i *InputSendMessageRichMessageDraftAction) Zero() bool { if i == nil { return true } + if !(i.Flags.Zero()) { + return false + } + if !(i.CanStop == false) { + return false + } + if !(i.KeepOnStop == false) { + return false + } if !(i.RandomID == 0) { return false } @@ -2417,9 +2520,13 @@ func (i *InputSendMessageRichMessageDraftAction) String() string { // FillFrom fills InputSendMessageRichMessageDraftAction from given interface. func (i *InputSendMessageRichMessageDraftAction) FillFrom(from interface { + GetCanStop() (value bool) + GetKeepOnStop() (value bool) GetRandomID() (value int64) GetRichMessage() (value InputRichMessageClass) }) { + i.CanStop = from.GetCanStop() + i.KeepOnStop = from.GetKeepOnStop() i.RandomID = from.GetRandomID() i.RichMessage = from.GetRichMessage() } @@ -2447,6 +2554,16 @@ func (i *InputSendMessageRichMessageDraftAction) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "CanStop", + SchemaName: "can_stop", + Null: !i.Flags.Has(0), + }, + { + Name: "KeepOnStop", + SchemaName: "keep_on_stop", + Null: !i.Flags.Has(1), + }, { Name: "RandomID", SchemaName: "random_id", @@ -2459,10 +2576,20 @@ func (i *InputSendMessageRichMessageDraftAction) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (i *InputSendMessageRichMessageDraftAction) SetFlags() { + if !(i.CanStop == false) { + i.Flags.Set(0) + } + if !(i.KeepOnStop == false) { + i.Flags.Set(1) + } +} + // Encode implements bin.Encoder. func (i *InputSendMessageRichMessageDraftAction) Encode(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't encode inputSendMessageRichMessageDraftAction#e2b23b51 as nil") + return fmt.Errorf("can't encode inputSendMessageRichMessageDraftAction#a937c7be as nil") } b.PutID(InputSendMessageRichMessageDraftActionTypeID) return i.EncodeBare(b) @@ -2471,14 +2598,18 @@ func (i *InputSendMessageRichMessageDraftAction) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (i *InputSendMessageRichMessageDraftAction) EncodeBare(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't encode inputSendMessageRichMessageDraftAction#e2b23b51 as nil") + return fmt.Errorf("can't encode inputSendMessageRichMessageDraftAction#a937c7be as nil") + } + i.SetFlags() + if err := i.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputSendMessageRichMessageDraftAction#a937c7be: field flags: %w", err) } b.PutLong(i.RandomID) if i.RichMessage == nil { - return fmt.Errorf("unable to encode inputSendMessageRichMessageDraftAction#e2b23b51: field rich_message is nil") + return fmt.Errorf("unable to encode inputSendMessageRichMessageDraftAction#a937c7be: field rich_message is nil") } if err := i.RichMessage.Encode(b); err != nil { - return fmt.Errorf("unable to encode inputSendMessageRichMessageDraftAction#e2b23b51: field rich_message: %w", err) + return fmt.Errorf("unable to encode inputSendMessageRichMessageDraftAction#a937c7be: field rich_message: %w", err) } return nil } @@ -2486,10 +2617,10 @@ func (i *InputSendMessageRichMessageDraftAction) EncodeBare(b *bin.Buffer) error // Decode implements bin.Decoder. func (i *InputSendMessageRichMessageDraftAction) Decode(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't decode inputSendMessageRichMessageDraftAction#e2b23b51 to nil") + return fmt.Errorf("can't decode inputSendMessageRichMessageDraftAction#a937c7be to nil") } if err := b.ConsumeID(InputSendMessageRichMessageDraftActionTypeID); err != nil { - return fmt.Errorf("unable to decode inputSendMessageRichMessageDraftAction#e2b23b51: %w", err) + return fmt.Errorf("unable to decode inputSendMessageRichMessageDraftAction#a937c7be: %w", err) } return i.DecodeBare(b) } @@ -2497,25 +2628,70 @@ func (i *InputSendMessageRichMessageDraftAction) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (i *InputSendMessageRichMessageDraftAction) DecodeBare(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't decode inputSendMessageRichMessageDraftAction#e2b23b51 to nil") + return fmt.Errorf("can't decode inputSendMessageRichMessageDraftAction#a937c7be to nil") + } + { + if err := i.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode inputSendMessageRichMessageDraftAction#a937c7be: field flags: %w", err) + } } + i.CanStop = i.Flags.Has(0) + i.KeepOnStop = i.Flags.Has(1) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode inputSendMessageRichMessageDraftAction#e2b23b51: field random_id: %w", err) + return fmt.Errorf("unable to decode inputSendMessageRichMessageDraftAction#a937c7be: field random_id: %w", err) } i.RandomID = value } { value, err := DecodeInputRichMessage(b) if err != nil { - return fmt.Errorf("unable to decode inputSendMessageRichMessageDraftAction#e2b23b51: field rich_message: %w", err) + return fmt.Errorf("unable to decode inputSendMessageRichMessageDraftAction#a937c7be: field rich_message: %w", err) } i.RichMessage = value } return nil } +// SetCanStop sets value of CanStop conditional field. +func (i *InputSendMessageRichMessageDraftAction) SetCanStop(value bool) { + if value { + i.Flags.Set(0) + i.CanStop = true + } else { + i.Flags.Unset(0) + i.CanStop = false + } +} + +// GetCanStop returns value of CanStop conditional field. +func (i *InputSendMessageRichMessageDraftAction) GetCanStop() (value bool) { + if i == nil { + return + } + return i.Flags.Has(0) +} + +// SetKeepOnStop sets value of KeepOnStop conditional field. +func (i *InputSendMessageRichMessageDraftAction) SetKeepOnStop(value bool) { + if value { + i.Flags.Set(1) + i.KeepOnStop = true + } else { + i.Flags.Unset(1) + i.KeepOnStop = false + } +} + +// GetKeepOnStop returns value of KeepOnStop conditional field. +func (i *InputSendMessageRichMessageDraftAction) GetKeepOnStop() (value bool) { + if i == nil { + return + } + return i.Flags.Has(1) +} + // GetRandomID returns value of RandomID field. func (i *InputSendMessageRichMessageDraftAction) GetRandomID() (value int64) { if i == nil { @@ -2532,10 +2708,16 @@ func (i *InputSendMessageRichMessageDraftAction) GetRichMessage() (value InputRi return i.RichMessage } -// SendMessageRichMessageDraftAction represents TL type `sendMessageRichMessageDraftAction#a2cb24f9`. +// SendMessageRichMessageDraftAction represents TL type `sendMessageRichMessageDraftAction#52564893`. // // See https://core.telegram.org/constructor/sendMessageRichMessageDraftAction for reference. type SendMessageRichMessageDraftAction struct { + // Flags field of SendMessageRichMessageDraftAction. + Flags bin.Fields + // CanStop field of SendMessageRichMessageDraftAction. + CanStop bool + // KeepOnStop field of SendMessageRichMessageDraftAction. + KeepOnStop bool // RandomID field of SendMessageRichMessageDraftAction. RandomID int64 // RichMessage field of SendMessageRichMessageDraftAction. @@ -2543,7 +2725,7 @@ type SendMessageRichMessageDraftAction struct { } // SendMessageRichMessageDraftActionTypeID is TL type id of SendMessageRichMessageDraftAction. -const SendMessageRichMessageDraftActionTypeID = 0xa2cb24f9 +const SendMessageRichMessageDraftActionTypeID = 0x52564893 // construct implements constructor of SendMessageActionClass. func (s SendMessageRichMessageDraftAction) construct() SendMessageActionClass { return &s } @@ -2562,6 +2744,15 @@ func (s *SendMessageRichMessageDraftAction) Zero() bool { if s == nil { return true } + if !(s.Flags.Zero()) { + return false + } + if !(s.CanStop == false) { + return false + } + if !(s.KeepOnStop == false) { + return false + } if !(s.RandomID == 0) { return false } @@ -2583,9 +2774,13 @@ func (s *SendMessageRichMessageDraftAction) String() string { // FillFrom fills SendMessageRichMessageDraftAction from given interface. func (s *SendMessageRichMessageDraftAction) FillFrom(from interface { + GetCanStop() (value bool) + GetKeepOnStop() (value bool) GetRandomID() (value int64) GetRichMessage() (value RichMessage) }) { + s.CanStop = from.GetCanStop() + s.KeepOnStop = from.GetKeepOnStop() s.RandomID = from.GetRandomID() s.RichMessage = from.GetRichMessage() } @@ -2613,6 +2808,16 @@ func (s *SendMessageRichMessageDraftAction) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "CanStop", + SchemaName: "can_stop", + Null: !s.Flags.Has(0), + }, + { + Name: "KeepOnStop", + SchemaName: "keep_on_stop", + Null: !s.Flags.Has(1), + }, { Name: "RandomID", SchemaName: "random_id", @@ -2625,10 +2830,20 @@ func (s *SendMessageRichMessageDraftAction) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (s *SendMessageRichMessageDraftAction) SetFlags() { + if !(s.CanStop == false) { + s.Flags.Set(0) + } + if !(s.KeepOnStop == false) { + s.Flags.Set(1) + } +} + // Encode implements bin.Encoder. func (s *SendMessageRichMessageDraftAction) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode sendMessageRichMessageDraftAction#a2cb24f9 as nil") + return fmt.Errorf("can't encode sendMessageRichMessageDraftAction#52564893 as nil") } b.PutID(SendMessageRichMessageDraftActionTypeID) return s.EncodeBare(b) @@ -2637,11 +2852,15 @@ func (s *SendMessageRichMessageDraftAction) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *SendMessageRichMessageDraftAction) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode sendMessageRichMessageDraftAction#a2cb24f9 as nil") + return fmt.Errorf("can't encode sendMessageRichMessageDraftAction#52564893 as nil") + } + s.SetFlags() + if err := s.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode sendMessageRichMessageDraftAction#52564893: field flags: %w", err) } b.PutLong(s.RandomID) if err := s.RichMessage.Encode(b); err != nil { - return fmt.Errorf("unable to encode sendMessageRichMessageDraftAction#a2cb24f9: field rich_message: %w", err) + return fmt.Errorf("unable to encode sendMessageRichMessageDraftAction#52564893: field rich_message: %w", err) } return nil } @@ -2649,10 +2868,10 @@ func (s *SendMessageRichMessageDraftAction) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *SendMessageRichMessageDraftAction) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode sendMessageRichMessageDraftAction#a2cb24f9 to nil") + return fmt.Errorf("can't decode sendMessageRichMessageDraftAction#52564893 to nil") } if err := b.ConsumeID(SendMessageRichMessageDraftActionTypeID); err != nil { - return fmt.Errorf("unable to decode sendMessageRichMessageDraftAction#a2cb24f9: %w", err) + return fmt.Errorf("unable to decode sendMessageRichMessageDraftAction#52564893: %w", err) } return s.DecodeBare(b) } @@ -2660,23 +2879,68 @@ func (s *SendMessageRichMessageDraftAction) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *SendMessageRichMessageDraftAction) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode sendMessageRichMessageDraftAction#a2cb24f9 to nil") + return fmt.Errorf("can't decode sendMessageRichMessageDraftAction#52564893 to nil") + } + { + if err := s.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode sendMessageRichMessageDraftAction#52564893: field flags: %w", err) + } } + s.CanStop = s.Flags.Has(0) + s.KeepOnStop = s.Flags.Has(1) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode sendMessageRichMessageDraftAction#a2cb24f9: field random_id: %w", err) + return fmt.Errorf("unable to decode sendMessageRichMessageDraftAction#52564893: field random_id: %w", err) } s.RandomID = value } { if err := s.RichMessage.Decode(b); err != nil { - return fmt.Errorf("unable to decode sendMessageRichMessageDraftAction#a2cb24f9: field rich_message: %w", err) + return fmt.Errorf("unable to decode sendMessageRichMessageDraftAction#52564893: field rich_message: %w", err) } } return nil } +// SetCanStop sets value of CanStop conditional field. +func (s *SendMessageRichMessageDraftAction) SetCanStop(value bool) { + if value { + s.Flags.Set(0) + s.CanStop = true + } else { + s.Flags.Unset(0) + s.CanStop = false + } +} + +// GetCanStop returns value of CanStop conditional field. +func (s *SendMessageRichMessageDraftAction) GetCanStop() (value bool) { + if s == nil { + return + } + return s.Flags.Has(0) +} + +// SetKeepOnStop sets value of KeepOnStop conditional field. +func (s *SendMessageRichMessageDraftAction) SetKeepOnStop(value bool) { + if value { + s.Flags.Set(1) + s.KeepOnStop = true + } else { + s.Flags.Unset(1) + s.KeepOnStop = false + } +} + +// GetKeepOnStop returns value of KeepOnStop conditional field. +func (s *SendMessageRichMessageDraftAction) GetKeepOnStop() (value bool) { + if s == nil { + return + } + return s.Flags.Has(1) +} + // GetRandomID returns value of RandomID field. func (s *SendMessageRichMessageDraftAction) GetRandomID() (value int64) { if s == nil { @@ -2693,6 +2957,140 @@ func (s *SendMessageRichMessageDraftAction) GetRichMessage() (value RichMessage) return s.RichMessage } +// SendMessageStopDraftAction represents TL type `sendMessageStopDraftAction#fbf902b0`. +// +// See https://core.telegram.org/constructor/sendMessageStopDraftAction for reference. +type SendMessageStopDraftAction struct { + // RandomID field of SendMessageStopDraftAction. + RandomID int64 +} + +// SendMessageStopDraftActionTypeID is TL type id of SendMessageStopDraftAction. +const SendMessageStopDraftActionTypeID = 0xfbf902b0 + +// construct implements constructor of SendMessageActionClass. +func (s SendMessageStopDraftAction) construct() SendMessageActionClass { return &s } + +// Ensuring interfaces in compile-time for SendMessageStopDraftAction. +var ( + _ bin.Encoder = &SendMessageStopDraftAction{} + _ bin.Decoder = &SendMessageStopDraftAction{} + _ bin.BareEncoder = &SendMessageStopDraftAction{} + _ bin.BareDecoder = &SendMessageStopDraftAction{} + + _ SendMessageActionClass = &SendMessageStopDraftAction{} +) + +func (s *SendMessageStopDraftAction) Zero() bool { + if s == nil { + return true + } + if !(s.RandomID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *SendMessageStopDraftAction) String() string { + if s == nil { + return "SendMessageStopDraftAction(nil)" + } + type Alias SendMessageStopDraftAction + return fmt.Sprintf("SendMessageStopDraftAction%+v", Alias(*s)) +} + +// FillFrom fills SendMessageStopDraftAction from given interface. +func (s *SendMessageStopDraftAction) FillFrom(from interface { + GetRandomID() (value int64) +}) { + s.RandomID = from.GetRandomID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*SendMessageStopDraftAction) TypeID() uint32 { + return SendMessageStopDraftActionTypeID +} + +// TypeName returns name of type in TL schema. +func (*SendMessageStopDraftAction) TypeName() string { + return "sendMessageStopDraftAction" +} + +// TypeInfo returns info about TL type. +func (s *SendMessageStopDraftAction) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "sendMessageStopDraftAction", + ID: SendMessageStopDraftActionTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "RandomID", + SchemaName: "random_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *SendMessageStopDraftAction) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode sendMessageStopDraftAction#fbf902b0 as nil") + } + b.PutID(SendMessageStopDraftActionTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *SendMessageStopDraftAction) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode sendMessageStopDraftAction#fbf902b0 as nil") + } + b.PutLong(s.RandomID) + return nil +} + +// Decode implements bin.Decoder. +func (s *SendMessageStopDraftAction) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode sendMessageStopDraftAction#fbf902b0 to nil") + } + if err := b.ConsumeID(SendMessageStopDraftActionTypeID); err != nil { + return fmt.Errorf("unable to decode sendMessageStopDraftAction#fbf902b0: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *SendMessageStopDraftAction) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode sendMessageStopDraftAction#fbf902b0 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode sendMessageStopDraftAction#fbf902b0: field random_id: %w", err) + } + s.RandomID = value + } + return nil +} + +// GetRandomID returns value of RandomID field. +func (s *SendMessageStopDraftAction) GetRandomID() (value int64) { + if s == nil { + return + } + return s.RandomID +} + // SendMessageActionClassName is schema name of SendMessageActionClass. const SendMessageActionClassName = "SendMessageAction" @@ -2722,6 +3120,7 @@ const SendMessageActionClassName = "SendMessageAction" // - [SendMessageTextDraftAction] // - [InputSendMessageRichMessageDraftAction] // - [SendMessageRichMessageDraftAction] +// - [SendMessageStopDraftAction] // // Example: // @@ -2748,9 +3147,10 @@ const SendMessageActionClassName = "SendMessageAction" // case *tg.SendMessageChooseStickerAction: // sendMessageChooseStickerAction#b05ac6b1 // case *tg.SendMessageEmojiInteraction: // sendMessageEmojiInteraction#25972bcb // case *tg.SendMessageEmojiInteractionSeen: // sendMessageEmojiInteractionSeen#b665902e -// case *tg.SendMessageTextDraftAction: // sendMessageTextDraftAction#376d975c -// case *tg.InputSendMessageRichMessageDraftAction: // inputSendMessageRichMessageDraftAction#e2b23b51 -// case *tg.SendMessageRichMessageDraftAction: // sendMessageRichMessageDraftAction#a2cb24f9 +// case *tg.SendMessageTextDraftAction: // sendMessageTextDraftAction#3630b85a +// case *tg.InputSendMessageRichMessageDraftAction: // inputSendMessageRichMessageDraftAction#a937c7be +// case *tg.SendMessageRichMessageDraftAction: // sendMessageRichMessageDraftAction#52564893 +// case *tg.SendMessageStopDraftAction: // sendMessageStopDraftAction#fbf902b0 // default: panic(v) // } type SendMessageActionClass interface { @@ -2906,26 +3306,33 @@ func DecodeSendMessageAction(buf *bin.Buffer) (SendMessageActionClass, error) { } return &v, nil case SendMessageTextDraftActionTypeID: - // Decoding sendMessageTextDraftAction#376d975c. + // Decoding sendMessageTextDraftAction#3630b85a. v := SendMessageTextDraftAction{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode SendMessageActionClass: %w", err) } return &v, nil case InputSendMessageRichMessageDraftActionTypeID: - // Decoding inputSendMessageRichMessageDraftAction#e2b23b51. + // Decoding inputSendMessageRichMessageDraftAction#a937c7be. v := InputSendMessageRichMessageDraftAction{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode SendMessageActionClass: %w", err) } return &v, nil case SendMessageRichMessageDraftActionTypeID: - // Decoding sendMessageRichMessageDraftAction#a2cb24f9. + // Decoding sendMessageRichMessageDraftAction#52564893. v := SendMessageRichMessageDraftAction{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode SendMessageActionClass: %w", err) } return &v, nil + case SendMessageStopDraftActionTypeID: + // Decoding sendMessageStopDraftAction#fbf902b0. + v := SendMessageStopDraftAction{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode SendMessageActionClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode SendMessageActionClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_send_message_action_slices_gen.go b/tg/tl_send_message_action_slices_gen.go index 910886959d..13f8e64cd1 100644 --- a/tg/tl_send_message_action_slices_gen.go +++ b/tg/tl_send_message_action_slices_gen.go @@ -259,6 +259,19 @@ func (s SendMessageActionClassArray) AsSendMessageRichMessageDraftAction() (to S return to } +// AsSendMessageStopDraftAction returns copy with only SendMessageStopDraftAction constructors. +func (s SendMessageActionClassArray) AsSendMessageStopDraftAction() (to SendMessageStopDraftActionArray) { + for _, elem := range s { + value, ok := elem.(*SendMessageStopDraftAction) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // SendMessageUploadVideoActionArray is adapter for slice of SendMessageUploadVideoAction. type SendMessageUploadVideoActionArray []SendMessageUploadVideoAction @@ -1160,3 +1173,85 @@ func (s *SendMessageRichMessageDraftActionArray) Pop() (v SendMessageRichMessage return v, true } + +// SendMessageStopDraftActionArray is adapter for slice of SendMessageStopDraftAction. +type SendMessageStopDraftActionArray []SendMessageStopDraftAction + +// Sort sorts slice of SendMessageStopDraftAction. +func (s SendMessageStopDraftActionArray) Sort(less func(a, b SendMessageStopDraftAction) bool) SendMessageStopDraftActionArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of SendMessageStopDraftAction. +func (s SendMessageStopDraftActionArray) SortStable(less func(a, b SendMessageStopDraftAction) bool) SendMessageStopDraftActionArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of SendMessageStopDraftAction. +func (s SendMessageStopDraftActionArray) Retain(keep func(x SendMessageStopDraftAction) bool) SendMessageStopDraftActionArray { + 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 SendMessageStopDraftActionArray) First() (v SendMessageStopDraftAction, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s SendMessageStopDraftActionArray) Last() (v SendMessageStopDraftAction, 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 *SendMessageStopDraftActionArray) PopFirst() (v SendMessageStopDraftAction, 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 SendMessageStopDraftAction + 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 *SendMessageStopDraftActionArray) Pop() (v SendMessageStopDraftAction, 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_server_gen.go b/tg/tl_server_gen.go index c1b4d6cf63..7cf1c2608f 100644 --- a/tg/tl_server_gen.go +++ b/tg/tl_server_gen.go @@ -527,6 +527,57 @@ func (s *ServerDispatcher) OnAuthFinishPasskeyLogin(f func(ctx context.Context, s.handlers[AuthFinishPasskeyLoginRequestTypeID] = handler } +func (s *ServerDispatcher) OnAuthInitFirebasePnvLogin(f func(ctx context.Context, request *AuthInitFirebasePnvLoginRequest) (*AuthFirebasePnvIntent, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request AuthInitFirebasePnvLoginRequest + 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[AuthInitFirebasePnvLoginRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnAuthFinishFirebasePnvLogin(f func(ctx context.Context, googletoken string) (AuthAuthorizationClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request AuthFinishFirebasePnvLoginRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, request.GoogleToken) + if err != nil { + return nil, err + } + return &AuthAuthorizationBox{Authorization: response}, nil + } + + s.handlers[AuthFinishFirebasePnvLoginRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnAuthFirebasePnvSignUp(f func(ctx context.Context, request *AuthFirebasePnvSignUpRequest) (AuthAuthorizationClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request AuthFirebasePnvSignUpRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return &AuthAuthorizationBox{Authorization: response}, nil + } + + s.handlers[AuthFirebasePnvSignUpRequestTypeID] = handler +} + func (s *ServerDispatcher) OnAccountRegisterDevice(f func(ctx context.Context, request *AccountRegisterDeviceRequest) (bool, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request AccountRegisterDeviceRequest @@ -10638,7 +10689,7 @@ func (s *ServerDispatcher) OnBotsRequestWebViewButton(f func(ctx context.Context s.handlers[BotsRequestWebViewButtonRequestTypeID] = handler } -func (s *ServerDispatcher) OnBotsGetRequestedWebViewButton(f func(ctx context.Context, request *BotsGetRequestedWebViewButtonRequest) (KeyboardButtonClass, error)) { +func (s *ServerDispatcher) OnBotsGetRequestedWebViewButton(f func(ctx context.Context, request *BotsGetRequestedWebViewButtonRequest) (*KeyboardButton, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request BotsGetRequestedWebViewButtonRequest if err := request.Decode(b); err != nil { @@ -10649,7 +10700,7 @@ func (s *ServerDispatcher) OnBotsGetRequestedWebViewButton(f func(ctx context.Co if err != nil { return nil, err } - return &KeyboardButtonBox{KeyboardButton: response}, nil + return response, nil } s.handlers[BotsGetRequestedWebViewButtonRequestTypeID] = handler @@ -14440,6 +14491,82 @@ func (s *ServerDispatcher) OnEphemeralGetCallbackAnswer(f func(ctx context.Conte s.handlers[EphemeralGetCallbackAnswerRequestTypeID] = handler } +func (s *ServerDispatcher) OnEphemeralEditMessage(f func(ctx context.Context, request *EphemeralEditMessageRequest) (UpdatesClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request EphemeralEditMessageRequest + 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[EphemeralEditMessageRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnEphemeralDeleteWelcomeMessage(f func(ctx context.Context, request *EphemeralDeleteWelcomeMessageRequest) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request EphemeralDeleteWelcomeMessageRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + if response { + return &BoolBox{Bool: &BoolTrue{}}, nil + } + + return &BoolBox{Bool: &BoolFalse{}}, nil + } + + s.handlers[EphemeralDeleteWelcomeMessageRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnEphemeralDeleteAllWelcomeMessages(f func(ctx context.Context, peer InputPeerClass) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request EphemeralDeleteAllWelcomeMessagesRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, request.Peer) + if err != nil { + return nil, err + } + if response { + return &BoolBox{Bool: &BoolTrue{}}, nil + } + + return &BoolBox{Bool: &BoolFalse{}}, nil + } + + s.handlers[EphemeralDeleteAllWelcomeMessagesRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnEphemeralGetWelcomeMessages(f func(ctx context.Context, request *EphemeralGetWelcomeMessagesRequest) (EphemeralWelcomeMessagesClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request EphemeralGetWelcomeMessagesRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return &EphemeralWelcomeMessagesBox{WelcomeMessages: response}, nil + } + + s.handlers[EphemeralGetWelcomeMessagesRequestTypeID] = handler +} + func (s *ServerDispatcher) OnTestUseError(f func(ctx context.Context) (*Error, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request TestUseErrorRequest diff --git a/tg/tl_update_gen.go b/tg/tl_update_gen.go index b4f53576db..50b46c7c5a 100644 --- a/tg/tl_update_gen.go +++ b/tg/tl_update_gen.go @@ -33512,6 +33512,367 @@ func (u *UpdateEditEphemeralMessage) GetMessage() (value EphemeralMessage) { return u.Message } +// UpdateEphemeralBotCallbackQuery represents TL type `updateEphemeralBotCallbackQuery#7c1079d6`. +// +// See https://core.telegram.org/constructor/updateEphemeralBotCallbackQuery for reference. +type UpdateEphemeralBotCallbackQuery struct { + // Flags field of UpdateEphemeralBotCallbackQuery. + Flags bin.Fields + // QueryID field of UpdateEphemeralBotCallbackQuery. + QueryID int64 + // UserID field of UpdateEphemeralBotCallbackQuery. + UserID int64 + // Peer field of UpdateEphemeralBotCallbackQuery. + // + // Use SetPeer and GetPeer helpers. + Peer PeerClass + // MsgID field of UpdateEphemeralBotCallbackQuery. + MsgID int + // Data field of UpdateEphemeralBotCallbackQuery. + Data []byte + // ChatInstance field of UpdateEphemeralBotCallbackQuery. + // + // Use SetChatInstance and GetChatInstance helpers. + ChatInstance int64 + // Message field of UpdateEphemeralBotCallbackQuery. + Message EphemeralMessage +} + +// UpdateEphemeralBotCallbackQueryTypeID is TL type id of UpdateEphemeralBotCallbackQuery. +const UpdateEphemeralBotCallbackQueryTypeID = 0x7c1079d6 + +// construct implements constructor of UpdateClass. +func (u UpdateEphemeralBotCallbackQuery) construct() UpdateClass { return &u } + +// Ensuring interfaces in compile-time for UpdateEphemeralBotCallbackQuery. +var ( + _ bin.Encoder = &UpdateEphemeralBotCallbackQuery{} + _ bin.Decoder = &UpdateEphemeralBotCallbackQuery{} + _ bin.BareEncoder = &UpdateEphemeralBotCallbackQuery{} + _ bin.BareDecoder = &UpdateEphemeralBotCallbackQuery{} + + _ UpdateClass = &UpdateEphemeralBotCallbackQuery{} +) + +func (u *UpdateEphemeralBotCallbackQuery) Zero() bool { + if u == nil { + return true + } + if !(u.Flags.Zero()) { + return false + } + if !(u.QueryID == 0) { + return false + } + if !(u.UserID == 0) { + return false + } + if !(u.Peer == nil) { + return false + } + if !(u.MsgID == 0) { + return false + } + if !(u.Data == nil) { + return false + } + if !(u.ChatInstance == 0) { + return false + } + if !(u.Message.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *UpdateEphemeralBotCallbackQuery) String() string { + if u == nil { + return "UpdateEphemeralBotCallbackQuery(nil)" + } + type Alias UpdateEphemeralBotCallbackQuery + return fmt.Sprintf("UpdateEphemeralBotCallbackQuery%+v", Alias(*u)) +} + +// FillFrom fills UpdateEphemeralBotCallbackQuery from given interface. +func (u *UpdateEphemeralBotCallbackQuery) FillFrom(from interface { + GetQueryID() (value int64) + GetUserID() (value int64) + GetPeer() (value PeerClass, ok bool) + GetMsgID() (value int) + GetData() (value []byte) + GetChatInstance() (value int64, ok bool) + GetMessage() (value EphemeralMessage) +}) { + u.QueryID = from.GetQueryID() + u.UserID = from.GetUserID() + if val, ok := from.GetPeer(); ok { + u.Peer = val + } + + u.MsgID = from.GetMsgID() + u.Data = from.GetData() + if val, ok := from.GetChatInstance(); ok { + u.ChatInstance = val + } + + u.Message = from.GetMessage() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*UpdateEphemeralBotCallbackQuery) TypeID() uint32 { + return UpdateEphemeralBotCallbackQueryTypeID +} + +// TypeName returns name of type in TL schema. +func (*UpdateEphemeralBotCallbackQuery) TypeName() string { + return "updateEphemeralBotCallbackQuery" +} + +// TypeInfo returns info about TL type. +func (u *UpdateEphemeralBotCallbackQuery) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "updateEphemeralBotCallbackQuery", + ID: UpdateEphemeralBotCallbackQueryTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "QueryID", + SchemaName: "query_id", + }, + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "Peer", + SchemaName: "peer", + Null: !u.Flags.Has(0), + }, + { + Name: "MsgID", + SchemaName: "msg_id", + }, + { + Name: "Data", + SchemaName: "data", + }, + { + Name: "ChatInstance", + SchemaName: "chat_instance", + Null: !u.Flags.Has(1), + }, + { + Name: "Message", + SchemaName: "message", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (u *UpdateEphemeralBotCallbackQuery) SetFlags() { + if !(u.Peer == nil) { + u.Flags.Set(0) + } + if !(u.ChatInstance == 0) { + u.Flags.Set(1) + } +} + +// Encode implements bin.Encoder. +func (u *UpdateEphemeralBotCallbackQuery) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateEphemeralBotCallbackQuery#7c1079d6 as nil") + } + b.PutID(UpdateEphemeralBotCallbackQueryTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *UpdateEphemeralBotCallbackQuery) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateEphemeralBotCallbackQuery#7c1079d6 as nil") + } + u.SetFlags() + if err := u.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode updateEphemeralBotCallbackQuery#7c1079d6: field flags: %w", err) + } + b.PutLong(u.QueryID) + b.PutLong(u.UserID) + if u.Flags.Has(0) { + if u.Peer == nil { + return fmt.Errorf("unable to encode updateEphemeralBotCallbackQuery#7c1079d6: field peer is nil") + } + if err := u.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode updateEphemeralBotCallbackQuery#7c1079d6: field peer: %w", err) + } + } + b.PutInt(u.MsgID) + b.PutBytes(u.Data) + if u.Flags.Has(1) { + b.PutLong(u.ChatInstance) + } + if err := u.Message.Encode(b); err != nil { + return fmt.Errorf("unable to encode updateEphemeralBotCallbackQuery#7c1079d6: field message: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (u *UpdateEphemeralBotCallbackQuery) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateEphemeralBotCallbackQuery#7c1079d6 to nil") + } + if err := b.ConsumeID(UpdateEphemeralBotCallbackQueryTypeID); err != nil { + return fmt.Errorf("unable to decode updateEphemeralBotCallbackQuery#7c1079d6: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *UpdateEphemeralBotCallbackQuery) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateEphemeralBotCallbackQuery#7c1079d6 to nil") + } + { + if err := u.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode updateEphemeralBotCallbackQuery#7c1079d6: field flags: %w", err) + } + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode updateEphemeralBotCallbackQuery#7c1079d6: field query_id: %w", err) + } + u.QueryID = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode updateEphemeralBotCallbackQuery#7c1079d6: field user_id: %w", err) + } + u.UserID = value + } + if u.Flags.Has(0) { + value, err := DecodePeer(b) + if err != nil { + return fmt.Errorf("unable to decode updateEphemeralBotCallbackQuery#7c1079d6: field peer: %w", err) + } + u.Peer = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode updateEphemeralBotCallbackQuery#7c1079d6: field msg_id: %w", err) + } + u.MsgID = value + } + { + value, err := b.Bytes() + if err != nil { + return fmt.Errorf("unable to decode updateEphemeralBotCallbackQuery#7c1079d6: field data: %w", err) + } + u.Data = value + } + if u.Flags.Has(1) { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode updateEphemeralBotCallbackQuery#7c1079d6: field chat_instance: %w", err) + } + u.ChatInstance = value + } + { + if err := u.Message.Decode(b); err != nil { + return fmt.Errorf("unable to decode updateEphemeralBotCallbackQuery#7c1079d6: field message: %w", err) + } + } + return nil +} + +// GetQueryID returns value of QueryID field. +func (u *UpdateEphemeralBotCallbackQuery) GetQueryID() (value int64) { + if u == nil { + return + } + return u.QueryID +} + +// GetUserID returns value of UserID field. +func (u *UpdateEphemeralBotCallbackQuery) GetUserID() (value int64) { + if u == nil { + return + } + return u.UserID +} + +// SetPeer sets value of Peer conditional field. +func (u *UpdateEphemeralBotCallbackQuery) SetPeer(value PeerClass) { + u.Flags.Set(0) + u.Peer = value +} + +// GetPeer returns value of Peer conditional field and +// boolean which is true if field was set. +func (u *UpdateEphemeralBotCallbackQuery) GetPeer() (value PeerClass, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(0) { + return value, false + } + return u.Peer, true +} + +// GetMsgID returns value of MsgID field. +func (u *UpdateEphemeralBotCallbackQuery) GetMsgID() (value int) { + if u == nil { + return + } + return u.MsgID +} + +// GetData returns value of Data field. +func (u *UpdateEphemeralBotCallbackQuery) GetData() (value []byte) { + if u == nil { + return + } + return u.Data +} + +// SetChatInstance sets value of ChatInstance conditional field. +func (u *UpdateEphemeralBotCallbackQuery) SetChatInstance(value int64) { + u.Flags.Set(1) + u.ChatInstance = value +} + +// GetChatInstance returns value of ChatInstance conditional field and +// boolean which is true if field was set. +func (u *UpdateEphemeralBotCallbackQuery) GetChatInstance() (value int64, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(1) { + return value, false + } + return u.ChatInstance, true +} + +// GetMessage returns value of Message field. +func (u *UpdateEphemeralBotCallbackQuery) GetMessage() (value EphemeralMessage) { + if u == nil { + return + } + return u.Message +} + // UpdateBotStarsSubscription represents TL type `updateBotStarsSubscription#6c0d8e23`. // // See https://core.telegram.org/constructor/updateBotStarsSubscription for reference. @@ -33994,6 +34355,7 @@ const UpdateClassName = "Update" // - [UpdateNewEphemeralMessage] // - [UpdateDeleteEphemeralMessages] // - [UpdateEditEphemeralMessage] +// - [UpdateEphemeralBotCallbackQuery] // - [UpdateBotStarsSubscription] // // Example: @@ -34166,6 +34528,7 @@ const UpdateClassName = "Update" // case *tg.UpdateNewEphemeralMessage: // updateNewEphemeralMessage#20bcbba1 // case *tg.UpdateDeleteEphemeralMessages: // updateDeleteEphemeralMessages#56dbfcf8 // case *tg.UpdateEditEphemeralMessage: // updateEditEphemeralMessage#4bbb8f01 +// case *tg.UpdateEphemeralBotCallbackQuery: // updateEphemeralBotCallbackQuery#7c1079d6 // case *tg.UpdateBotStarsSubscription: // updateBotStarsSubscription#6c0d8e23 // default: panic(v) // } @@ -35336,6 +35699,13 @@ func DecodeUpdate(buf *bin.Buffer) (UpdateClass, error) { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) } return &v, nil + case UpdateEphemeralBotCallbackQueryTypeID: + // Decoding updateEphemeralBotCallbackQuery#7c1079d6. + v := UpdateEphemeralBotCallbackQuery{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) + } + return &v, nil case UpdateBotStarsSubscriptionTypeID: // Decoding updateBotStarsSubscription#6c0d8e23. v := UpdateBotStarsSubscription{} diff --git a/tg/tl_update_slices_gen.go b/tg/tl_update_slices_gen.go index 796c8ebd8c..54251ad4db 100644 --- a/tg/tl_update_slices_gen.go +++ b/tg/tl_update_slices_gen.go @@ -2001,6 +2001,19 @@ func (s UpdateClassArray) AsUpdateEditEphemeralMessage() (to UpdateEditEphemeral return to } +// AsUpdateEphemeralBotCallbackQuery returns copy with only UpdateEphemeralBotCallbackQuery constructors. +func (s UpdateClassArray) AsUpdateEphemeralBotCallbackQuery() (to UpdateEphemeralBotCallbackQueryArray) { + for _, elem := range s { + value, ok := elem.(*UpdateEphemeralBotCallbackQuery) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // AsUpdateBotStarsSubscription returns copy with only UpdateBotStarsSubscription constructors. func (s UpdateClassArray) AsUpdateBotStarsSubscription() (to UpdateBotStarsSubscriptionArray) { for _, elem := range s { @@ -14170,6 +14183,88 @@ func (s *UpdateEditEphemeralMessageArray) Pop() (v UpdateEditEphemeralMessage, o return v, true } +// UpdateEphemeralBotCallbackQueryArray is adapter for slice of UpdateEphemeralBotCallbackQuery. +type UpdateEphemeralBotCallbackQueryArray []UpdateEphemeralBotCallbackQuery + +// Sort sorts slice of UpdateEphemeralBotCallbackQuery. +func (s UpdateEphemeralBotCallbackQueryArray) Sort(less func(a, b UpdateEphemeralBotCallbackQuery) bool) UpdateEphemeralBotCallbackQueryArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of UpdateEphemeralBotCallbackQuery. +func (s UpdateEphemeralBotCallbackQueryArray) SortStable(less func(a, b UpdateEphemeralBotCallbackQuery) bool) UpdateEphemeralBotCallbackQueryArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of UpdateEphemeralBotCallbackQuery. +func (s UpdateEphemeralBotCallbackQueryArray) Retain(keep func(x UpdateEphemeralBotCallbackQuery) bool) UpdateEphemeralBotCallbackQueryArray { + 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 UpdateEphemeralBotCallbackQueryArray) First() (v UpdateEphemeralBotCallbackQuery, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s UpdateEphemeralBotCallbackQueryArray) Last() (v UpdateEphemeralBotCallbackQuery, 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 *UpdateEphemeralBotCallbackQueryArray) PopFirst() (v UpdateEphemeralBotCallbackQuery, 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 UpdateEphemeralBotCallbackQuery + 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 *UpdateEphemeralBotCallbackQueryArray) Pop() (v UpdateEphemeralBotCallbackQuery, 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 +} + // UpdateBotStarsSubscriptionArray is adapter for slice of UpdateBotStarsSubscription. type UpdateBotStarsSubscriptionArray []UpdateBotStarsSubscription