From c4b4673ba05bfff232770106504f8670425dd871 Mon Sep 17 00:00:00 2001 From: GitHub Date: Tue, 12 Apr 2022 07:45:10 +0000 Subject: [PATCH] feat(schema): update Telegram to the latest layer --- _schema/tdesktop.tl | 108 ++- _schema/telegram.tl | 108 ++- telegram/query/cached/queries.gen.go | 168 +++++ tg/tl_account_get_saved_ringtones_gen.go | 176 +++++ ..._account_get_saved_ringtones_slices_gen.go | 35 + tg/tl_account_save_ringtone_gen.go | 210 ++++++ tg/tl_account_save_ringtone_slices_gen.go | 35 + tg/tl_account_saved_ringtone_gen.go | 360 ++++++++++ tg/tl_account_saved_ringtone_slices_gen.go | 212 ++++++ tg/tl_account_saved_ringtones_gen.go | 418 ++++++++++++ tg/tl_account_saved_ringtones_slices_gen.go | 267 ++++++++ tg/tl_account_upload_ringtone_gen.go | 232 +++++++ tg/tl_account_upload_ringtone_slices_gen.go | 35 + tg/tl_attach_menu_bot_gen.go | 283 ++++++++ tg/tl_attach_menu_bot_icon_color_gen.go | 188 ++++++ ...l_attach_menu_bot_icon_color_slices_gen.go | 35 + tg/tl_attach_menu_bot_icon_gen.go | 279 ++++++++ tg/tl_attach_menu_bot_icon_slices_gen.go | 35 + tg/tl_attach_menu_bot_slices_gen.go | 35 + tg/tl_attach_menu_bots_bot_gen.go | 211 ++++++ tg/tl_attach_menu_bots_bot_slices_gen.go | 35 + tg/tl_attach_menu_bots_gen.go | 460 +++++++++++++ tg/tl_attach_menu_bots_slices_gen.go | 267 ++++++++ tg/tl_bot_info_gen.go | 56 +- tg/tl_bot_menu_button_gen.go | 491 ++++++++++++++ tg/tl_bot_menu_button_slices_gen.go | 212 ++++++ tg/tl_bots_get_bot_menu_button_gen.go | 181 +++++ tg/tl_bots_get_bot_menu_button_slices_gen.go | 35 + ..._bot_broadcast_default_admin_rights_gen.go | 177 +++++ ...oadcast_default_admin_rights_slices_gen.go | 35 + ..._set_bot_group_default_admin_rights_gen.go | 177 +++++ ...t_group_default_admin_rights_slices_gen.go | 35 + tg/tl_bots_set_bot_menu_button_gen.go | 211 ++++++ tg/tl_bots_set_bot_menu_button_slices_gen.go | 35 + tg/tl_channels_delete_history_gen.go | 86 ++- tg/tl_chat_full_gen.go | 174 +++-- tg/tl_chat_gen.go | 35 - tg/tl_handlers_gen.go | 40 ++ tg/tl_input_peer_notify_settings_gen.go | 47 +- tg/tl_keyboard_button_gen.go | 338 ++++++++++ tg/tl_keyboard_button_slices_gen.go | 190 ++++++ tg/tl_message_action_gen.go | 311 +++++++++ tg/tl_message_action_slices_gen.go | 190 ++++++ tg/tl_messages_get_attach_menu_bot_gen.go | 181 +++++ ...messages_get_attach_menu_bot_slices_gen.go | 35 + tg/tl_messages_get_attach_menu_bots_gen.go | 176 +++++ ...essages_get_attach_menu_bots_slices_gen.go | 35 + tg/tl_messages_prolong_web_view_gen.go | 339 ++++++++++ tg/tl_messages_prolong_web_view_slices_gen.go | 35 + tg/tl_messages_request_simple_web_view_gen.go | 271 ++++++++ ...ages_request_simple_web_view_slices_gen.go | 35 + tg/tl_messages_request_web_view_gen.go | 490 ++++++++++++++ tg/tl_messages_request_web_view_slices_gen.go | 35 + tg/tl_messages_send_web_view_data_gen.go | 259 +++++++ ..._messages_send_web_view_data_slices_gen.go | 35 + ...ssages_send_web_view_result_message_gen.go | 205 ++++++ ...send_web_view_result_message_slices_gen.go | 35 + ..._messages_toggle_bot_in_attach_menu_gen.go | 206 ++++++ ...es_toggle_bot_in_attach_menu_slices_gen.go | 35 + tg/tl_notification_sound_gen.go | 633 ++++++++++++++++++ tg/tl_notification_sound_slices_gen.go | 335 +++++++++ tg/tl_peer_notify_settings_gen.go | 175 ++++- tg/tl_registry_gen.go | 174 ++++- tg/tl_server_gen.go | 283 +++++++- tg/tl_simple_web_view_result_url_gen.go | 161 +++++ ...l_simple_web_view_result_url_slices_gen.go | 35 + tg/tl_update_gen.go | 534 +++++++++++++++ tg/tl_update_slices_gen.go | 190 ++++++ tg/tl_user_full_gen.go | 148 +++- tg/tl_user_gen.go | 35 + tg/tl_web_view_message_sent_gen.go | 205 ++++++ tg/tl_web_view_message_sent_slices_gen.go | 35 + tg/tl_web_view_result_url_gen.go | 188 ++++++ tg/tl_web_view_result_url_slices_gen.go | 35 + 74 files changed, 12580 insertions(+), 241 deletions(-) create mode 100644 tg/tl_account_get_saved_ringtones_gen.go create mode 100644 tg/tl_account_get_saved_ringtones_slices_gen.go create mode 100644 tg/tl_account_save_ringtone_gen.go create mode 100644 tg/tl_account_save_ringtone_slices_gen.go create mode 100644 tg/tl_account_saved_ringtone_gen.go create mode 100644 tg/tl_account_saved_ringtone_slices_gen.go create mode 100644 tg/tl_account_saved_ringtones_gen.go create mode 100644 tg/tl_account_saved_ringtones_slices_gen.go create mode 100644 tg/tl_account_upload_ringtone_gen.go create mode 100644 tg/tl_account_upload_ringtone_slices_gen.go create mode 100644 tg/tl_attach_menu_bot_gen.go create mode 100644 tg/tl_attach_menu_bot_icon_color_gen.go create mode 100644 tg/tl_attach_menu_bot_icon_color_slices_gen.go create mode 100644 tg/tl_attach_menu_bot_icon_gen.go create mode 100644 tg/tl_attach_menu_bot_icon_slices_gen.go create mode 100644 tg/tl_attach_menu_bot_slices_gen.go create mode 100644 tg/tl_attach_menu_bots_bot_gen.go create mode 100644 tg/tl_attach_menu_bots_bot_slices_gen.go create mode 100644 tg/tl_attach_menu_bots_gen.go create mode 100644 tg/tl_attach_menu_bots_slices_gen.go create mode 100644 tg/tl_bot_menu_button_gen.go create mode 100644 tg/tl_bot_menu_button_slices_gen.go create mode 100644 tg/tl_bots_get_bot_menu_button_gen.go create mode 100644 tg/tl_bots_get_bot_menu_button_slices_gen.go create mode 100644 tg/tl_bots_set_bot_broadcast_default_admin_rights_gen.go create mode 100644 tg/tl_bots_set_bot_broadcast_default_admin_rights_slices_gen.go create mode 100644 tg/tl_bots_set_bot_group_default_admin_rights_gen.go create mode 100644 tg/tl_bots_set_bot_group_default_admin_rights_slices_gen.go create mode 100644 tg/tl_bots_set_bot_menu_button_gen.go create mode 100644 tg/tl_bots_set_bot_menu_button_slices_gen.go create mode 100644 tg/tl_messages_get_attach_menu_bot_gen.go create mode 100644 tg/tl_messages_get_attach_menu_bot_slices_gen.go create mode 100644 tg/tl_messages_get_attach_menu_bots_gen.go create mode 100644 tg/tl_messages_get_attach_menu_bots_slices_gen.go create mode 100644 tg/tl_messages_prolong_web_view_gen.go create mode 100644 tg/tl_messages_prolong_web_view_slices_gen.go create mode 100644 tg/tl_messages_request_simple_web_view_gen.go create mode 100644 tg/tl_messages_request_simple_web_view_slices_gen.go create mode 100644 tg/tl_messages_request_web_view_gen.go create mode 100644 tg/tl_messages_request_web_view_slices_gen.go create mode 100644 tg/tl_messages_send_web_view_data_gen.go create mode 100644 tg/tl_messages_send_web_view_data_slices_gen.go create mode 100644 tg/tl_messages_send_web_view_result_message_gen.go create mode 100644 tg/tl_messages_send_web_view_result_message_slices_gen.go create mode 100644 tg/tl_messages_toggle_bot_in_attach_menu_gen.go create mode 100644 tg/tl_messages_toggle_bot_in_attach_menu_slices_gen.go create mode 100644 tg/tl_notification_sound_gen.go create mode 100644 tg/tl_notification_sound_slices_gen.go create mode 100644 tg/tl_simple_web_view_result_url_gen.go create mode 100644 tg/tl_simple_web_view_result_url_slices_gen.go create mode 100644 tg/tl_web_view_message_sent_gen.go create mode 100644 tg/tl_web_view_message_sent_slices_gen.go create mode 100644 tg/tl_web_view_result_url_gen.go create mode 100644 tg/tl_web_view_result_url_slices_gen.go diff --git a/_schema/tdesktop.tl b/_schema/tdesktop.tl index 11053ff03d..e4b4e2ae5d 100644 --- a/_schema/tdesktop.tl +++ b/_schema/tdesktop.tl @@ -1,8 +1,8 @@ // Code generated by ./cmd/dltl, DO NOT EDIT. // // Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/Resources/tl/api.tl -// Layer: 139 -// SHA256: 80cbdbe9df4d7a9dda681537ce4ae739567051782b9fb4237d3cab78c1d70384 +// Layer: 140 +// SHA256: 283b3306402528272ff3bcd1bb80089d471f721b3b7618695b6a41378eb90a3e boolFalse#bc799737 = Bool; @@ -134,7 +134,7 @@ storage.fileWebp#1081464c = storage.FileType; userEmpty#d3bc4b7a id:long = User; -user#3ff6ecb0 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true fake:flags.26?true id:long access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector bot_inline_placeholder:flags.19?string lang_code:flags.22?string = User; +user#3ff6ecb0 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true fake:flags.26?true bot_attach_menu:flags.27?true id:long access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector bot_inline_placeholder:flags.19?string lang_code:flags.22?string = User; userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto; @@ -154,7 +154,7 @@ userStatusLastMonth#77ebc742 = UserStatus; chatEmpty#29562865 id:long = Chat; -chat#41cbf256 flags:# creator:flags.0?true kicked:flags.1?true left:flags.2?true deactivated:flags.5?true call_active:flags.23?true call_not_empty:flags.24?true noforwards:flags.25?true id:long title:string photo:ChatPhoto participants_count:int date:int version:int migrated_to:flags.6?InputChannel admin_rights:flags.14?ChatAdminRights default_banned_rights:flags.18?ChatBannedRights = Chat; +chat#41cbf256 flags:# creator:flags.0?true left:flags.2?true deactivated:flags.5?true call_active:flags.23?true call_not_empty:flags.24?true noforwards:flags.25?true id:long title:string photo:ChatPhoto participants_count:int date:int version:int migrated_to:flags.6?InputChannel admin_rights:flags.14?ChatAdminRights default_banned_rights:flags.18?ChatBannedRights = Chat; chatForbidden#6592a1a7 id:long title:string = Chat; @@ -164,7 +164,7 @@ channelForbidden#17d493d5 flags:# broadcast:flags.5?true megagroup:flags.8?true chatFull#d18ee226 flags:# can_set_username:flags.7?true has_scheduled:flags.8?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector available_reactions:flags.18?Vector = ChatFull; -channelFull#e13c3d20 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 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?Vector = ChatFull; +channelFull#ea68a619 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 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?Vector = ChatFull; chatParticipant#c02d4007 user_id:long inviter_id:long date:int = ChatParticipant; @@ -272,6 +272,10 @@ messageActionSetChatTheme#aa786345 emoticon:string = MessageAction; messageActionChatJoinedByRequest#ebbca3cb = MessageAction; +messageActionWebViewDataSentMe#47dd8079 text:string data:string = MessageAction; + +messageActionWebViewDataSent#b4c38cb5 text:string = MessageAction; + dialog#a8edd0f5 flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int = Dialog; dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog; @@ -312,9 +316,9 @@ inputNotifyChats#4a95e84e = InputNotifyPeer; inputNotifyBroadcasts#b1db7c7e = InputNotifyPeer; -inputPeerNotifySettings#9c3d198e flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int sound:flags.3?string = InputPeerNotifySettings; +inputPeerNotifySettings#df1f002b flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int sound:flags.3?NotificationSound = InputPeerNotifySettings; -peerNotifySettings#af509d20 flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int sound:flags.3?string = PeerNotifySettings; +peerNotifySettings#a83b0426 flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int ios_sound:flags.3?NotificationSound android_sound:flags.4?NotificationSound other_sound:flags.5?NotificationSound = PeerNotifySettings; peerSettings#a518110d flags:# report_spam:flags.0?true add_contact:flags.1?true block_contact:flags.2?true share_contact:flags.3?true need_contacts_exception:flags.4?true report_geo:flags.5?true autoarchived:flags.7?true invite_members:flags.8?true request_chat_broadcast:flags.10?true geo_distance:flags.6?int request_chat_title:flags.9?string request_chat_date:flags.9?int = PeerSettings; @@ -342,7 +346,7 @@ inputReportReasonIllegalDrugs#a8eb2be = ReportReason; inputReportReasonPersonalDetails#9ec7863d = ReportReason; -userFull#cf366521 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true id:long about:flags.1?string settings:PeerSettings profile_photo:flags.2?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string = UserFull; +userFull#8c72ea81 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true id:long about:flags.1?string settings:PeerSettings profile_photo:flags.2?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights = UserFull; contact#145ade0b user_id:long mutual:Bool = Contact; @@ -608,6 +612,14 @@ updateBotChatInviteRequester#11dfa986 peer:Peer date:int user_id:long about:stri updateMessageReactions#154798c3 peer:Peer msg_id:int reactions:MessageReactions = Update; +updateAttachMenuBots#17b7a20b = Update; + +updateWebViewResultSent#1592b79d query_id:long = Update; + +updateBotMenuButton#14b85813 bot_id:long button:BotMenuButton = Update; + +updateSavedRingtones#74d8be99 = Update; + updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; updates.differenceEmpty#5d75a138 date:int seq:int = updates.Difference; @@ -890,7 +902,7 @@ messages.stickerSetNotModified#d3f924eb = messages.StickerSet; botCommand#c27ac8c7 command:string description:string = BotCommand; -botInfo#1b74b335 user_id:long description:string commands:Vector = BotInfo; +botInfo#e4169b5d user_id:long description:string commands:Vector menu_button:BotMenuButton = BotInfo; keyboardButton#a2fa4880 text:string = KeyboardButton; @@ -918,6 +930,10 @@ inputKeyboardButtonUserProfile#e988037b text:string user_id:InputUser = Keyboard keyboardButtonUserProfile#308660c1 text:string user_id:long = KeyboardButton; +keyboardButtonWebView#13767230 text:string url:string = KeyboardButton; + +keyboardButtonSimpleWebView#a0c0505c text:string url:string = KeyboardButton; + keyboardButtonRow#77608b83 buttons:Vector = KeyboardButtonRow; replyKeyboardHide#a03e5b85 flags:# selective:flags.2?true = ReplyMarkup; @@ -1920,6 +1936,46 @@ phone.groupCallStreamChannels#d0e482b2 channels:Vector = phone.groupCallStreamRtmpUrl#2dbf3432 url:string key:string = phone.GroupCallStreamRtmpUrl; +attachMenuBotIconColor#4576f3f0 name:string color:int = AttachMenuBotIconColor; + +attachMenuBotIcon#b2a7386b flags:# name:string icon:Document colors:flags.0?Vector = AttachMenuBotIcon; + +attachMenuBot#e93cb772 flags:# inactive:flags.0?true bot_id:long short_name:string icons:Vector = AttachMenuBot; + +attachMenuBotsNotModified#f1d88a5c = AttachMenuBots; + +attachMenuBots#3c4301c0 hash:long bots:Vector users:Vector = AttachMenuBots; + +attachMenuBotsBot#93bf667f bot:AttachMenuBot users:Vector = AttachMenuBotsBot; + +webViewResultUrl#c14557c query_id:long url:string = WebViewResult; + +simpleWebViewResultUrl#882f76bb url:string = SimpleWebViewResult; + +webViewMessageSent#c94511c flags:# msg_id:flags.0?InputBotInlineMessageID = WebViewMessageSent; + +botMenuButtonDefault#7533a588 = BotMenuButton; + +botMenuButtonCommands#4258c205 = BotMenuButton; + +botMenuButton#c7b57ce6 text:string url:string = BotMenuButton; + +account.savedRingtonesNotModified#fbf6e8b1 = account.SavedRingtones; + +account.savedRingtones#c1e92cc5 hash:long ringtones:Vector = account.SavedRingtones; + +notificationSoundDefault#97e8bebe = NotificationSound; + +notificationSoundNone#6f0c34df = NotificationSound; + +notificationSoundLocal#830b9ae4 title:string data:string = NotificationSound; + +notificationSoundRingtone#ff6c8049 id:long = NotificationSound; + +account.savedRingtone#b7263f6d = account.SavedRingtone; + +account.savedRingtoneConverted#1f307eb7 document:Document = account.SavedRingtone; + ---functions--- @@ -2121,6 +2177,12 @@ account.setAuthorizationTTL#bf899aa0 authorization_ttl_days:int = Bool; account.changeAuthorizationSettings#40f48462 flags:# hash:long encrypted_requests_disabled:flags.0?Bool call_requests_disabled:flags.1?Bool = Bool; +account.getSavedRingtones#e1902288 hash:long = account.SavedRingtones; + +account.saveRingtone#3dea5b03 id:InputDocument unsave:Bool = account.SavedRingtone; + +account.uploadRingtone#831a83a2 file:InputFile file_name:string mime_type:string = Document; + users.getUsers#d91a548 id:Vector = Vector; users.getFullUser#b60f5918 id:InputUser = users.UserFull; @@ -2487,6 +2549,22 @@ messages.readReactions#82e251d7 peer:InputPeer = messages.AffectedHistory; messages.searchSentMedia#107e31a0 q:string filter:MessagesFilter limit:int = messages.Messages; +messages.getAttachMenuBots#16fcc2cb hash:long = AttachMenuBots; + +messages.getAttachMenuBot#77216192 bot:InputUser = AttachMenuBotsBot; + +messages.toggleBotInAttachMenu#1aee33af bot:InputUser enabled:Bool = Bool; + +messages.requestWebView#fa04dff flags:# from_bot_menu:flags.4?true silent:flags.5?true peer:InputPeer bot:InputUser url:flags.1?string start_param:flags.3?string theme_params:flags.2?DataJSON reply_to_msg_id:flags.0?int = WebViewResult; + +messages.prolongWebView#d22ad148 flags:# silent:flags.5?true peer:InputPeer bot:InputUser query_id:long reply_to_msg_id:flags.0?int = Bool; + +messages.requestSimpleWebView#6abb2f73 flags:# bot:InputUser url:string theme_params:flags.0?DataJSON = SimpleWebViewResult; + +messages.sendWebViewResultMessage#a4314f5 bot_query_id:string result:InputBotInlineResult = WebViewMessageSent; + +messages.sendWebViewData#dc0242c8 bot:InputUser random_id:long button_text:string data:string = Updates; + updates.getState#edd4882a = updates.State; updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference; @@ -2611,7 +2689,7 @@ channels.setStickers#ea8ca4f9 channel:InputChannel stickerset:InputStickerSet = channels.readMessageContents#eab5dc38 channel:InputChannel id:Vector = Bool; -channels.deleteHistory#af369d42 channel:InputChannel max_id:int = Bool; +channels.deleteHistory#9baa9647 flags:# for_everyone:flags.0?true channel:InputChannel max_id:int = Updates; channels.togglePreHistoryHidden#eabbb94c channel:InputChannel enabled:Bool = Updates; @@ -2649,6 +2727,14 @@ bots.resetBotCommands#3d8de0f9 scope:BotCommandScope lang_code:string = Bool; bots.getBotCommands#e34c0dd6 scope:BotCommandScope lang_code:string = Vector; +bots.setBotMenuButton#4504d54f user_id:InputUser button:BotMenuButton = Bool; + +bots.getBotMenuButton#9c60eb28 user_id:InputUser = BotMenuButton; + +bots.setBotBroadcastDefaultAdminRights#788464e1 admin_rights:ChatAdminRights = Bool; + +bots.setBotGroupDefaultAdminRights#925ec9ea admin_rights:ChatAdminRights = Bool; + payments.getPaymentForm#8a333c8d flags:# peer:InputPeer msg_id:int theme_params:flags.0?DataJSON = payments.PaymentForm; payments.getPaymentReceipt#2478d1cc peer:InputPeer msg_id:int = payments.PaymentReceipt; @@ -2761,4 +2847,4 @@ stats.getMessagePublicForwards#5630281b channel:InputChannel msg_id:int offset_r stats.getMessageStats#b6e0a3f5 flags:# dark:flags.0?true channel:InputChannel msg_id:int = stats.MessageStats; -// LAYER 139 +// LAYER 140 diff --git a/_schema/telegram.tl b/_schema/telegram.tl index 0152e246bb..2ba0594b49 100644 --- a/_schema/telegram.tl +++ b/_schema/telegram.tl @@ -2,8 +2,8 @@ // // Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/Resources/tl/api.tl // Merge: _schema/legacy.tl -// Layer: 139 -// SHA256: 80cbdbe9df4d7a9dda681537ce4ae739567051782b9fb4237d3cab78c1d70384 +// Layer: 140 +// SHA256: 283b3306402528272ff3bcd1bb80089d471f721b3b7618695b6a41378eb90a3e boolFalse#bc799737 = Bool; @@ -135,7 +135,7 @@ storage.fileWebp#1081464c = storage.FileType; userEmpty#d3bc4b7a id:long = User; -user#3ff6ecb0 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true fake:flags.26?true id:long access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector bot_inline_placeholder:flags.19?string lang_code:flags.22?string = User; +user#3ff6ecb0 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true fake:flags.26?true bot_attach_menu:flags.27?true id:long access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector bot_inline_placeholder:flags.19?string lang_code:flags.22?string = User; userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto; @@ -155,7 +155,7 @@ userStatusLastMonth#77ebc742 = UserStatus; chatEmpty#29562865 id:long = Chat; -chat#41cbf256 flags:# creator:flags.0?true kicked:flags.1?true left:flags.2?true deactivated:flags.5?true call_active:flags.23?true call_not_empty:flags.24?true noforwards:flags.25?true id:long title:string photo:ChatPhoto participants_count:int date:int version:int migrated_to:flags.6?InputChannel admin_rights:flags.14?ChatAdminRights default_banned_rights:flags.18?ChatBannedRights = Chat; +chat#41cbf256 flags:# creator:flags.0?true left:flags.2?true deactivated:flags.5?true call_active:flags.23?true call_not_empty:flags.24?true noforwards:flags.25?true id:long title:string photo:ChatPhoto participants_count:int date:int version:int migrated_to:flags.6?InputChannel admin_rights:flags.14?ChatAdminRights default_banned_rights:flags.18?ChatBannedRights = Chat; chatForbidden#6592a1a7 id:long title:string = Chat; @@ -165,7 +165,7 @@ channelForbidden#17d493d5 flags:# broadcast:flags.5?true megagroup:flags.8?true chatFull#d18ee226 flags:# can_set_username:flags.7?true has_scheduled:flags.8?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector available_reactions:flags.18?Vector = ChatFull; -channelFull#e13c3d20 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 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?Vector = ChatFull; +channelFull#ea68a619 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 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?Vector = ChatFull; chatParticipant#c02d4007 user_id:long inviter_id:long date:int = ChatParticipant; @@ -273,6 +273,10 @@ messageActionSetChatTheme#aa786345 emoticon:string = MessageAction; messageActionChatJoinedByRequest#ebbca3cb = MessageAction; +messageActionWebViewDataSentMe#47dd8079 text:string data:string = MessageAction; + +messageActionWebViewDataSent#b4c38cb5 text:string = MessageAction; + dialog#a8edd0f5 flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int = Dialog; dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog; @@ -313,9 +317,9 @@ inputNotifyChats#4a95e84e = InputNotifyPeer; inputNotifyBroadcasts#b1db7c7e = InputNotifyPeer; -inputPeerNotifySettings#9c3d198e flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int sound:flags.3?string = InputPeerNotifySettings; +inputPeerNotifySettings#df1f002b flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int sound:flags.3?NotificationSound = InputPeerNotifySettings; -peerNotifySettings#af509d20 flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int sound:flags.3?string = PeerNotifySettings; +peerNotifySettings#a83b0426 flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int ios_sound:flags.3?NotificationSound android_sound:flags.4?NotificationSound other_sound:flags.5?NotificationSound = PeerNotifySettings; peerSettings#a518110d flags:# report_spam:flags.0?true add_contact:flags.1?true block_contact:flags.2?true share_contact:flags.3?true need_contacts_exception:flags.4?true report_geo:flags.5?true autoarchived:flags.7?true invite_members:flags.8?true request_chat_broadcast:flags.10?true geo_distance:flags.6?int request_chat_title:flags.9?string request_chat_date:flags.9?int = PeerSettings; @@ -343,7 +347,7 @@ inputReportReasonIllegalDrugs#a8eb2be = ReportReason; inputReportReasonPersonalDetails#9ec7863d = ReportReason; -userFull#cf366521 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true id:long about:flags.1?string settings:PeerSettings profile_photo:flags.2?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string = UserFull; +userFull#8c72ea81 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true id:long about:flags.1?string settings:PeerSettings profile_photo:flags.2?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights = UserFull; contact#145ade0b user_id:long mutual:Bool = Contact; @@ -609,6 +613,14 @@ updateBotChatInviteRequester#11dfa986 peer:Peer date:int user_id:long about:stri updateMessageReactions#154798c3 peer:Peer msg_id:int reactions:MessageReactions = Update; +updateAttachMenuBots#17b7a20b = Update; + +updateWebViewResultSent#1592b79d query_id:long = Update; + +updateBotMenuButton#14b85813 bot_id:long button:BotMenuButton = Update; + +updateSavedRingtones#74d8be99 = Update; + updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; updates.differenceEmpty#5d75a138 date:int seq:int = updates.Difference; @@ -891,7 +903,7 @@ messages.stickerSetNotModified#d3f924eb = messages.StickerSet; botCommand#c27ac8c7 command:string description:string = BotCommand; -botInfo#1b74b335 user_id:long description:string commands:Vector = BotInfo; +botInfo#e4169b5d user_id:long description:string commands:Vector menu_button:BotMenuButton = BotInfo; keyboardButton#a2fa4880 text:string = KeyboardButton; @@ -919,6 +931,10 @@ inputKeyboardButtonUserProfile#e988037b text:string user_id:InputUser = Keyboard keyboardButtonUserProfile#308660c1 text:string user_id:long = KeyboardButton; +keyboardButtonWebView#13767230 text:string url:string = KeyboardButton; + +keyboardButtonSimpleWebView#a0c0505c text:string url:string = KeyboardButton; + keyboardButtonRow#77608b83 buttons:Vector = KeyboardButtonRow; replyKeyboardHide#a03e5b85 flags:# selective:flags.2?true = ReplyMarkup; @@ -1921,6 +1937,46 @@ phone.groupCallStreamChannels#d0e482b2 channels:Vector = phone.groupCallStreamRtmpUrl#2dbf3432 url:string key:string = phone.GroupCallStreamRtmpUrl; +attachMenuBotIconColor#4576f3f0 name:string color:int = AttachMenuBotIconColor; + +attachMenuBotIcon#b2a7386b flags:# name:string icon:Document colors:flags.0?Vector = AttachMenuBotIcon; + +attachMenuBot#e93cb772 flags:# inactive:flags.0?true bot_id:long short_name:string icons:Vector = AttachMenuBot; + +attachMenuBotsNotModified#f1d88a5c = AttachMenuBots; + +attachMenuBots#3c4301c0 hash:long bots:Vector users:Vector = AttachMenuBots; + +attachMenuBotsBot#93bf667f bot:AttachMenuBot users:Vector = AttachMenuBotsBot; + +webViewResultUrl#c14557c query_id:long url:string = WebViewResult; + +simpleWebViewResultUrl#882f76bb url:string = SimpleWebViewResult; + +webViewMessageSent#c94511c flags:# msg_id:flags.0?InputBotInlineMessageID = WebViewMessageSent; + +botMenuButtonDefault#7533a588 = BotMenuButton; + +botMenuButtonCommands#4258c205 = BotMenuButton; + +botMenuButton#c7b57ce6 text:string url:string = BotMenuButton; + +account.savedRingtonesNotModified#fbf6e8b1 = account.SavedRingtones; + +account.savedRingtones#c1e92cc5 hash:long ringtones:Vector = account.SavedRingtones; + +notificationSoundDefault#97e8bebe = NotificationSound; + +notificationSoundNone#6f0c34df = NotificationSound; + +notificationSoundLocal#830b9ae4 title:string data:string = NotificationSound; + +notificationSoundRingtone#ff6c8049 id:long = NotificationSound; + +account.savedRingtone#b7263f6d = account.SavedRingtone; + +account.savedRingtoneConverted#1f307eb7 document:Document = account.SavedRingtone; + ---functions--- @@ -2122,6 +2178,12 @@ account.setAuthorizationTTL#bf899aa0 authorization_ttl_days:int = Bool; account.changeAuthorizationSettings#40f48462 flags:# hash:long encrypted_requests_disabled:flags.0?Bool call_requests_disabled:flags.1?Bool = Bool; +account.getSavedRingtones#e1902288 hash:long = account.SavedRingtones; + +account.saveRingtone#3dea5b03 id:InputDocument unsave:Bool = account.SavedRingtone; + +account.uploadRingtone#831a83a2 file:InputFile file_name:string mime_type:string = Document; + users.getUsers#d91a548 id:Vector = Vector; users.getFullUser#b60f5918 id:InputUser = users.UserFull; @@ -2488,6 +2550,22 @@ messages.readReactions#82e251d7 peer:InputPeer = messages.AffectedHistory; messages.searchSentMedia#107e31a0 q:string filter:MessagesFilter limit:int = messages.Messages; +messages.getAttachMenuBots#16fcc2cb hash:long = AttachMenuBots; + +messages.getAttachMenuBot#77216192 bot:InputUser = AttachMenuBotsBot; + +messages.toggleBotInAttachMenu#1aee33af bot:InputUser enabled:Bool = Bool; + +messages.requestWebView#fa04dff flags:# from_bot_menu:flags.4?true silent:flags.5?true peer:InputPeer bot:InputUser url:flags.1?string start_param:flags.3?string theme_params:flags.2?DataJSON reply_to_msg_id:flags.0?int = WebViewResult; + +messages.prolongWebView#d22ad148 flags:# silent:flags.5?true peer:InputPeer bot:InputUser query_id:long reply_to_msg_id:flags.0?int = Bool; + +messages.requestSimpleWebView#6abb2f73 flags:# bot:InputUser url:string theme_params:flags.0?DataJSON = SimpleWebViewResult; + +messages.sendWebViewResultMessage#a4314f5 bot_query_id:string result:InputBotInlineResult = WebViewMessageSent; + +messages.sendWebViewData#dc0242c8 bot:InputUser random_id:long button_text:string data:string = Updates; + updates.getState#edd4882a = updates.State; updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference; @@ -2612,7 +2690,7 @@ channels.setStickers#ea8ca4f9 channel:InputChannel stickerset:InputStickerSet = channels.readMessageContents#eab5dc38 channel:InputChannel id:Vector = Bool; -channels.deleteHistory#af369d42 channel:InputChannel max_id:int = Bool; +channels.deleteHistory#9baa9647 flags:# for_everyone:flags.0?true channel:InputChannel max_id:int = Updates; channels.togglePreHistoryHidden#eabbb94c channel:InputChannel enabled:Bool = Updates; @@ -2650,6 +2728,14 @@ bots.resetBotCommands#3d8de0f9 scope:BotCommandScope lang_code:string = Bool; bots.getBotCommands#e34c0dd6 scope:BotCommandScope lang_code:string = Vector; +bots.setBotMenuButton#4504d54f user_id:InputUser button:BotMenuButton = Bool; + +bots.getBotMenuButton#9c60eb28 user_id:InputUser = BotMenuButton; + +bots.setBotBroadcastDefaultAdminRights#788464e1 admin_rights:ChatAdminRights = Bool; + +bots.setBotGroupDefaultAdminRights#925ec9ea admin_rights:ChatAdminRights = Bool; + payments.getPaymentForm#8a333c8d flags:# peer:InputPeer msg_id:int theme_params:flags.0?DataJSON = payments.PaymentForm; payments.getPaymentReceipt#2478d1cc peer:InputPeer msg_id:int = payments.PaymentReceipt; @@ -2794,4 +2880,4 @@ test.useError#ee75af01 = Error; test.useConfigSimple#f9b7b23d = help.ConfigSimple; -// LAYER 139 +// LAYER 140 diff --git a/telegram/query/cached/queries.gen.go b/telegram/query/cached/queries.gen.go index d09f7ea470..7fa237b5c1 100644 --- a/telegram/query/cached/queries.gen.go +++ b/telegram/query/cached/queries.gen.go @@ -98,6 +98,90 @@ func (s *AccountGetChatThemes) Fetch(ctx context.Context) (bool, error) { } } +type innerAccountGetSavedRingtones struct { + // Last received hash. + hash int64 + // Last received result. + value *tg.AccountSavedRingtones +} + +type AccountGetSavedRingtones struct { + // Result state. + last atomic.Value + + // Reference to RPC client to make requests. + raw *tg.Client +} + +// NewAccountGetSavedRingtones creates new AccountGetSavedRingtones. +func NewAccountGetSavedRingtones(raw *tg.Client) *AccountGetSavedRingtones { + q := &AccountGetSavedRingtones{ + raw: raw, + } + + return q +} + +func (s *AccountGetSavedRingtones) store(v innerAccountGetSavedRingtones) { + s.last.Store(v) +} + +func (s *AccountGetSavedRingtones) load() (innerAccountGetSavedRingtones, bool) { + v, ok := s.last.Load().(innerAccountGetSavedRingtones) + return v, ok +} + +// Value returns last received result. +// NB: May be nil. Returned AccountSavedRingtones must not be mutated. +func (s *AccountGetSavedRingtones) Value() *tg.AccountSavedRingtones { + inner, _ := s.load() + return inner.value +} + +// Hash returns last received hash. +func (s *AccountGetSavedRingtones) Hash() int64 { + inner, _ := s.load() + return inner.hash +} + +// Get updates data if needed and returns it. +func (s *AccountGetSavedRingtones) Get(ctx context.Context) (*tg.AccountSavedRingtones, 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 *AccountGetSavedRingtones) Fetch(ctx context.Context) (bool, error) { + lastHash := s.Hash() + + req := lastHash + result, err := s.raw.AccountGetSavedRingtones(ctx, req) + if err != nil { + return false, errors.Wrap(err, "execute AccountGetSavedRingtones") + } + + switch variant := result.(type) { + case *tg.AccountSavedRingtones: + hash := variant.Hash + + s.store(innerAccountGetSavedRingtones{ + hash: hash, + value: variant, + }) + return true, nil + case *tg.AccountSavedRingtonesNotModified: + 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 innerAccountGetThemes struct { // Last received hash. hash int64 @@ -438,6 +522,90 @@ func (s *MessagesGetAllStickers) Fetch(ctx context.Context) (bool, error) { } } +type innerMessagesGetAttachMenuBots struct { + // Last received hash. + hash int64 + // Last received result. + value *tg.AttachMenuBots +} + +type MessagesGetAttachMenuBots struct { + // Result state. + last atomic.Value + + // Reference to RPC client to make requests. + raw *tg.Client +} + +// NewMessagesGetAttachMenuBots creates new MessagesGetAttachMenuBots. +func NewMessagesGetAttachMenuBots(raw *tg.Client) *MessagesGetAttachMenuBots { + q := &MessagesGetAttachMenuBots{ + raw: raw, + } + + return q +} + +func (s *MessagesGetAttachMenuBots) store(v innerMessagesGetAttachMenuBots) { + s.last.Store(v) +} + +func (s *MessagesGetAttachMenuBots) load() (innerMessagesGetAttachMenuBots, bool) { + v, ok := s.last.Load().(innerMessagesGetAttachMenuBots) + return v, ok +} + +// Value returns last received result. +// NB: May be nil. Returned AttachMenuBots must not be mutated. +func (s *MessagesGetAttachMenuBots) Value() *tg.AttachMenuBots { + inner, _ := s.load() + return inner.value +} + +// Hash returns last received hash. +func (s *MessagesGetAttachMenuBots) Hash() int64 { + inner, _ := s.load() + return inner.hash +} + +// Get updates data if needed and returns it. +func (s *MessagesGetAttachMenuBots) Get(ctx context.Context) (*tg.AttachMenuBots, 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 *MessagesGetAttachMenuBots) Fetch(ctx context.Context) (bool, error) { + lastHash := s.Hash() + + req := lastHash + result, err := s.raw.MessagesGetAttachMenuBots(ctx, req) + if err != nil { + return false, errors.Wrap(err, "execute MessagesGetAttachMenuBots") + } + + switch variant := result.(type) { + case *tg.AttachMenuBots: + hash := variant.Hash + + s.store(innerMessagesGetAttachMenuBots{ + hash: hash, + value: variant, + }) + return true, nil + case *tg.AttachMenuBotsNotModified: + 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 innerMessagesGetFavedStickers struct { // Last received hash. hash int64 diff --git a/tg/tl_account_get_saved_ringtones_gen.go b/tg/tl_account_get_saved_ringtones_gen.go new file mode 100644 index 0000000000..5cd5058d2a --- /dev/null +++ b/tg/tl_account_get_saved_ringtones_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{} +) + +// AccountGetSavedRingtonesRequest represents TL type `account.getSavedRingtones#e1902288`. +// +// See https://core.telegram.org/method/account.getSavedRingtones for reference. +type AccountGetSavedRingtonesRequest struct { + // Hash field of AccountGetSavedRingtonesRequest. + Hash int64 +} + +// AccountGetSavedRingtonesRequestTypeID is TL type id of AccountGetSavedRingtonesRequest. +const AccountGetSavedRingtonesRequestTypeID = 0xe1902288 + +// Ensuring interfaces in compile-time for AccountGetSavedRingtonesRequest. +var ( + _ bin.Encoder = &AccountGetSavedRingtonesRequest{} + _ bin.Decoder = &AccountGetSavedRingtonesRequest{} + _ bin.BareEncoder = &AccountGetSavedRingtonesRequest{} + _ bin.BareDecoder = &AccountGetSavedRingtonesRequest{} +) + +func (g *AccountGetSavedRingtonesRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Hash == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *AccountGetSavedRingtonesRequest) String() string { + if g == nil { + return "AccountGetSavedRingtonesRequest(nil)" + } + type Alias AccountGetSavedRingtonesRequest + return fmt.Sprintf("AccountGetSavedRingtonesRequest%+v", Alias(*g)) +} + +// FillFrom fills AccountGetSavedRingtonesRequest from given interface. +func (g *AccountGetSavedRingtonesRequest) FillFrom(from interface { + GetHash() (value int64) +}) { + g.Hash = from.GetHash() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AccountGetSavedRingtonesRequest) TypeID() uint32 { + return AccountGetSavedRingtonesRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*AccountGetSavedRingtonesRequest) TypeName() string { + return "account.getSavedRingtones" +} + +// TypeInfo returns info about TL type. +func (g *AccountGetSavedRingtonesRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "account.getSavedRingtones", + ID: AccountGetSavedRingtonesRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Hash", + SchemaName: "hash", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *AccountGetSavedRingtonesRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode account.getSavedRingtones#e1902288 as nil") + } + b.PutID(AccountGetSavedRingtonesRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *AccountGetSavedRingtonesRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode account.getSavedRingtones#e1902288 as nil") + } + b.PutLong(g.Hash) + return nil +} + +// Decode implements bin.Decoder. +func (g *AccountGetSavedRingtonesRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode account.getSavedRingtones#e1902288 to nil") + } + if err := b.ConsumeID(AccountGetSavedRingtonesRequestTypeID); err != nil { + return fmt.Errorf("unable to decode account.getSavedRingtones#e1902288: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *AccountGetSavedRingtonesRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode account.getSavedRingtones#e1902288 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode account.getSavedRingtones#e1902288: field hash: %w", err) + } + g.Hash = value + } + return nil +} + +// GetHash returns value of Hash field. +func (g *AccountGetSavedRingtonesRequest) GetHash() (value int64) { + if g == nil { + return + } + return g.Hash +} + +// AccountGetSavedRingtones invokes method account.getSavedRingtones#e1902288 returning error if any. +// +// See https://core.telegram.org/method/account.getSavedRingtones for reference. +func (c *Client) AccountGetSavedRingtones(ctx context.Context, hash int64) (AccountSavedRingtonesClass, error) { + var result AccountSavedRingtonesBox + + request := &AccountGetSavedRingtonesRequest{ + Hash: hash, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.SavedRingtones, nil +} diff --git a/tg/tl_account_get_saved_ringtones_slices_gen.go b/tg/tl_account_get_saved_ringtones_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_account_get_saved_ringtones_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_account_save_ringtone_gen.go b/tg/tl_account_save_ringtone_gen.go new file mode 100644 index 0000000000..904098b479 --- /dev/null +++ b/tg/tl_account_save_ringtone_gen.go @@ -0,0 +1,210 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// AccountSaveRingtoneRequest represents TL type `account.saveRingtone#3dea5b03`. +// +// See https://core.telegram.org/method/account.saveRingtone for reference. +type AccountSaveRingtoneRequest struct { + // ID field of AccountSaveRingtoneRequest. + ID InputDocumentClass + // Unsave field of AccountSaveRingtoneRequest. + Unsave bool +} + +// AccountSaveRingtoneRequestTypeID is TL type id of AccountSaveRingtoneRequest. +const AccountSaveRingtoneRequestTypeID = 0x3dea5b03 + +// Ensuring interfaces in compile-time for AccountSaveRingtoneRequest. +var ( + _ bin.Encoder = &AccountSaveRingtoneRequest{} + _ bin.Decoder = &AccountSaveRingtoneRequest{} + _ bin.BareEncoder = &AccountSaveRingtoneRequest{} + _ bin.BareDecoder = &AccountSaveRingtoneRequest{} +) + +func (s *AccountSaveRingtoneRequest) Zero() bool { + if s == nil { + return true + } + if !(s.ID == nil) { + return false + } + if !(s.Unsave == false) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *AccountSaveRingtoneRequest) String() string { + if s == nil { + return "AccountSaveRingtoneRequest(nil)" + } + type Alias AccountSaveRingtoneRequest + return fmt.Sprintf("AccountSaveRingtoneRequest%+v", Alias(*s)) +} + +// FillFrom fills AccountSaveRingtoneRequest from given interface. +func (s *AccountSaveRingtoneRequest) FillFrom(from interface { + GetID() (value InputDocumentClass) + GetUnsave() (value bool) +}) { + s.ID = from.GetID() + s.Unsave = from.GetUnsave() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AccountSaveRingtoneRequest) TypeID() uint32 { + return AccountSaveRingtoneRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*AccountSaveRingtoneRequest) TypeName() string { + return "account.saveRingtone" +} + +// TypeInfo returns info about TL type. +func (s *AccountSaveRingtoneRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "account.saveRingtone", + ID: AccountSaveRingtoneRequestTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ID", + SchemaName: "id", + }, + { + Name: "Unsave", + SchemaName: "unsave", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *AccountSaveRingtoneRequest) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode account.saveRingtone#3dea5b03 as nil") + } + b.PutID(AccountSaveRingtoneRequestTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *AccountSaveRingtoneRequest) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode account.saveRingtone#3dea5b03 as nil") + } + if s.ID == nil { + return fmt.Errorf("unable to encode account.saveRingtone#3dea5b03: field id is nil") + } + if err := s.ID.Encode(b); err != nil { + return fmt.Errorf("unable to encode account.saveRingtone#3dea5b03: field id: %w", err) + } + b.PutBool(s.Unsave) + return nil +} + +// Decode implements bin.Decoder. +func (s *AccountSaveRingtoneRequest) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode account.saveRingtone#3dea5b03 to nil") + } + if err := b.ConsumeID(AccountSaveRingtoneRequestTypeID); err != nil { + return fmt.Errorf("unable to decode account.saveRingtone#3dea5b03: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *AccountSaveRingtoneRequest) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode account.saveRingtone#3dea5b03 to nil") + } + { + value, err := DecodeInputDocument(b) + if err != nil { + return fmt.Errorf("unable to decode account.saveRingtone#3dea5b03: field id: %w", err) + } + s.ID = value + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode account.saveRingtone#3dea5b03: field unsave: %w", err) + } + s.Unsave = value + } + return nil +} + +// GetID returns value of ID field. +func (s *AccountSaveRingtoneRequest) GetID() (value InputDocumentClass) { + if s == nil { + return + } + return s.ID +} + +// GetUnsave returns value of Unsave field. +func (s *AccountSaveRingtoneRequest) GetUnsave() (value bool) { + if s == nil { + return + } + return s.Unsave +} + +// GetIDAsNotEmpty returns mapped value of ID field. +func (s *AccountSaveRingtoneRequest) GetIDAsNotEmpty() (*InputDocument, bool) { + return s.ID.AsNotEmpty() +} + +// AccountSaveRingtone invokes method account.saveRingtone#3dea5b03 returning error if any. +// +// See https://core.telegram.org/method/account.saveRingtone for reference. +func (c *Client) AccountSaveRingtone(ctx context.Context, request *AccountSaveRingtoneRequest) (AccountSavedRingtoneClass, error) { + var result AccountSavedRingtoneBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.SavedRingtone, nil +} diff --git a/tg/tl_account_save_ringtone_slices_gen.go b/tg/tl_account_save_ringtone_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_account_save_ringtone_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_account_saved_ringtone_gen.go b/tg/tl_account_saved_ringtone_gen.go new file mode 100644 index 0000000000..266a862494 --- /dev/null +++ b/tg/tl_account_saved_ringtone_gen.go @@ -0,0 +1,360 @@ +// 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{} +) + +// AccountSavedRingtone represents TL type `account.savedRingtone#b7263f6d`. +// +// See https://core.telegram.org/constructor/account.savedRingtone for reference. +type AccountSavedRingtone struct { +} + +// AccountSavedRingtoneTypeID is TL type id of AccountSavedRingtone. +const AccountSavedRingtoneTypeID = 0xb7263f6d + +// construct implements constructor of AccountSavedRingtoneClass. +func (s AccountSavedRingtone) construct() AccountSavedRingtoneClass { return &s } + +// Ensuring interfaces in compile-time for AccountSavedRingtone. +var ( + _ bin.Encoder = &AccountSavedRingtone{} + _ bin.Decoder = &AccountSavedRingtone{} + _ bin.BareEncoder = &AccountSavedRingtone{} + _ bin.BareDecoder = &AccountSavedRingtone{} + + _ AccountSavedRingtoneClass = &AccountSavedRingtone{} +) + +func (s *AccountSavedRingtone) Zero() bool { + if s == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (s *AccountSavedRingtone) String() string { + if s == nil { + return "AccountSavedRingtone(nil)" + } + type Alias AccountSavedRingtone + return fmt.Sprintf("AccountSavedRingtone%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AccountSavedRingtone) TypeID() uint32 { + return AccountSavedRingtoneTypeID +} + +// TypeName returns name of type in TL schema. +func (*AccountSavedRingtone) TypeName() string { + return "account.savedRingtone" +} + +// TypeInfo returns info about TL type. +func (s *AccountSavedRingtone) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "account.savedRingtone", + ID: AccountSavedRingtoneTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (s *AccountSavedRingtone) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode account.savedRingtone#b7263f6d as nil") + } + b.PutID(AccountSavedRingtoneTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *AccountSavedRingtone) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode account.savedRingtone#b7263f6d as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (s *AccountSavedRingtone) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode account.savedRingtone#b7263f6d to nil") + } + if err := b.ConsumeID(AccountSavedRingtoneTypeID); err != nil { + return fmt.Errorf("unable to decode account.savedRingtone#b7263f6d: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *AccountSavedRingtone) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode account.savedRingtone#b7263f6d to nil") + } + return nil +} + +// AccountSavedRingtoneConverted represents TL type `account.savedRingtoneConverted#1f307eb7`. +// +// See https://core.telegram.org/constructor/account.savedRingtoneConverted for reference. +type AccountSavedRingtoneConverted struct { + // Document field of AccountSavedRingtoneConverted. + Document DocumentClass +} + +// AccountSavedRingtoneConvertedTypeID is TL type id of AccountSavedRingtoneConverted. +const AccountSavedRingtoneConvertedTypeID = 0x1f307eb7 + +// construct implements constructor of AccountSavedRingtoneClass. +func (s AccountSavedRingtoneConverted) construct() AccountSavedRingtoneClass { return &s } + +// Ensuring interfaces in compile-time for AccountSavedRingtoneConverted. +var ( + _ bin.Encoder = &AccountSavedRingtoneConverted{} + _ bin.Decoder = &AccountSavedRingtoneConverted{} + _ bin.BareEncoder = &AccountSavedRingtoneConverted{} + _ bin.BareDecoder = &AccountSavedRingtoneConverted{} + + _ AccountSavedRingtoneClass = &AccountSavedRingtoneConverted{} +) + +func (s *AccountSavedRingtoneConverted) Zero() bool { + if s == nil { + return true + } + if !(s.Document == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *AccountSavedRingtoneConverted) String() string { + if s == nil { + return "AccountSavedRingtoneConverted(nil)" + } + type Alias AccountSavedRingtoneConverted + return fmt.Sprintf("AccountSavedRingtoneConverted%+v", Alias(*s)) +} + +// FillFrom fills AccountSavedRingtoneConverted from given interface. +func (s *AccountSavedRingtoneConverted) FillFrom(from interface { + GetDocument() (value DocumentClass) +}) { + s.Document = from.GetDocument() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AccountSavedRingtoneConverted) TypeID() uint32 { + return AccountSavedRingtoneConvertedTypeID +} + +// TypeName returns name of type in TL schema. +func (*AccountSavedRingtoneConverted) TypeName() string { + return "account.savedRingtoneConverted" +} + +// TypeInfo returns info about TL type. +func (s *AccountSavedRingtoneConverted) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "account.savedRingtoneConverted", + ID: AccountSavedRingtoneConvertedTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Document", + SchemaName: "document", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *AccountSavedRingtoneConverted) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode account.savedRingtoneConverted#1f307eb7 as nil") + } + b.PutID(AccountSavedRingtoneConvertedTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *AccountSavedRingtoneConverted) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode account.savedRingtoneConverted#1f307eb7 as nil") + } + if s.Document == nil { + return fmt.Errorf("unable to encode account.savedRingtoneConverted#1f307eb7: field document is nil") + } + if err := s.Document.Encode(b); err != nil { + return fmt.Errorf("unable to encode account.savedRingtoneConverted#1f307eb7: field document: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *AccountSavedRingtoneConverted) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode account.savedRingtoneConverted#1f307eb7 to nil") + } + if err := b.ConsumeID(AccountSavedRingtoneConvertedTypeID); err != nil { + return fmt.Errorf("unable to decode account.savedRingtoneConverted#1f307eb7: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *AccountSavedRingtoneConverted) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode account.savedRingtoneConverted#1f307eb7 to nil") + } + { + value, err := DecodeDocument(b) + if err != nil { + return fmt.Errorf("unable to decode account.savedRingtoneConverted#1f307eb7: field document: %w", err) + } + s.Document = value + } + return nil +} + +// GetDocument returns value of Document field. +func (s *AccountSavedRingtoneConverted) GetDocument() (value DocumentClass) { + if s == nil { + return + } + return s.Document +} + +// AccountSavedRingtoneClassName is schema name of AccountSavedRingtoneClass. +const AccountSavedRingtoneClassName = "account.SavedRingtone" + +// AccountSavedRingtoneClass represents account.SavedRingtone generic type. +// +// See https://core.telegram.org/type/account.SavedRingtone for reference. +// +// Example: +// g, err := tg.DecodeAccountSavedRingtone(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.AccountSavedRingtone: // account.savedRingtone#b7263f6d +// case *tg.AccountSavedRingtoneConverted: // account.savedRingtoneConverted#1f307eb7 +// default: panic(v) +// } +type AccountSavedRingtoneClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() AccountSavedRingtoneClass + + // 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 +} + +// DecodeAccountSavedRingtone implements binary de-serialization for AccountSavedRingtoneClass. +func DecodeAccountSavedRingtone(buf *bin.Buffer) (AccountSavedRingtoneClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case AccountSavedRingtoneTypeID: + // Decoding account.savedRingtone#b7263f6d. + v := AccountSavedRingtone{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode AccountSavedRingtoneClass: %w", err) + } + return &v, nil + case AccountSavedRingtoneConvertedTypeID: + // Decoding account.savedRingtoneConverted#1f307eb7. + v := AccountSavedRingtoneConverted{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode AccountSavedRingtoneClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode AccountSavedRingtoneClass: %w", bin.NewUnexpectedID(id)) + } +} + +// AccountSavedRingtone boxes the AccountSavedRingtoneClass providing a helper. +type AccountSavedRingtoneBox struct { + SavedRingtone AccountSavedRingtoneClass +} + +// Decode implements bin.Decoder for AccountSavedRingtoneBox. +func (b *AccountSavedRingtoneBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode AccountSavedRingtoneBox to nil") + } + v, err := DecodeAccountSavedRingtone(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.SavedRingtone = v + return nil +} + +// Encode implements bin.Encode for AccountSavedRingtoneBox. +func (b *AccountSavedRingtoneBox) Encode(buf *bin.Buffer) error { + if b == nil || b.SavedRingtone == nil { + return fmt.Errorf("unable to encode AccountSavedRingtoneClass as nil") + } + return b.SavedRingtone.Encode(buf) +} diff --git a/tg/tl_account_saved_ringtone_slices_gen.go b/tg/tl_account_saved_ringtone_slices_gen.go new file mode 100644 index 0000000000..fef0e1fbc2 --- /dev/null +++ b/tg/tl_account_saved_ringtone_slices_gen.go @@ -0,0 +1,212 @@ +//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{} +) + +// AccountSavedRingtoneClassArray is adapter for slice of AccountSavedRingtoneClass. +type AccountSavedRingtoneClassArray []AccountSavedRingtoneClass + +// Sort sorts slice of AccountSavedRingtoneClass. +func (s AccountSavedRingtoneClassArray) Sort(less func(a, b AccountSavedRingtoneClass) bool) AccountSavedRingtoneClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of AccountSavedRingtoneClass. +func (s AccountSavedRingtoneClassArray) SortStable(less func(a, b AccountSavedRingtoneClass) bool) AccountSavedRingtoneClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of AccountSavedRingtoneClass. +func (s AccountSavedRingtoneClassArray) Retain(keep func(x AccountSavedRingtoneClass) bool) AccountSavedRingtoneClassArray { + 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 AccountSavedRingtoneClassArray) First() (v AccountSavedRingtoneClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s AccountSavedRingtoneClassArray) Last() (v AccountSavedRingtoneClass, 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 *AccountSavedRingtoneClassArray) PopFirst() (v AccountSavedRingtoneClass, 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 AccountSavedRingtoneClass + 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 *AccountSavedRingtoneClassArray) Pop() (v AccountSavedRingtoneClass, 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 +} + +// AsAccountSavedRingtoneConverted returns copy with only AccountSavedRingtoneConverted constructors. +func (s AccountSavedRingtoneClassArray) AsAccountSavedRingtoneConverted() (to AccountSavedRingtoneConvertedArray) { + for _, elem := range s { + value, ok := elem.(*AccountSavedRingtoneConverted) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AccountSavedRingtoneConvertedArray is adapter for slice of AccountSavedRingtoneConverted. +type AccountSavedRingtoneConvertedArray []AccountSavedRingtoneConverted + +// Sort sorts slice of AccountSavedRingtoneConverted. +func (s AccountSavedRingtoneConvertedArray) Sort(less func(a, b AccountSavedRingtoneConverted) bool) AccountSavedRingtoneConvertedArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of AccountSavedRingtoneConverted. +func (s AccountSavedRingtoneConvertedArray) SortStable(less func(a, b AccountSavedRingtoneConverted) bool) AccountSavedRingtoneConvertedArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of AccountSavedRingtoneConverted. +func (s AccountSavedRingtoneConvertedArray) Retain(keep func(x AccountSavedRingtoneConverted) bool) AccountSavedRingtoneConvertedArray { + 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 AccountSavedRingtoneConvertedArray) First() (v AccountSavedRingtoneConverted, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s AccountSavedRingtoneConvertedArray) Last() (v AccountSavedRingtoneConverted, 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 *AccountSavedRingtoneConvertedArray) PopFirst() (v AccountSavedRingtoneConverted, 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 AccountSavedRingtoneConverted + 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 *AccountSavedRingtoneConvertedArray) Pop() (v AccountSavedRingtoneConverted, 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_account_saved_ringtones_gen.go b/tg/tl_account_saved_ringtones_gen.go new file mode 100644 index 0000000000..5d28643e13 --- /dev/null +++ b/tg/tl_account_saved_ringtones_gen.go @@ -0,0 +1,418 @@ +// 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{} +) + +// AccountSavedRingtonesNotModified represents TL type `account.savedRingtonesNotModified#fbf6e8b1`. +// +// See https://core.telegram.org/constructor/account.savedRingtonesNotModified for reference. +type AccountSavedRingtonesNotModified struct { +} + +// AccountSavedRingtonesNotModifiedTypeID is TL type id of AccountSavedRingtonesNotModified. +const AccountSavedRingtonesNotModifiedTypeID = 0xfbf6e8b1 + +// construct implements constructor of AccountSavedRingtonesClass. +func (s AccountSavedRingtonesNotModified) construct() AccountSavedRingtonesClass { return &s } + +// Ensuring interfaces in compile-time for AccountSavedRingtonesNotModified. +var ( + _ bin.Encoder = &AccountSavedRingtonesNotModified{} + _ bin.Decoder = &AccountSavedRingtonesNotModified{} + _ bin.BareEncoder = &AccountSavedRingtonesNotModified{} + _ bin.BareDecoder = &AccountSavedRingtonesNotModified{} + + _ AccountSavedRingtonesClass = &AccountSavedRingtonesNotModified{} +) + +func (s *AccountSavedRingtonesNotModified) Zero() bool { + if s == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (s *AccountSavedRingtonesNotModified) String() string { + if s == nil { + return "AccountSavedRingtonesNotModified(nil)" + } + type Alias AccountSavedRingtonesNotModified + return fmt.Sprintf("AccountSavedRingtonesNotModified%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AccountSavedRingtonesNotModified) TypeID() uint32 { + return AccountSavedRingtonesNotModifiedTypeID +} + +// TypeName returns name of type in TL schema. +func (*AccountSavedRingtonesNotModified) TypeName() string { + return "account.savedRingtonesNotModified" +} + +// TypeInfo returns info about TL type. +func (s *AccountSavedRingtonesNotModified) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "account.savedRingtonesNotModified", + ID: AccountSavedRingtonesNotModifiedTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (s *AccountSavedRingtonesNotModified) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode account.savedRingtonesNotModified#fbf6e8b1 as nil") + } + b.PutID(AccountSavedRingtonesNotModifiedTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *AccountSavedRingtonesNotModified) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode account.savedRingtonesNotModified#fbf6e8b1 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (s *AccountSavedRingtonesNotModified) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode account.savedRingtonesNotModified#fbf6e8b1 to nil") + } + if err := b.ConsumeID(AccountSavedRingtonesNotModifiedTypeID); err != nil { + return fmt.Errorf("unable to decode account.savedRingtonesNotModified#fbf6e8b1: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *AccountSavedRingtonesNotModified) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode account.savedRingtonesNotModified#fbf6e8b1 to nil") + } + return nil +} + +// AccountSavedRingtones represents TL type `account.savedRingtones#c1e92cc5`. +// +// See https://core.telegram.org/constructor/account.savedRingtones for reference. +type AccountSavedRingtones struct { + // Hash field of AccountSavedRingtones. + Hash int64 + // Ringtones field of AccountSavedRingtones. + Ringtones []DocumentClass +} + +// AccountSavedRingtonesTypeID is TL type id of AccountSavedRingtones. +const AccountSavedRingtonesTypeID = 0xc1e92cc5 + +// construct implements constructor of AccountSavedRingtonesClass. +func (s AccountSavedRingtones) construct() AccountSavedRingtonesClass { return &s } + +// Ensuring interfaces in compile-time for AccountSavedRingtones. +var ( + _ bin.Encoder = &AccountSavedRingtones{} + _ bin.Decoder = &AccountSavedRingtones{} + _ bin.BareEncoder = &AccountSavedRingtones{} + _ bin.BareDecoder = &AccountSavedRingtones{} + + _ AccountSavedRingtonesClass = &AccountSavedRingtones{} +) + +func (s *AccountSavedRingtones) Zero() bool { + if s == nil { + return true + } + if !(s.Hash == 0) { + return false + } + if !(s.Ringtones == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *AccountSavedRingtones) String() string { + if s == nil { + return "AccountSavedRingtones(nil)" + } + type Alias AccountSavedRingtones + return fmt.Sprintf("AccountSavedRingtones%+v", Alias(*s)) +} + +// FillFrom fills AccountSavedRingtones from given interface. +func (s *AccountSavedRingtones) FillFrom(from interface { + GetHash() (value int64) + GetRingtones() (value []DocumentClass) +}) { + s.Hash = from.GetHash() + s.Ringtones = from.GetRingtones() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AccountSavedRingtones) TypeID() uint32 { + return AccountSavedRingtonesTypeID +} + +// TypeName returns name of type in TL schema. +func (*AccountSavedRingtones) TypeName() string { + return "account.savedRingtones" +} + +// TypeInfo returns info about TL type. +func (s *AccountSavedRingtones) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "account.savedRingtones", + ID: AccountSavedRingtonesTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Hash", + SchemaName: "hash", + }, + { + Name: "Ringtones", + SchemaName: "ringtones", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *AccountSavedRingtones) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode account.savedRingtones#c1e92cc5 as nil") + } + b.PutID(AccountSavedRingtonesTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *AccountSavedRingtones) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode account.savedRingtones#c1e92cc5 as nil") + } + b.PutLong(s.Hash) + b.PutVectorHeader(len(s.Ringtones)) + for idx, v := range s.Ringtones { + if v == nil { + return fmt.Errorf("unable to encode account.savedRingtones#c1e92cc5: field ringtones element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode account.savedRingtones#c1e92cc5: field ringtones element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (s *AccountSavedRingtones) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode account.savedRingtones#c1e92cc5 to nil") + } + if err := b.ConsumeID(AccountSavedRingtonesTypeID); err != nil { + return fmt.Errorf("unable to decode account.savedRingtones#c1e92cc5: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *AccountSavedRingtones) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode account.savedRingtones#c1e92cc5 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode account.savedRingtones#c1e92cc5: field hash: %w", err) + } + s.Hash = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode account.savedRingtones#c1e92cc5: field ringtones: %w", err) + } + + if headerLen > 0 { + s.Ringtones = make([]DocumentClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeDocument(b) + if err != nil { + return fmt.Errorf("unable to decode account.savedRingtones#c1e92cc5: field ringtones: %w", err) + } + s.Ringtones = append(s.Ringtones, value) + } + } + return nil +} + +// GetHash returns value of Hash field. +func (s *AccountSavedRingtones) GetHash() (value int64) { + if s == nil { + return + } + return s.Hash +} + +// GetRingtones returns value of Ringtones field. +func (s *AccountSavedRingtones) GetRingtones() (value []DocumentClass) { + if s == nil { + return + } + return s.Ringtones +} + +// MapRingtones returns field Ringtones wrapped in DocumentClassArray helper. +func (s *AccountSavedRingtones) MapRingtones() (value DocumentClassArray) { + return DocumentClassArray(s.Ringtones) +} + +// AccountSavedRingtonesClassName is schema name of AccountSavedRingtonesClass. +const AccountSavedRingtonesClassName = "account.SavedRingtones" + +// AccountSavedRingtonesClass represents account.SavedRingtones generic type. +// +// See https://core.telegram.org/type/account.SavedRingtones for reference. +// +// Example: +// g, err := tg.DecodeAccountSavedRingtones(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.AccountSavedRingtonesNotModified: // account.savedRingtonesNotModified#fbf6e8b1 +// case *tg.AccountSavedRingtones: // account.savedRingtones#c1e92cc5 +// default: panic(v) +// } +type AccountSavedRingtonesClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() AccountSavedRingtonesClass + + // 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 AccountSavedRingtonesClass to AccountSavedRingtones. + AsModified() (*AccountSavedRingtones, bool) +} + +// AsModified tries to map AccountSavedRingtonesNotModified to AccountSavedRingtones. +func (s *AccountSavedRingtonesNotModified) AsModified() (*AccountSavedRingtones, bool) { + return nil, false +} + +// AsModified tries to map AccountSavedRingtones to AccountSavedRingtones. +func (s *AccountSavedRingtones) AsModified() (*AccountSavedRingtones, bool) { + return s, true +} + +// DecodeAccountSavedRingtones implements binary de-serialization for AccountSavedRingtonesClass. +func DecodeAccountSavedRingtones(buf *bin.Buffer) (AccountSavedRingtonesClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case AccountSavedRingtonesNotModifiedTypeID: + // Decoding account.savedRingtonesNotModified#fbf6e8b1. + v := AccountSavedRingtonesNotModified{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode AccountSavedRingtonesClass: %w", err) + } + return &v, nil + case AccountSavedRingtonesTypeID: + // Decoding account.savedRingtones#c1e92cc5. + v := AccountSavedRingtones{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode AccountSavedRingtonesClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode AccountSavedRingtonesClass: %w", bin.NewUnexpectedID(id)) + } +} + +// AccountSavedRingtones boxes the AccountSavedRingtonesClass providing a helper. +type AccountSavedRingtonesBox struct { + SavedRingtones AccountSavedRingtonesClass +} + +// Decode implements bin.Decoder for AccountSavedRingtonesBox. +func (b *AccountSavedRingtonesBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode AccountSavedRingtonesBox to nil") + } + v, err := DecodeAccountSavedRingtones(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.SavedRingtones = v + return nil +} + +// Encode implements bin.Encode for AccountSavedRingtonesBox. +func (b *AccountSavedRingtonesBox) Encode(buf *bin.Buffer) error { + if b == nil || b.SavedRingtones == nil { + return fmt.Errorf("unable to encode AccountSavedRingtonesClass as nil") + } + return b.SavedRingtones.Encode(buf) +} diff --git a/tg/tl_account_saved_ringtones_slices_gen.go b/tg/tl_account_saved_ringtones_slices_gen.go new file mode 100644 index 0000000000..bfe59c9e46 --- /dev/null +++ b/tg/tl_account_saved_ringtones_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{} +) + +// AccountSavedRingtonesClassArray is adapter for slice of AccountSavedRingtonesClass. +type AccountSavedRingtonesClassArray []AccountSavedRingtonesClass + +// Sort sorts slice of AccountSavedRingtonesClass. +func (s AccountSavedRingtonesClassArray) Sort(less func(a, b AccountSavedRingtonesClass) bool) AccountSavedRingtonesClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of AccountSavedRingtonesClass. +func (s AccountSavedRingtonesClassArray) SortStable(less func(a, b AccountSavedRingtonesClass) bool) AccountSavedRingtonesClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of AccountSavedRingtonesClass. +func (s AccountSavedRingtonesClassArray) Retain(keep func(x AccountSavedRingtonesClass) bool) AccountSavedRingtonesClassArray { + 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 AccountSavedRingtonesClassArray) First() (v AccountSavedRingtonesClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s AccountSavedRingtonesClassArray) Last() (v AccountSavedRingtonesClass, 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 *AccountSavedRingtonesClassArray) PopFirst() (v AccountSavedRingtonesClass, 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 AccountSavedRingtonesClass + 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 *AccountSavedRingtonesClassArray) Pop() (v AccountSavedRingtonesClass, 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 +} + +// AsAccountSavedRingtones returns copy with only AccountSavedRingtones constructors. +func (s AccountSavedRingtonesClassArray) AsAccountSavedRingtones() (to AccountSavedRingtonesArray) { + for _, elem := range s { + value, ok := elem.(*AccountSavedRingtones) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AppendOnlyModified appends only Modified constructors to +// given slice. +func (s AccountSavedRingtonesClassArray) AppendOnlyModified(to []*AccountSavedRingtones) []*AccountSavedRingtones { + 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 AccountSavedRingtonesClassArray) AsModified() (to []*AccountSavedRingtones) { + return s.AppendOnlyModified(to) +} + +// FirstAsModified returns first element of slice (if exists). +func (s AccountSavedRingtonesClassArray) FirstAsModified() (v *AccountSavedRingtones, ok bool) { + value, ok := s.First() + if !ok { + return + } + return value.AsModified() +} + +// LastAsModified returns last element of slice (if exists). +func (s AccountSavedRingtonesClassArray) LastAsModified() (v *AccountSavedRingtones, ok bool) { + value, ok := s.Last() + if !ok { + return + } + return value.AsModified() +} + +// PopFirstAsModified returns element of slice (if exists). +func (s *AccountSavedRingtonesClassArray) PopFirstAsModified() (v *AccountSavedRingtones, ok bool) { + value, ok := s.PopFirst() + if !ok { + return + } + return value.AsModified() +} + +// PopAsModified returns element of slice (if exists). +func (s *AccountSavedRingtonesClassArray) PopAsModified() (v *AccountSavedRingtones, ok bool) { + value, ok := s.Pop() + if !ok { + return + } + return value.AsModified() +} + +// AccountSavedRingtonesArray is adapter for slice of AccountSavedRingtones. +type AccountSavedRingtonesArray []AccountSavedRingtones + +// Sort sorts slice of AccountSavedRingtones. +func (s AccountSavedRingtonesArray) Sort(less func(a, b AccountSavedRingtones) bool) AccountSavedRingtonesArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of AccountSavedRingtones. +func (s AccountSavedRingtonesArray) SortStable(less func(a, b AccountSavedRingtones) bool) AccountSavedRingtonesArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of AccountSavedRingtones. +func (s AccountSavedRingtonesArray) Retain(keep func(x AccountSavedRingtones) bool) AccountSavedRingtonesArray { + 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 AccountSavedRingtonesArray) First() (v AccountSavedRingtones, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s AccountSavedRingtonesArray) Last() (v AccountSavedRingtones, 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 *AccountSavedRingtonesArray) PopFirst() (v AccountSavedRingtones, 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 AccountSavedRingtones + 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 *AccountSavedRingtonesArray) Pop() (v AccountSavedRingtones, 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_account_upload_ringtone_gen.go b/tg/tl_account_upload_ringtone_gen.go new file mode 100644 index 0000000000..a2819ff43d --- /dev/null +++ b/tg/tl_account_upload_ringtone_gen.go @@ -0,0 +1,232 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// AccountUploadRingtoneRequest represents TL type `account.uploadRingtone#831a83a2`. +// +// See https://core.telegram.org/method/account.uploadRingtone for reference. +type AccountUploadRingtoneRequest struct { + // File field of AccountUploadRingtoneRequest. + File InputFileClass + // FileName field of AccountUploadRingtoneRequest. + FileName string + // MimeType field of AccountUploadRingtoneRequest. + MimeType string +} + +// AccountUploadRingtoneRequestTypeID is TL type id of AccountUploadRingtoneRequest. +const AccountUploadRingtoneRequestTypeID = 0x831a83a2 + +// Ensuring interfaces in compile-time for AccountUploadRingtoneRequest. +var ( + _ bin.Encoder = &AccountUploadRingtoneRequest{} + _ bin.Decoder = &AccountUploadRingtoneRequest{} + _ bin.BareEncoder = &AccountUploadRingtoneRequest{} + _ bin.BareDecoder = &AccountUploadRingtoneRequest{} +) + +func (u *AccountUploadRingtoneRequest) Zero() bool { + if u == nil { + return true + } + if !(u.File == nil) { + return false + } + if !(u.FileName == "") { + return false + } + if !(u.MimeType == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *AccountUploadRingtoneRequest) String() string { + if u == nil { + return "AccountUploadRingtoneRequest(nil)" + } + type Alias AccountUploadRingtoneRequest + return fmt.Sprintf("AccountUploadRingtoneRequest%+v", Alias(*u)) +} + +// FillFrom fills AccountUploadRingtoneRequest from given interface. +func (u *AccountUploadRingtoneRequest) FillFrom(from interface { + GetFile() (value InputFileClass) + GetFileName() (value string) + GetMimeType() (value string) +}) { + u.File = from.GetFile() + u.FileName = from.GetFileName() + u.MimeType = from.GetMimeType() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AccountUploadRingtoneRequest) TypeID() uint32 { + return AccountUploadRingtoneRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*AccountUploadRingtoneRequest) TypeName() string { + return "account.uploadRingtone" +} + +// TypeInfo returns info about TL type. +func (u *AccountUploadRingtoneRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "account.uploadRingtone", + ID: AccountUploadRingtoneRequestTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "File", + SchemaName: "file", + }, + { + Name: "FileName", + SchemaName: "file_name", + }, + { + Name: "MimeType", + SchemaName: "mime_type", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (u *AccountUploadRingtoneRequest) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode account.uploadRingtone#831a83a2 as nil") + } + b.PutID(AccountUploadRingtoneRequestTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *AccountUploadRingtoneRequest) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode account.uploadRingtone#831a83a2 as nil") + } + if u.File == nil { + return fmt.Errorf("unable to encode account.uploadRingtone#831a83a2: field file is nil") + } + if err := u.File.Encode(b); err != nil { + return fmt.Errorf("unable to encode account.uploadRingtone#831a83a2: field file: %w", err) + } + b.PutString(u.FileName) + b.PutString(u.MimeType) + return nil +} + +// Decode implements bin.Decoder. +func (u *AccountUploadRingtoneRequest) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode account.uploadRingtone#831a83a2 to nil") + } + if err := b.ConsumeID(AccountUploadRingtoneRequestTypeID); err != nil { + return fmt.Errorf("unable to decode account.uploadRingtone#831a83a2: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *AccountUploadRingtoneRequest) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode account.uploadRingtone#831a83a2 to nil") + } + { + value, err := DecodeInputFile(b) + if err != nil { + return fmt.Errorf("unable to decode account.uploadRingtone#831a83a2: field file: %w", err) + } + u.File = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode account.uploadRingtone#831a83a2: field file_name: %w", err) + } + u.FileName = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode account.uploadRingtone#831a83a2: field mime_type: %w", err) + } + u.MimeType = value + } + return nil +} + +// GetFile returns value of File field. +func (u *AccountUploadRingtoneRequest) GetFile() (value InputFileClass) { + if u == nil { + return + } + return u.File +} + +// GetFileName returns value of FileName field. +func (u *AccountUploadRingtoneRequest) GetFileName() (value string) { + if u == nil { + return + } + return u.FileName +} + +// GetMimeType returns value of MimeType field. +func (u *AccountUploadRingtoneRequest) GetMimeType() (value string) { + if u == nil { + return + } + return u.MimeType +} + +// AccountUploadRingtone invokes method account.uploadRingtone#831a83a2 returning error if any. +// +// See https://core.telegram.org/method/account.uploadRingtone for reference. +func (c *Client) AccountUploadRingtone(ctx context.Context, request *AccountUploadRingtoneRequest) (DocumentClass, error) { + var result DocumentBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.Document, nil +} diff --git a/tg/tl_account_upload_ringtone_slices_gen.go b/tg/tl_account_upload_ringtone_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_account_upload_ringtone_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_attach_menu_bot_gen.go b/tg/tl_attach_menu_bot_gen.go new file mode 100644 index 0000000000..d97f9e143f --- /dev/null +++ b/tg/tl_attach_menu_bot_gen.go @@ -0,0 +1,283 @@ +// 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{} +) + +// AttachMenuBot represents TL type `attachMenuBot#e93cb772`. +// +// See https://core.telegram.org/constructor/attachMenuBot for reference. +type AttachMenuBot struct { + // Flags field of AttachMenuBot. + Flags bin.Fields + // Inactive field of AttachMenuBot. + Inactive bool + // BotID field of AttachMenuBot. + BotID int64 + // ShortName field of AttachMenuBot. + ShortName string + // Icons field of AttachMenuBot. + Icons []AttachMenuBotIcon +} + +// AttachMenuBotTypeID is TL type id of AttachMenuBot. +const AttachMenuBotTypeID = 0xe93cb772 + +// Ensuring interfaces in compile-time for AttachMenuBot. +var ( + _ bin.Encoder = &AttachMenuBot{} + _ bin.Decoder = &AttachMenuBot{} + _ bin.BareEncoder = &AttachMenuBot{} + _ bin.BareDecoder = &AttachMenuBot{} +) + +func (a *AttachMenuBot) Zero() bool { + if a == nil { + return true + } + if !(a.Flags.Zero()) { + return false + } + if !(a.Inactive == false) { + return false + } + if !(a.BotID == 0) { + return false + } + if !(a.ShortName == "") { + return false + } + if !(a.Icons == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (a *AttachMenuBot) String() string { + if a == nil { + return "AttachMenuBot(nil)" + } + type Alias AttachMenuBot + return fmt.Sprintf("AttachMenuBot%+v", Alias(*a)) +} + +// FillFrom fills AttachMenuBot from given interface. +func (a *AttachMenuBot) FillFrom(from interface { + GetInactive() (value bool) + GetBotID() (value int64) + GetShortName() (value string) + GetIcons() (value []AttachMenuBotIcon) +}) { + a.Inactive = from.GetInactive() + a.BotID = from.GetBotID() + a.ShortName = from.GetShortName() + a.Icons = from.GetIcons() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AttachMenuBot) TypeID() uint32 { + return AttachMenuBotTypeID +} + +// TypeName returns name of type in TL schema. +func (*AttachMenuBot) TypeName() string { + return "attachMenuBot" +} + +// TypeInfo returns info about TL type. +func (a *AttachMenuBot) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "attachMenuBot", + ID: AttachMenuBotTypeID, + } + if a == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Inactive", + SchemaName: "inactive", + Null: !a.Flags.Has(0), + }, + { + Name: "BotID", + SchemaName: "bot_id", + }, + { + Name: "ShortName", + SchemaName: "short_name", + }, + { + Name: "Icons", + SchemaName: "icons", + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (a *AttachMenuBot) SetFlags() { + if !(a.Inactive == false) { + a.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (a *AttachMenuBot) Encode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode attachMenuBot#e93cb772 as nil") + } + b.PutID(AttachMenuBotTypeID) + return a.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (a *AttachMenuBot) EncodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode attachMenuBot#e93cb772 as nil") + } + a.SetFlags() + if err := a.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode attachMenuBot#e93cb772: field flags: %w", err) + } + b.PutLong(a.BotID) + b.PutString(a.ShortName) + b.PutVectorHeader(len(a.Icons)) + for idx, v := range a.Icons { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode attachMenuBot#e93cb772: field icons element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (a *AttachMenuBot) Decode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode attachMenuBot#e93cb772 to nil") + } + if err := b.ConsumeID(AttachMenuBotTypeID); err != nil { + return fmt.Errorf("unable to decode attachMenuBot#e93cb772: %w", err) + } + return a.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (a *AttachMenuBot) DecodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode attachMenuBot#e93cb772 to nil") + } + { + if err := a.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode attachMenuBot#e93cb772: field flags: %w", err) + } + } + a.Inactive = a.Flags.Has(0) + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode attachMenuBot#e93cb772: field bot_id: %w", err) + } + a.BotID = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode attachMenuBot#e93cb772: field short_name: %w", err) + } + a.ShortName = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode attachMenuBot#e93cb772: field icons: %w", err) + } + + if headerLen > 0 { + a.Icons = make([]AttachMenuBotIcon, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value AttachMenuBotIcon + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode attachMenuBot#e93cb772: field icons: %w", err) + } + a.Icons = append(a.Icons, value) + } + } + return nil +} + +// SetInactive sets value of Inactive conditional field. +func (a *AttachMenuBot) SetInactive(value bool) { + if value { + a.Flags.Set(0) + a.Inactive = true + } else { + a.Flags.Unset(0) + a.Inactive = false + } +} + +// GetInactive returns value of Inactive conditional field. +func (a *AttachMenuBot) GetInactive() (value bool) { + if a == nil { + return + } + return a.Flags.Has(0) +} + +// GetBotID returns value of BotID field. +func (a *AttachMenuBot) GetBotID() (value int64) { + if a == nil { + return + } + return a.BotID +} + +// GetShortName returns value of ShortName field. +func (a *AttachMenuBot) GetShortName() (value string) { + if a == nil { + return + } + return a.ShortName +} + +// GetIcons returns value of Icons field. +func (a *AttachMenuBot) GetIcons() (value []AttachMenuBotIcon) { + if a == nil { + return + } + return a.Icons +} diff --git a/tg/tl_attach_menu_bot_icon_color_gen.go b/tg/tl_attach_menu_bot_icon_color_gen.go new file mode 100644 index 0000000000..65f5461c6b --- /dev/null +++ b/tg/tl_attach_menu_bot_icon_color_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{} +) + +// AttachMenuBotIconColor represents TL type `attachMenuBotIconColor#4576f3f0`. +// +// See https://core.telegram.org/constructor/attachMenuBotIconColor for reference. +type AttachMenuBotIconColor struct { + // Name field of AttachMenuBotIconColor. + Name string + // Color field of AttachMenuBotIconColor. + Color int +} + +// AttachMenuBotIconColorTypeID is TL type id of AttachMenuBotIconColor. +const AttachMenuBotIconColorTypeID = 0x4576f3f0 + +// Ensuring interfaces in compile-time for AttachMenuBotIconColor. +var ( + _ bin.Encoder = &AttachMenuBotIconColor{} + _ bin.Decoder = &AttachMenuBotIconColor{} + _ bin.BareEncoder = &AttachMenuBotIconColor{} + _ bin.BareDecoder = &AttachMenuBotIconColor{} +) + +func (a *AttachMenuBotIconColor) Zero() bool { + if a == nil { + return true + } + if !(a.Name == "") { + return false + } + if !(a.Color == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (a *AttachMenuBotIconColor) String() string { + if a == nil { + return "AttachMenuBotIconColor(nil)" + } + type Alias AttachMenuBotIconColor + return fmt.Sprintf("AttachMenuBotIconColor%+v", Alias(*a)) +} + +// FillFrom fills AttachMenuBotIconColor from given interface. +func (a *AttachMenuBotIconColor) FillFrom(from interface { + GetName() (value string) + GetColor() (value int) +}) { + a.Name = from.GetName() + a.Color = from.GetColor() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AttachMenuBotIconColor) TypeID() uint32 { + return AttachMenuBotIconColorTypeID +} + +// TypeName returns name of type in TL schema. +func (*AttachMenuBotIconColor) TypeName() string { + return "attachMenuBotIconColor" +} + +// TypeInfo returns info about TL type. +func (a *AttachMenuBotIconColor) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "attachMenuBotIconColor", + ID: AttachMenuBotIconColorTypeID, + } + if a == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Name", + SchemaName: "name", + }, + { + Name: "Color", + SchemaName: "color", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (a *AttachMenuBotIconColor) Encode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode attachMenuBotIconColor#4576f3f0 as nil") + } + b.PutID(AttachMenuBotIconColorTypeID) + return a.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (a *AttachMenuBotIconColor) EncodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode attachMenuBotIconColor#4576f3f0 as nil") + } + b.PutString(a.Name) + b.PutInt(a.Color) + return nil +} + +// Decode implements bin.Decoder. +func (a *AttachMenuBotIconColor) Decode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode attachMenuBotIconColor#4576f3f0 to nil") + } + if err := b.ConsumeID(AttachMenuBotIconColorTypeID); err != nil { + return fmt.Errorf("unable to decode attachMenuBotIconColor#4576f3f0: %w", err) + } + return a.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (a *AttachMenuBotIconColor) DecodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode attachMenuBotIconColor#4576f3f0 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode attachMenuBotIconColor#4576f3f0: field name: %w", err) + } + a.Name = value + } + { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode attachMenuBotIconColor#4576f3f0: field color: %w", err) + } + a.Color = value + } + return nil +} + +// GetName returns value of Name field. +func (a *AttachMenuBotIconColor) GetName() (value string) { + if a == nil { + return + } + return a.Name +} + +// GetColor returns value of Color field. +func (a *AttachMenuBotIconColor) GetColor() (value int) { + if a == nil { + return + } + return a.Color +} diff --git a/tg/tl_attach_menu_bot_icon_color_slices_gen.go b/tg/tl_attach_menu_bot_icon_color_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_attach_menu_bot_icon_color_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_attach_menu_bot_icon_gen.go b/tg/tl_attach_menu_bot_icon_gen.go new file mode 100644 index 0000000000..0481148ad3 --- /dev/null +++ b/tg/tl_attach_menu_bot_icon_gen.go @@ -0,0 +1,279 @@ +// 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{} +) + +// AttachMenuBotIcon represents TL type `attachMenuBotIcon#b2a7386b`. +// +// See https://core.telegram.org/constructor/attachMenuBotIcon for reference. +type AttachMenuBotIcon struct { + // Flags field of AttachMenuBotIcon. + Flags bin.Fields + // Name field of AttachMenuBotIcon. + Name string + // Icon field of AttachMenuBotIcon. + Icon DocumentClass + // Colors field of AttachMenuBotIcon. + // + // Use SetColors and GetColors helpers. + Colors []AttachMenuBotIconColor +} + +// AttachMenuBotIconTypeID is TL type id of AttachMenuBotIcon. +const AttachMenuBotIconTypeID = 0xb2a7386b + +// Ensuring interfaces in compile-time for AttachMenuBotIcon. +var ( + _ bin.Encoder = &AttachMenuBotIcon{} + _ bin.Decoder = &AttachMenuBotIcon{} + _ bin.BareEncoder = &AttachMenuBotIcon{} + _ bin.BareDecoder = &AttachMenuBotIcon{} +) + +func (a *AttachMenuBotIcon) Zero() bool { + if a == nil { + return true + } + if !(a.Flags.Zero()) { + return false + } + if !(a.Name == "") { + return false + } + if !(a.Icon == nil) { + return false + } + if !(a.Colors == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (a *AttachMenuBotIcon) String() string { + if a == nil { + return "AttachMenuBotIcon(nil)" + } + type Alias AttachMenuBotIcon + return fmt.Sprintf("AttachMenuBotIcon%+v", Alias(*a)) +} + +// FillFrom fills AttachMenuBotIcon from given interface. +func (a *AttachMenuBotIcon) FillFrom(from interface { + GetName() (value string) + GetIcon() (value DocumentClass) + GetColors() (value []AttachMenuBotIconColor, ok bool) +}) { + a.Name = from.GetName() + a.Icon = from.GetIcon() + if val, ok := from.GetColors(); ok { + a.Colors = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AttachMenuBotIcon) TypeID() uint32 { + return AttachMenuBotIconTypeID +} + +// TypeName returns name of type in TL schema. +func (*AttachMenuBotIcon) TypeName() string { + return "attachMenuBotIcon" +} + +// TypeInfo returns info about TL type. +func (a *AttachMenuBotIcon) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "attachMenuBotIcon", + ID: AttachMenuBotIconTypeID, + } + if a == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Name", + SchemaName: "name", + }, + { + Name: "Icon", + SchemaName: "icon", + }, + { + Name: "Colors", + SchemaName: "colors", + Null: !a.Flags.Has(0), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (a *AttachMenuBotIcon) SetFlags() { + if !(a.Colors == nil) { + a.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (a *AttachMenuBotIcon) Encode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode attachMenuBotIcon#b2a7386b as nil") + } + b.PutID(AttachMenuBotIconTypeID) + return a.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (a *AttachMenuBotIcon) EncodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode attachMenuBotIcon#b2a7386b as nil") + } + a.SetFlags() + if err := a.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode attachMenuBotIcon#b2a7386b: field flags: %w", err) + } + b.PutString(a.Name) + if a.Icon == nil { + return fmt.Errorf("unable to encode attachMenuBotIcon#b2a7386b: field icon is nil") + } + if err := a.Icon.Encode(b); err != nil { + return fmt.Errorf("unable to encode attachMenuBotIcon#b2a7386b: field icon: %w", err) + } + if a.Flags.Has(0) { + b.PutVectorHeader(len(a.Colors)) + for idx, v := range a.Colors { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode attachMenuBotIcon#b2a7386b: field colors element with index %d: %w", idx, err) + } + } + } + return nil +} + +// Decode implements bin.Decoder. +func (a *AttachMenuBotIcon) Decode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode attachMenuBotIcon#b2a7386b to nil") + } + if err := b.ConsumeID(AttachMenuBotIconTypeID); err != nil { + return fmt.Errorf("unable to decode attachMenuBotIcon#b2a7386b: %w", err) + } + return a.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (a *AttachMenuBotIcon) DecodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode attachMenuBotIcon#b2a7386b to nil") + } + { + if err := a.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode attachMenuBotIcon#b2a7386b: field flags: %w", err) + } + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode attachMenuBotIcon#b2a7386b: field name: %w", err) + } + a.Name = value + } + { + value, err := DecodeDocument(b) + if err != nil { + return fmt.Errorf("unable to decode attachMenuBotIcon#b2a7386b: field icon: %w", err) + } + a.Icon = value + } + if a.Flags.Has(0) { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode attachMenuBotIcon#b2a7386b: field colors: %w", err) + } + + if headerLen > 0 { + a.Colors = make([]AttachMenuBotIconColor, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value AttachMenuBotIconColor + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode attachMenuBotIcon#b2a7386b: field colors: %w", err) + } + a.Colors = append(a.Colors, value) + } + } + return nil +} + +// GetName returns value of Name field. +func (a *AttachMenuBotIcon) GetName() (value string) { + if a == nil { + return + } + return a.Name +} + +// GetIcon returns value of Icon field. +func (a *AttachMenuBotIcon) GetIcon() (value DocumentClass) { + if a == nil { + return + } + return a.Icon +} + +// SetColors sets value of Colors conditional field. +func (a *AttachMenuBotIcon) SetColors(value []AttachMenuBotIconColor) { + a.Flags.Set(0) + a.Colors = value +} + +// GetColors returns value of Colors conditional field and +// boolean which is true if field was set. +func (a *AttachMenuBotIcon) GetColors() (value []AttachMenuBotIconColor, ok bool) { + if a == nil { + return + } + if !a.Flags.Has(0) { + return value, false + } + return a.Colors, true +} + +// GetIconAsNotEmpty returns mapped value of Icon field. +func (a *AttachMenuBotIcon) GetIconAsNotEmpty() (*Document, bool) { + return a.Icon.AsNotEmpty() +} diff --git a/tg/tl_attach_menu_bot_icon_slices_gen.go b/tg/tl_attach_menu_bot_icon_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_attach_menu_bot_icon_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_attach_menu_bot_slices_gen.go b/tg/tl_attach_menu_bot_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_attach_menu_bot_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_attach_menu_bots_bot_gen.go b/tg/tl_attach_menu_bots_bot_gen.go new file mode 100644 index 0000000000..2d400cc75d --- /dev/null +++ b/tg/tl_attach_menu_bots_bot_gen.go @@ -0,0 +1,211 @@ +// 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{} +) + +// AttachMenuBotsBot represents TL type `attachMenuBotsBot#93bf667f`. +// +// See https://core.telegram.org/constructor/attachMenuBotsBot for reference. +type AttachMenuBotsBot struct { + // Bot field of AttachMenuBotsBot. + Bot AttachMenuBot + // Users field of AttachMenuBotsBot. + Users []UserClass +} + +// AttachMenuBotsBotTypeID is TL type id of AttachMenuBotsBot. +const AttachMenuBotsBotTypeID = 0x93bf667f + +// Ensuring interfaces in compile-time for AttachMenuBotsBot. +var ( + _ bin.Encoder = &AttachMenuBotsBot{} + _ bin.Decoder = &AttachMenuBotsBot{} + _ bin.BareEncoder = &AttachMenuBotsBot{} + _ bin.BareDecoder = &AttachMenuBotsBot{} +) + +func (a *AttachMenuBotsBot) Zero() bool { + if a == nil { + return true + } + if !(a.Bot.Zero()) { + return false + } + if !(a.Users == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (a *AttachMenuBotsBot) String() string { + if a == nil { + return "AttachMenuBotsBot(nil)" + } + type Alias AttachMenuBotsBot + return fmt.Sprintf("AttachMenuBotsBot%+v", Alias(*a)) +} + +// FillFrom fills AttachMenuBotsBot from given interface. +func (a *AttachMenuBotsBot) FillFrom(from interface { + GetBot() (value AttachMenuBot) + GetUsers() (value []UserClass) +}) { + a.Bot = from.GetBot() + a.Users = from.GetUsers() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AttachMenuBotsBot) TypeID() uint32 { + return AttachMenuBotsBotTypeID +} + +// TypeName returns name of type in TL schema. +func (*AttachMenuBotsBot) TypeName() string { + return "attachMenuBotsBot" +} + +// TypeInfo returns info about TL type. +func (a *AttachMenuBotsBot) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "attachMenuBotsBot", + ID: AttachMenuBotsBotTypeID, + } + if a == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Bot", + SchemaName: "bot", + }, + { + Name: "Users", + SchemaName: "users", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (a *AttachMenuBotsBot) Encode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode attachMenuBotsBot#93bf667f as nil") + } + b.PutID(AttachMenuBotsBotTypeID) + return a.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (a *AttachMenuBotsBot) EncodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode attachMenuBotsBot#93bf667f as nil") + } + if err := a.Bot.Encode(b); err != nil { + return fmt.Errorf("unable to encode attachMenuBotsBot#93bf667f: field bot: %w", err) + } + b.PutVectorHeader(len(a.Users)) + for idx, v := range a.Users { + if v == nil { + return fmt.Errorf("unable to encode attachMenuBotsBot#93bf667f: field users element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode attachMenuBotsBot#93bf667f: field users element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (a *AttachMenuBotsBot) Decode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode attachMenuBotsBot#93bf667f to nil") + } + if err := b.ConsumeID(AttachMenuBotsBotTypeID); err != nil { + return fmt.Errorf("unable to decode attachMenuBotsBot#93bf667f: %w", err) + } + return a.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (a *AttachMenuBotsBot) DecodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode attachMenuBotsBot#93bf667f to nil") + } + { + if err := a.Bot.Decode(b); err != nil { + return fmt.Errorf("unable to decode attachMenuBotsBot#93bf667f: field bot: %w", err) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode attachMenuBotsBot#93bf667f: field users: %w", err) + } + + if headerLen > 0 { + a.Users = make([]UserClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeUser(b) + if err != nil { + return fmt.Errorf("unable to decode attachMenuBotsBot#93bf667f: field users: %w", err) + } + a.Users = append(a.Users, value) + } + } + return nil +} + +// GetBot returns value of Bot field. +func (a *AttachMenuBotsBot) GetBot() (value AttachMenuBot) { + if a == nil { + return + } + return a.Bot +} + +// GetUsers returns value of Users field. +func (a *AttachMenuBotsBot) GetUsers() (value []UserClass) { + if a == nil { + return + } + return a.Users +} + +// MapUsers returns field Users wrapped in UserClassArray helper. +func (a *AttachMenuBotsBot) MapUsers() (value UserClassArray) { + return UserClassArray(a.Users) +} diff --git a/tg/tl_attach_menu_bots_bot_slices_gen.go b/tg/tl_attach_menu_bots_bot_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_attach_menu_bots_bot_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_attach_menu_bots_gen.go b/tg/tl_attach_menu_bots_gen.go new file mode 100644 index 0000000000..9713391a8c --- /dev/null +++ b/tg/tl_attach_menu_bots_gen.go @@ -0,0 +1,460 @@ +// 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{} +) + +// AttachMenuBotsNotModified represents TL type `attachMenuBotsNotModified#f1d88a5c`. +// +// See https://core.telegram.org/constructor/attachMenuBotsNotModified for reference. +type AttachMenuBotsNotModified struct { +} + +// AttachMenuBotsNotModifiedTypeID is TL type id of AttachMenuBotsNotModified. +const AttachMenuBotsNotModifiedTypeID = 0xf1d88a5c + +// construct implements constructor of AttachMenuBotsClass. +func (a AttachMenuBotsNotModified) construct() AttachMenuBotsClass { return &a } + +// Ensuring interfaces in compile-time for AttachMenuBotsNotModified. +var ( + _ bin.Encoder = &AttachMenuBotsNotModified{} + _ bin.Decoder = &AttachMenuBotsNotModified{} + _ bin.BareEncoder = &AttachMenuBotsNotModified{} + _ bin.BareDecoder = &AttachMenuBotsNotModified{} + + _ AttachMenuBotsClass = &AttachMenuBotsNotModified{} +) + +func (a *AttachMenuBotsNotModified) Zero() bool { + if a == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (a *AttachMenuBotsNotModified) String() string { + if a == nil { + return "AttachMenuBotsNotModified(nil)" + } + type Alias AttachMenuBotsNotModified + return fmt.Sprintf("AttachMenuBotsNotModified%+v", Alias(*a)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AttachMenuBotsNotModified) TypeID() uint32 { + return AttachMenuBotsNotModifiedTypeID +} + +// TypeName returns name of type in TL schema. +func (*AttachMenuBotsNotModified) TypeName() string { + return "attachMenuBotsNotModified" +} + +// TypeInfo returns info about TL type. +func (a *AttachMenuBotsNotModified) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "attachMenuBotsNotModified", + ID: AttachMenuBotsNotModifiedTypeID, + } + if a == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (a *AttachMenuBotsNotModified) Encode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode attachMenuBotsNotModified#f1d88a5c as nil") + } + b.PutID(AttachMenuBotsNotModifiedTypeID) + return a.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (a *AttachMenuBotsNotModified) EncodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode attachMenuBotsNotModified#f1d88a5c as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (a *AttachMenuBotsNotModified) Decode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode attachMenuBotsNotModified#f1d88a5c to nil") + } + if err := b.ConsumeID(AttachMenuBotsNotModifiedTypeID); err != nil { + return fmt.Errorf("unable to decode attachMenuBotsNotModified#f1d88a5c: %w", err) + } + return a.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (a *AttachMenuBotsNotModified) DecodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode attachMenuBotsNotModified#f1d88a5c to nil") + } + return nil +} + +// AttachMenuBots represents TL type `attachMenuBots#3c4301c0`. +// +// See https://core.telegram.org/constructor/attachMenuBots for reference. +type AttachMenuBots struct { + // Hash field of AttachMenuBots. + Hash int64 + // Bots field of AttachMenuBots. + Bots []AttachMenuBot + // Users field of AttachMenuBots. + Users []UserClass +} + +// AttachMenuBotsTypeID is TL type id of AttachMenuBots. +const AttachMenuBotsTypeID = 0x3c4301c0 + +// construct implements constructor of AttachMenuBotsClass. +func (a AttachMenuBots) construct() AttachMenuBotsClass { return &a } + +// Ensuring interfaces in compile-time for AttachMenuBots. +var ( + _ bin.Encoder = &AttachMenuBots{} + _ bin.Decoder = &AttachMenuBots{} + _ bin.BareEncoder = &AttachMenuBots{} + _ bin.BareDecoder = &AttachMenuBots{} + + _ AttachMenuBotsClass = &AttachMenuBots{} +) + +func (a *AttachMenuBots) Zero() bool { + if a == nil { + return true + } + if !(a.Hash == 0) { + return false + } + if !(a.Bots == nil) { + return false + } + if !(a.Users == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (a *AttachMenuBots) String() string { + if a == nil { + return "AttachMenuBots(nil)" + } + type Alias AttachMenuBots + return fmt.Sprintf("AttachMenuBots%+v", Alias(*a)) +} + +// FillFrom fills AttachMenuBots from given interface. +func (a *AttachMenuBots) FillFrom(from interface { + GetHash() (value int64) + GetBots() (value []AttachMenuBot) + GetUsers() (value []UserClass) +}) { + a.Hash = from.GetHash() + a.Bots = from.GetBots() + a.Users = from.GetUsers() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AttachMenuBots) TypeID() uint32 { + return AttachMenuBotsTypeID +} + +// TypeName returns name of type in TL schema. +func (*AttachMenuBots) TypeName() string { + return "attachMenuBots" +} + +// TypeInfo returns info about TL type. +func (a *AttachMenuBots) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "attachMenuBots", + ID: AttachMenuBotsTypeID, + } + if a == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Hash", + SchemaName: "hash", + }, + { + Name: "Bots", + SchemaName: "bots", + }, + { + Name: "Users", + SchemaName: "users", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (a *AttachMenuBots) Encode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode attachMenuBots#3c4301c0 as nil") + } + b.PutID(AttachMenuBotsTypeID) + return a.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (a *AttachMenuBots) EncodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode attachMenuBots#3c4301c0 as nil") + } + b.PutLong(a.Hash) + b.PutVectorHeader(len(a.Bots)) + for idx, v := range a.Bots { + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode attachMenuBots#3c4301c0: field bots element with index %d: %w", idx, err) + } + } + b.PutVectorHeader(len(a.Users)) + for idx, v := range a.Users { + if v == nil { + return fmt.Errorf("unable to encode attachMenuBots#3c4301c0: field users element with index %d is nil", idx) + } + if err := v.Encode(b); err != nil { + return fmt.Errorf("unable to encode attachMenuBots#3c4301c0: field users element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (a *AttachMenuBots) Decode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode attachMenuBots#3c4301c0 to nil") + } + if err := b.ConsumeID(AttachMenuBotsTypeID); err != nil { + return fmt.Errorf("unable to decode attachMenuBots#3c4301c0: %w", err) + } + return a.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (a *AttachMenuBots) DecodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode attachMenuBots#3c4301c0 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode attachMenuBots#3c4301c0: field hash: %w", err) + } + a.Hash = value + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode attachMenuBots#3c4301c0: field bots: %w", err) + } + + if headerLen > 0 { + a.Bots = make([]AttachMenuBot, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value AttachMenuBot + if err := value.Decode(b); err != nil { + return fmt.Errorf("unable to decode attachMenuBots#3c4301c0: field bots: %w", err) + } + a.Bots = append(a.Bots, value) + } + } + { + headerLen, err := b.VectorHeader() + if err != nil { + return fmt.Errorf("unable to decode attachMenuBots#3c4301c0: field users: %w", err) + } + + if headerLen > 0 { + a.Users = make([]UserClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodeUser(b) + if err != nil { + return fmt.Errorf("unable to decode attachMenuBots#3c4301c0: field users: %w", err) + } + a.Users = append(a.Users, value) + } + } + return nil +} + +// GetHash returns value of Hash field. +func (a *AttachMenuBots) GetHash() (value int64) { + if a == nil { + return + } + return a.Hash +} + +// GetBots returns value of Bots field. +func (a *AttachMenuBots) GetBots() (value []AttachMenuBot) { + if a == nil { + return + } + return a.Bots +} + +// GetUsers returns value of Users field. +func (a *AttachMenuBots) GetUsers() (value []UserClass) { + if a == nil { + return + } + return a.Users +} + +// MapUsers returns field Users wrapped in UserClassArray helper. +func (a *AttachMenuBots) MapUsers() (value UserClassArray) { + return UserClassArray(a.Users) +} + +// AttachMenuBotsClassName is schema name of AttachMenuBotsClass. +const AttachMenuBotsClassName = "AttachMenuBots" + +// AttachMenuBotsClass represents AttachMenuBots generic type. +// +// See https://core.telegram.org/type/AttachMenuBots for reference. +// +// Example: +// g, err := tg.DecodeAttachMenuBots(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.AttachMenuBotsNotModified: // attachMenuBotsNotModified#f1d88a5c +// case *tg.AttachMenuBots: // attachMenuBots#3c4301c0 +// default: panic(v) +// } +type AttachMenuBotsClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() AttachMenuBotsClass + + // 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 AttachMenuBotsClass to AttachMenuBots. + AsModified() (*AttachMenuBots, bool) +} + +// AsModified tries to map AttachMenuBotsNotModified to AttachMenuBots. +func (a *AttachMenuBotsNotModified) AsModified() (*AttachMenuBots, bool) { + return nil, false +} + +// AsModified tries to map AttachMenuBots to AttachMenuBots. +func (a *AttachMenuBots) AsModified() (*AttachMenuBots, bool) { + return a, true +} + +// DecodeAttachMenuBots implements binary de-serialization for AttachMenuBotsClass. +func DecodeAttachMenuBots(buf *bin.Buffer) (AttachMenuBotsClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case AttachMenuBotsNotModifiedTypeID: + // Decoding attachMenuBotsNotModified#f1d88a5c. + v := AttachMenuBotsNotModified{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode AttachMenuBotsClass: %w", err) + } + return &v, nil + case AttachMenuBotsTypeID: + // Decoding attachMenuBots#3c4301c0. + v := AttachMenuBots{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode AttachMenuBotsClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode AttachMenuBotsClass: %w", bin.NewUnexpectedID(id)) + } +} + +// AttachMenuBots boxes the AttachMenuBotsClass providing a helper. +type AttachMenuBotsBox struct { + AttachMenuBots AttachMenuBotsClass +} + +// Decode implements bin.Decoder for AttachMenuBotsBox. +func (b *AttachMenuBotsBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode AttachMenuBotsBox to nil") + } + v, err := DecodeAttachMenuBots(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.AttachMenuBots = v + return nil +} + +// Encode implements bin.Encode for AttachMenuBotsBox. +func (b *AttachMenuBotsBox) Encode(buf *bin.Buffer) error { + if b == nil || b.AttachMenuBots == nil { + return fmt.Errorf("unable to encode AttachMenuBotsClass as nil") + } + return b.AttachMenuBots.Encode(buf) +} diff --git a/tg/tl_attach_menu_bots_slices_gen.go b/tg/tl_attach_menu_bots_slices_gen.go new file mode 100644 index 0000000000..10cfec8ab6 --- /dev/null +++ b/tg/tl_attach_menu_bots_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{} +) + +// AttachMenuBotsClassArray is adapter for slice of AttachMenuBotsClass. +type AttachMenuBotsClassArray []AttachMenuBotsClass + +// Sort sorts slice of AttachMenuBotsClass. +func (s AttachMenuBotsClassArray) Sort(less func(a, b AttachMenuBotsClass) bool) AttachMenuBotsClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of AttachMenuBotsClass. +func (s AttachMenuBotsClassArray) SortStable(less func(a, b AttachMenuBotsClass) bool) AttachMenuBotsClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of AttachMenuBotsClass. +func (s AttachMenuBotsClassArray) Retain(keep func(x AttachMenuBotsClass) bool) AttachMenuBotsClassArray { + 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 AttachMenuBotsClassArray) First() (v AttachMenuBotsClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s AttachMenuBotsClassArray) Last() (v AttachMenuBotsClass, 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 *AttachMenuBotsClassArray) PopFirst() (v AttachMenuBotsClass, 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 AttachMenuBotsClass + 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 *AttachMenuBotsClassArray) Pop() (v AttachMenuBotsClass, 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 +} + +// AsAttachMenuBots returns copy with only AttachMenuBots constructors. +func (s AttachMenuBotsClassArray) AsAttachMenuBots() (to AttachMenuBotsArray) { + for _, elem := range s { + value, ok := elem.(*AttachMenuBots) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AppendOnlyModified appends only Modified constructors to +// given slice. +func (s AttachMenuBotsClassArray) AppendOnlyModified(to []*AttachMenuBots) []*AttachMenuBots { + 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 AttachMenuBotsClassArray) AsModified() (to []*AttachMenuBots) { + return s.AppendOnlyModified(to) +} + +// FirstAsModified returns first element of slice (if exists). +func (s AttachMenuBotsClassArray) FirstAsModified() (v *AttachMenuBots, ok bool) { + value, ok := s.First() + if !ok { + return + } + return value.AsModified() +} + +// LastAsModified returns last element of slice (if exists). +func (s AttachMenuBotsClassArray) LastAsModified() (v *AttachMenuBots, ok bool) { + value, ok := s.Last() + if !ok { + return + } + return value.AsModified() +} + +// PopFirstAsModified returns element of slice (if exists). +func (s *AttachMenuBotsClassArray) PopFirstAsModified() (v *AttachMenuBots, ok bool) { + value, ok := s.PopFirst() + if !ok { + return + } + return value.AsModified() +} + +// PopAsModified returns element of slice (if exists). +func (s *AttachMenuBotsClassArray) PopAsModified() (v *AttachMenuBots, ok bool) { + value, ok := s.Pop() + if !ok { + return + } + return value.AsModified() +} + +// AttachMenuBotsArray is adapter for slice of AttachMenuBots. +type AttachMenuBotsArray []AttachMenuBots + +// Sort sorts slice of AttachMenuBots. +func (s AttachMenuBotsArray) Sort(less func(a, b AttachMenuBots) bool) AttachMenuBotsArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of AttachMenuBots. +func (s AttachMenuBotsArray) SortStable(less func(a, b AttachMenuBots) bool) AttachMenuBotsArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of AttachMenuBots. +func (s AttachMenuBotsArray) Retain(keep func(x AttachMenuBots) bool) AttachMenuBotsArray { + 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 AttachMenuBotsArray) First() (v AttachMenuBots, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s AttachMenuBotsArray) Last() (v AttachMenuBots, 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 *AttachMenuBotsArray) PopFirst() (v AttachMenuBots, 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 AttachMenuBots + 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 *AttachMenuBotsArray) Pop() (v AttachMenuBots, 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_bot_info_gen.go b/tg/tl_bot_info_gen.go index d9d9eb2338..bbc1c945f3 100644 --- a/tg/tl_bot_info_gen.go +++ b/tg/tl_bot_info_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// BotInfo represents TL type `botInfo#1b74b335`. +// BotInfo represents TL type `botInfo#e4169b5d`. // Info about bots (available bot commands, etc) // // See https://core.telegram.org/constructor/botInfo for reference. @@ -42,10 +42,12 @@ type BotInfo struct { Description string // Bot commands that can be used in the chat Commands []BotCommand + // MenuButton field of BotInfo. + MenuButton BotMenuButtonClass } // BotInfoTypeID is TL type id of BotInfo. -const BotInfoTypeID = 0x1b74b335 +const BotInfoTypeID = 0xe4169b5d // Ensuring interfaces in compile-time for BotInfo. var ( @@ -68,6 +70,9 @@ func (b *BotInfo) Zero() bool { if !(b.Commands == nil) { return false } + if !(b.MenuButton == nil) { + return false + } return true } @@ -86,10 +91,12 @@ func (b *BotInfo) FillFrom(from interface { GetUserID() (value int64) GetDescription() (value string) GetCommands() (value []BotCommand) + GetMenuButton() (value BotMenuButtonClass) }) { b.UserID = from.GetUserID() b.Description = from.GetDescription() b.Commands = from.GetCommands() + b.MenuButton = from.GetMenuButton() } // TypeID returns type id in TL schema. @@ -127,6 +134,10 @@ func (b *BotInfo) TypeInfo() tdp.Type { Name: "Commands", SchemaName: "commands", }, + { + Name: "MenuButton", + SchemaName: "menu_button", + }, } return typ } @@ -134,7 +145,7 @@ func (b *BotInfo) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (b *BotInfo) Encode(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't encode botInfo#1b74b335 as nil") + return fmt.Errorf("can't encode botInfo#e4169b5d as nil") } buf.PutID(BotInfoTypeID) return b.EncodeBare(buf) @@ -143,26 +154,32 @@ func (b *BotInfo) Encode(buf *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (b *BotInfo) EncodeBare(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't encode botInfo#1b74b335 as nil") + return fmt.Errorf("can't encode botInfo#e4169b5d as nil") } buf.PutLong(b.UserID) buf.PutString(b.Description) buf.PutVectorHeader(len(b.Commands)) for idx, v := range b.Commands { if err := v.Encode(buf); err != nil { - return fmt.Errorf("unable to encode botInfo#1b74b335: field commands element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode botInfo#e4169b5d: field commands element with index %d: %w", idx, err) } } + if b.MenuButton == nil { + return fmt.Errorf("unable to encode botInfo#e4169b5d: field menu_button is nil") + } + if err := b.MenuButton.Encode(buf); err != nil { + return fmt.Errorf("unable to encode botInfo#e4169b5d: field menu_button: %w", err) + } return nil } // Decode implements bin.Decoder. func (b *BotInfo) Decode(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't decode botInfo#1b74b335 to nil") + return fmt.Errorf("can't decode botInfo#e4169b5d to nil") } if err := buf.ConsumeID(BotInfoTypeID); err != nil { - return fmt.Errorf("unable to decode botInfo#1b74b335: %w", err) + return fmt.Errorf("unable to decode botInfo#e4169b5d: %w", err) } return b.DecodeBare(buf) } @@ -170,26 +187,26 @@ func (b *BotInfo) Decode(buf *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (b *BotInfo) DecodeBare(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't decode botInfo#1b74b335 to nil") + return fmt.Errorf("can't decode botInfo#e4169b5d to nil") } { value, err := buf.Long() if err != nil { - return fmt.Errorf("unable to decode botInfo#1b74b335: field user_id: %w", err) + return fmt.Errorf("unable to decode botInfo#e4169b5d: field user_id: %w", err) } b.UserID = value } { value, err := buf.String() if err != nil { - return fmt.Errorf("unable to decode botInfo#1b74b335: field description: %w", err) + return fmt.Errorf("unable to decode botInfo#e4169b5d: field description: %w", err) } b.Description = value } { headerLen, err := buf.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode botInfo#1b74b335: field commands: %w", err) + return fmt.Errorf("unable to decode botInfo#e4169b5d: field commands: %w", err) } if headerLen > 0 { @@ -198,11 +215,18 @@ func (b *BotInfo) DecodeBare(buf *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value BotCommand if err := value.Decode(buf); err != nil { - return fmt.Errorf("unable to decode botInfo#1b74b335: field commands: %w", err) + return fmt.Errorf("unable to decode botInfo#e4169b5d: field commands: %w", err) } b.Commands = append(b.Commands, value) } } + { + value, err := DecodeBotMenuButton(buf) + if err != nil { + return fmt.Errorf("unable to decode botInfo#e4169b5d: field menu_button: %w", err) + } + b.MenuButton = value + } return nil } @@ -229,3 +253,11 @@ func (b *BotInfo) GetCommands() (value []BotCommand) { } return b.Commands } + +// GetMenuButton returns value of MenuButton field. +func (b *BotInfo) GetMenuButton() (value BotMenuButtonClass) { + if b == nil { + return + } + return b.MenuButton +} diff --git a/tg/tl_bot_menu_button_gen.go b/tg/tl_bot_menu_button_gen.go new file mode 100644 index 0000000000..57b494ce31 --- /dev/null +++ b/tg/tl_bot_menu_button_gen.go @@ -0,0 +1,491 @@ +// 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{} +) + +// BotMenuButtonDefault represents TL type `botMenuButtonDefault#7533a588`. +// +// See https://core.telegram.org/constructor/botMenuButtonDefault for reference. +type BotMenuButtonDefault struct { +} + +// BotMenuButtonDefaultTypeID is TL type id of BotMenuButtonDefault. +const BotMenuButtonDefaultTypeID = 0x7533a588 + +// construct implements constructor of BotMenuButtonClass. +func (b BotMenuButtonDefault) construct() BotMenuButtonClass { return &b } + +// Ensuring interfaces in compile-time for BotMenuButtonDefault. +var ( + _ bin.Encoder = &BotMenuButtonDefault{} + _ bin.Decoder = &BotMenuButtonDefault{} + _ bin.BareEncoder = &BotMenuButtonDefault{} + _ bin.BareDecoder = &BotMenuButtonDefault{} + + _ BotMenuButtonClass = &BotMenuButtonDefault{} +) + +func (b *BotMenuButtonDefault) Zero() bool { + if b == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (b *BotMenuButtonDefault) String() string { + if b == nil { + return "BotMenuButtonDefault(nil)" + } + type Alias BotMenuButtonDefault + return fmt.Sprintf("BotMenuButtonDefault%+v", Alias(*b)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*BotMenuButtonDefault) TypeID() uint32 { + return BotMenuButtonDefaultTypeID +} + +// TypeName returns name of type in TL schema. +func (*BotMenuButtonDefault) TypeName() string { + return "botMenuButtonDefault" +} + +// TypeInfo returns info about TL type. +func (b *BotMenuButtonDefault) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "botMenuButtonDefault", + ID: BotMenuButtonDefaultTypeID, + } + if b == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (b *BotMenuButtonDefault) Encode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode botMenuButtonDefault#7533a588 as nil") + } + buf.PutID(BotMenuButtonDefaultTypeID) + return b.EncodeBare(buf) +} + +// EncodeBare implements bin.BareEncoder. +func (b *BotMenuButtonDefault) EncodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode botMenuButtonDefault#7533a588 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (b *BotMenuButtonDefault) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode botMenuButtonDefault#7533a588 to nil") + } + if err := buf.ConsumeID(BotMenuButtonDefaultTypeID); err != nil { + return fmt.Errorf("unable to decode botMenuButtonDefault#7533a588: %w", err) + } + return b.DecodeBare(buf) +} + +// DecodeBare implements bin.BareDecoder. +func (b *BotMenuButtonDefault) DecodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode botMenuButtonDefault#7533a588 to nil") + } + return nil +} + +// BotMenuButtonCommands represents TL type `botMenuButtonCommands#4258c205`. +// +// See https://core.telegram.org/constructor/botMenuButtonCommands for reference. +type BotMenuButtonCommands struct { +} + +// BotMenuButtonCommandsTypeID is TL type id of BotMenuButtonCommands. +const BotMenuButtonCommandsTypeID = 0x4258c205 + +// construct implements constructor of BotMenuButtonClass. +func (b BotMenuButtonCommands) construct() BotMenuButtonClass { return &b } + +// Ensuring interfaces in compile-time for BotMenuButtonCommands. +var ( + _ bin.Encoder = &BotMenuButtonCommands{} + _ bin.Decoder = &BotMenuButtonCommands{} + _ bin.BareEncoder = &BotMenuButtonCommands{} + _ bin.BareDecoder = &BotMenuButtonCommands{} + + _ BotMenuButtonClass = &BotMenuButtonCommands{} +) + +func (b *BotMenuButtonCommands) Zero() bool { + if b == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (b *BotMenuButtonCommands) String() string { + if b == nil { + return "BotMenuButtonCommands(nil)" + } + type Alias BotMenuButtonCommands + return fmt.Sprintf("BotMenuButtonCommands%+v", Alias(*b)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*BotMenuButtonCommands) TypeID() uint32 { + return BotMenuButtonCommandsTypeID +} + +// TypeName returns name of type in TL schema. +func (*BotMenuButtonCommands) TypeName() string { + return "botMenuButtonCommands" +} + +// TypeInfo returns info about TL type. +func (b *BotMenuButtonCommands) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "botMenuButtonCommands", + ID: BotMenuButtonCommandsTypeID, + } + if b == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (b *BotMenuButtonCommands) Encode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode botMenuButtonCommands#4258c205 as nil") + } + buf.PutID(BotMenuButtonCommandsTypeID) + return b.EncodeBare(buf) +} + +// EncodeBare implements bin.BareEncoder. +func (b *BotMenuButtonCommands) EncodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode botMenuButtonCommands#4258c205 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (b *BotMenuButtonCommands) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode botMenuButtonCommands#4258c205 to nil") + } + if err := buf.ConsumeID(BotMenuButtonCommandsTypeID); err != nil { + return fmt.Errorf("unable to decode botMenuButtonCommands#4258c205: %w", err) + } + return b.DecodeBare(buf) +} + +// DecodeBare implements bin.BareDecoder. +func (b *BotMenuButtonCommands) DecodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode botMenuButtonCommands#4258c205 to nil") + } + return nil +} + +// BotMenuButton represents TL type `botMenuButton#c7b57ce6`. +// +// See https://core.telegram.org/constructor/botMenuButton for reference. +type BotMenuButton struct { + // Text field of BotMenuButton. + Text string + // URL field of BotMenuButton. + URL string +} + +// BotMenuButtonTypeID is TL type id of BotMenuButton. +const BotMenuButtonTypeID = 0xc7b57ce6 + +// construct implements constructor of BotMenuButtonClass. +func (b BotMenuButton) construct() BotMenuButtonClass { return &b } + +// Ensuring interfaces in compile-time for BotMenuButton. +var ( + _ bin.Encoder = &BotMenuButton{} + _ bin.Decoder = &BotMenuButton{} + _ bin.BareEncoder = &BotMenuButton{} + _ bin.BareDecoder = &BotMenuButton{} + + _ BotMenuButtonClass = &BotMenuButton{} +) + +func (b *BotMenuButton) Zero() bool { + if b == nil { + return true + } + if !(b.Text == "") { + return false + } + if !(b.URL == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (b *BotMenuButton) String() string { + if b == nil { + return "BotMenuButton(nil)" + } + type Alias BotMenuButton + return fmt.Sprintf("BotMenuButton%+v", Alias(*b)) +} + +// FillFrom fills BotMenuButton from given interface. +func (b *BotMenuButton) FillFrom(from interface { + GetText() (value string) + GetURL() (value string) +}) { + b.Text = from.GetText() + b.URL = from.GetURL() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*BotMenuButton) TypeID() uint32 { + return BotMenuButtonTypeID +} + +// TypeName returns name of type in TL schema. +func (*BotMenuButton) TypeName() string { + return "botMenuButton" +} + +// TypeInfo returns info about TL type. +func (b *BotMenuButton) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "botMenuButton", + ID: BotMenuButtonTypeID, + } + if b == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Text", + SchemaName: "text", + }, + { + Name: "URL", + SchemaName: "url", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (b *BotMenuButton) Encode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode botMenuButton#c7b57ce6 as nil") + } + buf.PutID(BotMenuButtonTypeID) + return b.EncodeBare(buf) +} + +// EncodeBare implements bin.BareEncoder. +func (b *BotMenuButton) EncodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode botMenuButton#c7b57ce6 as nil") + } + buf.PutString(b.Text) + buf.PutString(b.URL) + return nil +} + +// Decode implements bin.Decoder. +func (b *BotMenuButton) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode botMenuButton#c7b57ce6 to nil") + } + if err := buf.ConsumeID(BotMenuButtonTypeID); err != nil { + return fmt.Errorf("unable to decode botMenuButton#c7b57ce6: %w", err) + } + return b.DecodeBare(buf) +} + +// DecodeBare implements bin.BareDecoder. +func (b *BotMenuButton) DecodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode botMenuButton#c7b57ce6 to nil") + } + { + value, err := buf.String() + if err != nil { + return fmt.Errorf("unable to decode botMenuButton#c7b57ce6: field text: %w", err) + } + b.Text = value + } + { + value, err := buf.String() + if err != nil { + return fmt.Errorf("unable to decode botMenuButton#c7b57ce6: field url: %w", err) + } + b.URL = value + } + return nil +} + +// GetText returns value of Text field. +func (b *BotMenuButton) GetText() (value string) { + if b == nil { + return + } + return b.Text +} + +// GetURL returns value of URL field. +func (b *BotMenuButton) GetURL() (value string) { + if b == nil { + return + } + return b.URL +} + +// BotMenuButtonClassName is schema name of BotMenuButtonClass. +const BotMenuButtonClassName = "BotMenuButton" + +// BotMenuButtonClass represents BotMenuButton generic type. +// +// See https://core.telegram.org/type/BotMenuButton for reference. +// +// Example: +// g, err := tg.DecodeBotMenuButton(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.BotMenuButtonDefault: // botMenuButtonDefault#7533a588 +// case *tg.BotMenuButtonCommands: // botMenuButtonCommands#4258c205 +// case *tg.BotMenuButton: // botMenuButton#c7b57ce6 +// default: panic(v) +// } +type BotMenuButtonClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() BotMenuButtonClass + + // 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 +} + +// DecodeBotMenuButton implements binary de-serialization for BotMenuButtonClass. +func DecodeBotMenuButton(buf *bin.Buffer) (BotMenuButtonClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case BotMenuButtonDefaultTypeID: + // Decoding botMenuButtonDefault#7533a588. + v := BotMenuButtonDefault{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode BotMenuButtonClass: %w", err) + } + return &v, nil + case BotMenuButtonCommandsTypeID: + // Decoding botMenuButtonCommands#4258c205. + v := BotMenuButtonCommands{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode BotMenuButtonClass: %w", err) + } + return &v, nil + case BotMenuButtonTypeID: + // Decoding botMenuButton#c7b57ce6. + v := BotMenuButton{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode BotMenuButtonClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode BotMenuButtonClass: %w", bin.NewUnexpectedID(id)) + } +} + +// BotMenuButton boxes the BotMenuButtonClass providing a helper. +type BotMenuButtonBox struct { + BotMenuButton BotMenuButtonClass +} + +// Decode implements bin.Decoder for BotMenuButtonBox. +func (b *BotMenuButtonBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode BotMenuButtonBox to nil") + } + v, err := DecodeBotMenuButton(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.BotMenuButton = v + return nil +} + +// Encode implements bin.Encode for BotMenuButtonBox. +func (b *BotMenuButtonBox) Encode(buf *bin.Buffer) error { + if b == nil || b.BotMenuButton == nil { + return fmt.Errorf("unable to encode BotMenuButtonClass as nil") + } + return b.BotMenuButton.Encode(buf) +} diff --git a/tg/tl_bot_menu_button_slices_gen.go b/tg/tl_bot_menu_button_slices_gen.go new file mode 100644 index 0000000000..c79007f1f5 --- /dev/null +++ b/tg/tl_bot_menu_button_slices_gen.go @@ -0,0 +1,212 @@ +//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{} +) + +// BotMenuButtonClassArray is adapter for slice of BotMenuButtonClass. +type BotMenuButtonClassArray []BotMenuButtonClass + +// Sort sorts slice of BotMenuButtonClass. +func (s BotMenuButtonClassArray) Sort(less func(a, b BotMenuButtonClass) bool) BotMenuButtonClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of BotMenuButtonClass. +func (s BotMenuButtonClassArray) SortStable(less func(a, b BotMenuButtonClass) bool) BotMenuButtonClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of BotMenuButtonClass. +func (s BotMenuButtonClassArray) Retain(keep func(x BotMenuButtonClass) bool) BotMenuButtonClassArray { + 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 BotMenuButtonClassArray) First() (v BotMenuButtonClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s BotMenuButtonClassArray) Last() (v BotMenuButtonClass, 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 *BotMenuButtonClassArray) PopFirst() (v BotMenuButtonClass, 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 BotMenuButtonClass + 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 *BotMenuButtonClassArray) Pop() (v BotMenuButtonClass, 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 +} + +// AsBotMenuButton returns copy with only BotMenuButton constructors. +func (s BotMenuButtonClassArray) AsBotMenuButton() (to BotMenuButtonArray) { + for _, elem := range s { + value, ok := elem.(*BotMenuButton) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// BotMenuButtonArray is adapter for slice of BotMenuButton. +type BotMenuButtonArray []BotMenuButton + +// Sort sorts slice of BotMenuButton. +func (s BotMenuButtonArray) Sort(less func(a, b BotMenuButton) bool) BotMenuButtonArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of BotMenuButton. +func (s BotMenuButtonArray) SortStable(less func(a, b BotMenuButton) bool) BotMenuButtonArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of BotMenuButton. +func (s BotMenuButtonArray) Retain(keep func(x BotMenuButton) bool) BotMenuButtonArray { + 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 BotMenuButtonArray) First() (v BotMenuButton, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s BotMenuButtonArray) Last() (v BotMenuButton, 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 *BotMenuButtonArray) PopFirst() (v BotMenuButton, 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 BotMenuButton + 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 *BotMenuButtonArray) Pop() (v BotMenuButton, 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_bots_get_bot_menu_button_gen.go b/tg/tl_bots_get_bot_menu_button_gen.go new file mode 100644 index 0000000000..286320d90b --- /dev/null +++ b/tg/tl_bots_get_bot_menu_button_gen.go @@ -0,0 +1,181 @@ +// 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{} +) + +// BotsGetBotMenuButtonRequest represents TL type `bots.getBotMenuButton#9c60eb28`. +// +// See https://core.telegram.org/method/bots.getBotMenuButton for reference. +type BotsGetBotMenuButtonRequest struct { + // UserID field of BotsGetBotMenuButtonRequest. + UserID InputUserClass +} + +// BotsGetBotMenuButtonRequestTypeID is TL type id of BotsGetBotMenuButtonRequest. +const BotsGetBotMenuButtonRequestTypeID = 0x9c60eb28 + +// Ensuring interfaces in compile-time for BotsGetBotMenuButtonRequest. +var ( + _ bin.Encoder = &BotsGetBotMenuButtonRequest{} + _ bin.Decoder = &BotsGetBotMenuButtonRequest{} + _ bin.BareEncoder = &BotsGetBotMenuButtonRequest{} + _ bin.BareDecoder = &BotsGetBotMenuButtonRequest{} +) + +func (g *BotsGetBotMenuButtonRequest) Zero() bool { + if g == nil { + return true + } + if !(g.UserID == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *BotsGetBotMenuButtonRequest) String() string { + if g == nil { + return "BotsGetBotMenuButtonRequest(nil)" + } + type Alias BotsGetBotMenuButtonRequest + return fmt.Sprintf("BotsGetBotMenuButtonRequest%+v", Alias(*g)) +} + +// FillFrom fills BotsGetBotMenuButtonRequest from given interface. +func (g *BotsGetBotMenuButtonRequest) FillFrom(from interface { + GetUserID() (value InputUserClass) +}) { + g.UserID = from.GetUserID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*BotsGetBotMenuButtonRequest) TypeID() uint32 { + return BotsGetBotMenuButtonRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*BotsGetBotMenuButtonRequest) TypeName() string { + return "bots.getBotMenuButton" +} + +// TypeInfo returns info about TL type. +func (g *BotsGetBotMenuButtonRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "bots.getBotMenuButton", + ID: BotsGetBotMenuButtonRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *BotsGetBotMenuButtonRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode bots.getBotMenuButton#9c60eb28 as nil") + } + b.PutID(BotsGetBotMenuButtonRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *BotsGetBotMenuButtonRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode bots.getBotMenuButton#9c60eb28 as nil") + } + if g.UserID == nil { + return fmt.Errorf("unable to encode bots.getBotMenuButton#9c60eb28: field user_id is nil") + } + if err := g.UserID.Encode(b); err != nil { + return fmt.Errorf("unable to encode bots.getBotMenuButton#9c60eb28: field user_id: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (g *BotsGetBotMenuButtonRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode bots.getBotMenuButton#9c60eb28 to nil") + } + if err := b.ConsumeID(BotsGetBotMenuButtonRequestTypeID); err != nil { + return fmt.Errorf("unable to decode bots.getBotMenuButton#9c60eb28: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *BotsGetBotMenuButtonRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode bots.getBotMenuButton#9c60eb28 to nil") + } + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode bots.getBotMenuButton#9c60eb28: field user_id: %w", err) + } + g.UserID = value + } + return nil +} + +// GetUserID returns value of UserID field. +func (g *BotsGetBotMenuButtonRequest) GetUserID() (value InputUserClass) { + if g == nil { + return + } + return g.UserID +} + +// BotsGetBotMenuButton invokes method bots.getBotMenuButton#9c60eb28 returning error if any. +// +// See https://core.telegram.org/method/bots.getBotMenuButton for reference. +func (c *Client) BotsGetBotMenuButton(ctx context.Context, userid InputUserClass) (BotMenuButtonClass, error) { + var result BotMenuButtonBox + + request := &BotsGetBotMenuButtonRequest{ + UserID: userid, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.BotMenuButton, nil +} diff --git a/tg/tl_bots_get_bot_menu_button_slices_gen.go b/tg/tl_bots_get_bot_menu_button_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_bots_get_bot_menu_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_bots_set_bot_broadcast_default_admin_rights_gen.go b/tg/tl_bots_set_bot_broadcast_default_admin_rights_gen.go new file mode 100644 index 0000000000..367d881600 --- /dev/null +++ b/tg/tl_bots_set_bot_broadcast_default_admin_rights_gen.go @@ -0,0 +1,177 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// BotsSetBotBroadcastDefaultAdminRightsRequest represents TL type `bots.setBotBroadcastDefaultAdminRights#788464e1`. +// +// See https://core.telegram.org/method/bots.setBotBroadcastDefaultAdminRights for reference. +type BotsSetBotBroadcastDefaultAdminRightsRequest struct { + // AdminRights field of BotsSetBotBroadcastDefaultAdminRightsRequest. + AdminRights ChatAdminRights +} + +// BotsSetBotBroadcastDefaultAdminRightsRequestTypeID is TL type id of BotsSetBotBroadcastDefaultAdminRightsRequest. +const BotsSetBotBroadcastDefaultAdminRightsRequestTypeID = 0x788464e1 + +// Ensuring interfaces in compile-time for BotsSetBotBroadcastDefaultAdminRightsRequest. +var ( + _ bin.Encoder = &BotsSetBotBroadcastDefaultAdminRightsRequest{} + _ bin.Decoder = &BotsSetBotBroadcastDefaultAdminRightsRequest{} + _ bin.BareEncoder = &BotsSetBotBroadcastDefaultAdminRightsRequest{} + _ bin.BareDecoder = &BotsSetBotBroadcastDefaultAdminRightsRequest{} +) + +func (s *BotsSetBotBroadcastDefaultAdminRightsRequest) Zero() bool { + if s == nil { + return true + } + if !(s.AdminRights.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *BotsSetBotBroadcastDefaultAdminRightsRequest) String() string { + if s == nil { + return "BotsSetBotBroadcastDefaultAdminRightsRequest(nil)" + } + type Alias BotsSetBotBroadcastDefaultAdminRightsRequest + return fmt.Sprintf("BotsSetBotBroadcastDefaultAdminRightsRequest%+v", Alias(*s)) +} + +// FillFrom fills BotsSetBotBroadcastDefaultAdminRightsRequest from given interface. +func (s *BotsSetBotBroadcastDefaultAdminRightsRequest) FillFrom(from interface { + GetAdminRights() (value ChatAdminRights) +}) { + s.AdminRights = from.GetAdminRights() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*BotsSetBotBroadcastDefaultAdminRightsRequest) TypeID() uint32 { + return BotsSetBotBroadcastDefaultAdminRightsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*BotsSetBotBroadcastDefaultAdminRightsRequest) TypeName() string { + return "bots.setBotBroadcastDefaultAdminRights" +} + +// TypeInfo returns info about TL type. +func (s *BotsSetBotBroadcastDefaultAdminRightsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "bots.setBotBroadcastDefaultAdminRights", + ID: BotsSetBotBroadcastDefaultAdminRightsRequestTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "AdminRights", + SchemaName: "admin_rights", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *BotsSetBotBroadcastDefaultAdminRightsRequest) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode bots.setBotBroadcastDefaultAdminRights#788464e1 as nil") + } + b.PutID(BotsSetBotBroadcastDefaultAdminRightsRequestTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *BotsSetBotBroadcastDefaultAdminRightsRequest) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode bots.setBotBroadcastDefaultAdminRights#788464e1 as nil") + } + if err := s.AdminRights.Encode(b); err != nil { + return fmt.Errorf("unable to encode bots.setBotBroadcastDefaultAdminRights#788464e1: field admin_rights: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *BotsSetBotBroadcastDefaultAdminRightsRequest) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode bots.setBotBroadcastDefaultAdminRights#788464e1 to nil") + } + if err := b.ConsumeID(BotsSetBotBroadcastDefaultAdminRightsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode bots.setBotBroadcastDefaultAdminRights#788464e1: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *BotsSetBotBroadcastDefaultAdminRightsRequest) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode bots.setBotBroadcastDefaultAdminRights#788464e1 to nil") + } + { + if err := s.AdminRights.Decode(b); err != nil { + return fmt.Errorf("unable to decode bots.setBotBroadcastDefaultAdminRights#788464e1: field admin_rights: %w", err) + } + } + return nil +} + +// GetAdminRights returns value of AdminRights field. +func (s *BotsSetBotBroadcastDefaultAdminRightsRequest) GetAdminRights() (value ChatAdminRights) { + if s == nil { + return + } + return s.AdminRights +} + +// BotsSetBotBroadcastDefaultAdminRights invokes method bots.setBotBroadcastDefaultAdminRights#788464e1 returning error if any. +// +// See https://core.telegram.org/method/bots.setBotBroadcastDefaultAdminRights for reference. +func (c *Client) BotsSetBotBroadcastDefaultAdminRights(ctx context.Context, adminrights ChatAdminRights) (bool, error) { + var result BoolBox + + request := &BotsSetBotBroadcastDefaultAdminRightsRequest{ + AdminRights: adminrights, + } + 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_bots_set_bot_broadcast_default_admin_rights_slices_gen.go b/tg/tl_bots_set_bot_broadcast_default_admin_rights_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_bots_set_bot_broadcast_default_admin_rights_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_set_bot_group_default_admin_rights_gen.go b/tg/tl_bots_set_bot_group_default_admin_rights_gen.go new file mode 100644 index 0000000000..1ff2780b07 --- /dev/null +++ b/tg/tl_bots_set_bot_group_default_admin_rights_gen.go @@ -0,0 +1,177 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// BotsSetBotGroupDefaultAdminRightsRequest represents TL type `bots.setBotGroupDefaultAdminRights#925ec9ea`. +// +// See https://core.telegram.org/method/bots.setBotGroupDefaultAdminRights for reference. +type BotsSetBotGroupDefaultAdminRightsRequest struct { + // AdminRights field of BotsSetBotGroupDefaultAdminRightsRequest. + AdminRights ChatAdminRights +} + +// BotsSetBotGroupDefaultAdminRightsRequestTypeID is TL type id of BotsSetBotGroupDefaultAdminRightsRequest. +const BotsSetBotGroupDefaultAdminRightsRequestTypeID = 0x925ec9ea + +// Ensuring interfaces in compile-time for BotsSetBotGroupDefaultAdminRightsRequest. +var ( + _ bin.Encoder = &BotsSetBotGroupDefaultAdminRightsRequest{} + _ bin.Decoder = &BotsSetBotGroupDefaultAdminRightsRequest{} + _ bin.BareEncoder = &BotsSetBotGroupDefaultAdminRightsRequest{} + _ bin.BareDecoder = &BotsSetBotGroupDefaultAdminRightsRequest{} +) + +func (s *BotsSetBotGroupDefaultAdminRightsRequest) Zero() bool { + if s == nil { + return true + } + if !(s.AdminRights.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *BotsSetBotGroupDefaultAdminRightsRequest) String() string { + if s == nil { + return "BotsSetBotGroupDefaultAdminRightsRequest(nil)" + } + type Alias BotsSetBotGroupDefaultAdminRightsRequest + return fmt.Sprintf("BotsSetBotGroupDefaultAdminRightsRequest%+v", Alias(*s)) +} + +// FillFrom fills BotsSetBotGroupDefaultAdminRightsRequest from given interface. +func (s *BotsSetBotGroupDefaultAdminRightsRequest) FillFrom(from interface { + GetAdminRights() (value ChatAdminRights) +}) { + s.AdminRights = from.GetAdminRights() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*BotsSetBotGroupDefaultAdminRightsRequest) TypeID() uint32 { + return BotsSetBotGroupDefaultAdminRightsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*BotsSetBotGroupDefaultAdminRightsRequest) TypeName() string { + return "bots.setBotGroupDefaultAdminRights" +} + +// TypeInfo returns info about TL type. +func (s *BotsSetBotGroupDefaultAdminRightsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "bots.setBotGroupDefaultAdminRights", + ID: BotsSetBotGroupDefaultAdminRightsRequestTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "AdminRights", + SchemaName: "admin_rights", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *BotsSetBotGroupDefaultAdminRightsRequest) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode bots.setBotGroupDefaultAdminRights#925ec9ea as nil") + } + b.PutID(BotsSetBotGroupDefaultAdminRightsRequestTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *BotsSetBotGroupDefaultAdminRightsRequest) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode bots.setBotGroupDefaultAdminRights#925ec9ea as nil") + } + if err := s.AdminRights.Encode(b); err != nil { + return fmt.Errorf("unable to encode bots.setBotGroupDefaultAdminRights#925ec9ea: field admin_rights: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *BotsSetBotGroupDefaultAdminRightsRequest) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode bots.setBotGroupDefaultAdminRights#925ec9ea to nil") + } + if err := b.ConsumeID(BotsSetBotGroupDefaultAdminRightsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode bots.setBotGroupDefaultAdminRights#925ec9ea: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *BotsSetBotGroupDefaultAdminRightsRequest) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode bots.setBotGroupDefaultAdminRights#925ec9ea to nil") + } + { + if err := s.AdminRights.Decode(b); err != nil { + return fmt.Errorf("unable to decode bots.setBotGroupDefaultAdminRights#925ec9ea: field admin_rights: %w", err) + } + } + return nil +} + +// GetAdminRights returns value of AdminRights field. +func (s *BotsSetBotGroupDefaultAdminRightsRequest) GetAdminRights() (value ChatAdminRights) { + if s == nil { + return + } + return s.AdminRights +} + +// BotsSetBotGroupDefaultAdminRights invokes method bots.setBotGroupDefaultAdminRights#925ec9ea returning error if any. +// +// See https://core.telegram.org/method/bots.setBotGroupDefaultAdminRights for reference. +func (c *Client) BotsSetBotGroupDefaultAdminRights(ctx context.Context, adminrights ChatAdminRights) (bool, error) { + var result BoolBox + + request := &BotsSetBotGroupDefaultAdminRightsRequest{ + AdminRights: adminrights, + } + 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_bots_set_bot_group_default_admin_rights_slices_gen.go b/tg/tl_bots_set_bot_group_default_admin_rights_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_bots_set_bot_group_default_admin_rights_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_set_bot_menu_button_gen.go b/tg/tl_bots_set_bot_menu_button_gen.go new file mode 100644 index 0000000000..8545d7d87a --- /dev/null +++ b/tg/tl_bots_set_bot_menu_button_gen.go @@ -0,0 +1,211 @@ +// 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{} +) + +// BotsSetBotMenuButtonRequest represents TL type `bots.setBotMenuButton#4504d54f`. +// +// See https://core.telegram.org/method/bots.setBotMenuButton for reference. +type BotsSetBotMenuButtonRequest struct { + // UserID field of BotsSetBotMenuButtonRequest. + UserID InputUserClass + // Button field of BotsSetBotMenuButtonRequest. + Button BotMenuButtonClass +} + +// BotsSetBotMenuButtonRequestTypeID is TL type id of BotsSetBotMenuButtonRequest. +const BotsSetBotMenuButtonRequestTypeID = 0x4504d54f + +// Ensuring interfaces in compile-time for BotsSetBotMenuButtonRequest. +var ( + _ bin.Encoder = &BotsSetBotMenuButtonRequest{} + _ bin.Decoder = &BotsSetBotMenuButtonRequest{} + _ bin.BareEncoder = &BotsSetBotMenuButtonRequest{} + _ bin.BareDecoder = &BotsSetBotMenuButtonRequest{} +) + +func (s *BotsSetBotMenuButtonRequest) Zero() bool { + if s == nil { + return true + } + if !(s.UserID == nil) { + return false + } + if !(s.Button == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *BotsSetBotMenuButtonRequest) String() string { + if s == nil { + return "BotsSetBotMenuButtonRequest(nil)" + } + type Alias BotsSetBotMenuButtonRequest + return fmt.Sprintf("BotsSetBotMenuButtonRequest%+v", Alias(*s)) +} + +// FillFrom fills BotsSetBotMenuButtonRequest from given interface. +func (s *BotsSetBotMenuButtonRequest) FillFrom(from interface { + GetUserID() (value InputUserClass) + GetButton() (value BotMenuButtonClass) +}) { + s.UserID = from.GetUserID() + s.Button = from.GetButton() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*BotsSetBotMenuButtonRequest) TypeID() uint32 { + return BotsSetBotMenuButtonRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*BotsSetBotMenuButtonRequest) TypeName() string { + return "bots.setBotMenuButton" +} + +// TypeInfo returns info about TL type. +func (s *BotsSetBotMenuButtonRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "bots.setBotMenuButton", + ID: BotsSetBotMenuButtonRequestTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "Button", + SchemaName: "button", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *BotsSetBotMenuButtonRequest) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode bots.setBotMenuButton#4504d54f as nil") + } + b.PutID(BotsSetBotMenuButtonRequestTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *BotsSetBotMenuButtonRequest) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode bots.setBotMenuButton#4504d54f as nil") + } + if s.UserID == nil { + return fmt.Errorf("unable to encode bots.setBotMenuButton#4504d54f: field user_id is nil") + } + if err := s.UserID.Encode(b); err != nil { + return fmt.Errorf("unable to encode bots.setBotMenuButton#4504d54f: field user_id: %w", err) + } + if s.Button == nil { + return fmt.Errorf("unable to encode bots.setBotMenuButton#4504d54f: field button is nil") + } + if err := s.Button.Encode(b); err != nil { + return fmt.Errorf("unable to encode bots.setBotMenuButton#4504d54f: field button: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *BotsSetBotMenuButtonRequest) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode bots.setBotMenuButton#4504d54f to nil") + } + if err := b.ConsumeID(BotsSetBotMenuButtonRequestTypeID); err != nil { + return fmt.Errorf("unable to decode bots.setBotMenuButton#4504d54f: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *BotsSetBotMenuButtonRequest) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode bots.setBotMenuButton#4504d54f to nil") + } + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode bots.setBotMenuButton#4504d54f: field user_id: %w", err) + } + s.UserID = value + } + { + value, err := DecodeBotMenuButton(b) + if err != nil { + return fmt.Errorf("unable to decode bots.setBotMenuButton#4504d54f: field button: %w", err) + } + s.Button = value + } + return nil +} + +// GetUserID returns value of UserID field. +func (s *BotsSetBotMenuButtonRequest) GetUserID() (value InputUserClass) { + if s == nil { + return + } + return s.UserID +} + +// GetButton returns value of Button field. +func (s *BotsSetBotMenuButtonRequest) GetButton() (value BotMenuButtonClass) { + if s == nil { + return + } + return s.Button +} + +// BotsSetBotMenuButton invokes method bots.setBotMenuButton#4504d54f returning error if any. +// +// See https://core.telegram.org/method/bots.setBotMenuButton for reference. +func (c *Client) BotsSetBotMenuButton(ctx context.Context, request *BotsSetBotMenuButtonRequest) (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_bots_set_bot_menu_button_slices_gen.go b/tg/tl_bots_set_bot_menu_button_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_bots_set_bot_menu_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_channels_delete_history_gen.go b/tg/tl_channels_delete_history_gen.go index 7510c20002..53f953eecb 100644 --- a/tg/tl_channels_delete_history_gen.go +++ b/tg/tl_channels_delete_history_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// ChannelsDeleteHistoryRequest represents TL type `channels.deleteHistory#af369d42`. +// ChannelsDeleteHistoryRequest represents TL type `channels.deleteHistory#9baa9647`. // Delete the history of a supergroup¹ // // Links: @@ -39,6 +39,10 @@ var ( // // See https://core.telegram.org/method/channels.deleteHistory for reference. type ChannelsDeleteHistoryRequest struct { + // Flags field of ChannelsDeleteHistoryRequest. + Flags bin.Fields + // ForEveryone field of ChannelsDeleteHistoryRequest. + ForEveryone bool // Supergroup¹ whose history must be deleted // // Links: @@ -49,7 +53,7 @@ type ChannelsDeleteHistoryRequest struct { } // ChannelsDeleteHistoryRequestTypeID is TL type id of ChannelsDeleteHistoryRequest. -const ChannelsDeleteHistoryRequestTypeID = 0xaf369d42 +const ChannelsDeleteHistoryRequestTypeID = 0x9baa9647 // Ensuring interfaces in compile-time for ChannelsDeleteHistoryRequest. var ( @@ -63,6 +67,12 @@ func (d *ChannelsDeleteHistoryRequest) Zero() bool { if d == nil { return true } + if !(d.Flags.Zero()) { + return false + } + if !(d.ForEveryone == false) { + return false + } if !(d.Channel == nil) { return false } @@ -84,9 +94,11 @@ func (d *ChannelsDeleteHistoryRequest) String() string { // FillFrom fills ChannelsDeleteHistoryRequest from given interface. func (d *ChannelsDeleteHistoryRequest) FillFrom(from interface { + GetForEveryone() (value bool) GetChannel() (value InputChannelClass) GetMaxID() (value int) }) { + d.ForEveryone = from.GetForEveryone() d.Channel = from.GetChannel() d.MaxID = from.GetMaxID() } @@ -114,6 +126,11 @@ func (d *ChannelsDeleteHistoryRequest) TypeInfo() tdp.Type { return typ } typ.Fields = []tdp.Field{ + { + Name: "ForEveryone", + SchemaName: "for_everyone", + Null: !d.Flags.Has(0), + }, { Name: "Channel", SchemaName: "channel", @@ -126,10 +143,17 @@ func (d *ChannelsDeleteHistoryRequest) TypeInfo() tdp.Type { return typ } +// SetFlags sets flags for non-zero fields. +func (d *ChannelsDeleteHistoryRequest) SetFlags() { + if !(d.ForEveryone == false) { + d.Flags.Set(0) + } +} + // Encode implements bin.Encoder. func (d *ChannelsDeleteHistoryRequest) Encode(b *bin.Buffer) error { if d == nil { - return fmt.Errorf("can't encode channels.deleteHistory#af369d42 as nil") + return fmt.Errorf("can't encode channels.deleteHistory#9baa9647 as nil") } b.PutID(ChannelsDeleteHistoryRequestTypeID) return d.EncodeBare(b) @@ -138,13 +162,17 @@ func (d *ChannelsDeleteHistoryRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (d *ChannelsDeleteHistoryRequest) EncodeBare(b *bin.Buffer) error { if d == nil { - return fmt.Errorf("can't encode channels.deleteHistory#af369d42 as nil") + return fmt.Errorf("can't encode channels.deleteHistory#9baa9647 as nil") + } + d.SetFlags() + if err := d.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode channels.deleteHistory#9baa9647: field flags: %w", err) } if d.Channel == nil { - return fmt.Errorf("unable to encode channels.deleteHistory#af369d42: field channel is nil") + return fmt.Errorf("unable to encode channels.deleteHistory#9baa9647: field channel is nil") } if err := d.Channel.Encode(b); err != nil { - return fmt.Errorf("unable to encode channels.deleteHistory#af369d42: field channel: %w", err) + return fmt.Errorf("unable to encode channels.deleteHistory#9baa9647: field channel: %w", err) } b.PutInt(d.MaxID) return nil @@ -153,10 +181,10 @@ func (d *ChannelsDeleteHistoryRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (d *ChannelsDeleteHistoryRequest) Decode(b *bin.Buffer) error { if d == nil { - return fmt.Errorf("can't decode channels.deleteHistory#af369d42 to nil") + return fmt.Errorf("can't decode channels.deleteHistory#9baa9647 to nil") } if err := b.ConsumeID(ChannelsDeleteHistoryRequestTypeID); err != nil { - return fmt.Errorf("unable to decode channels.deleteHistory#af369d42: %w", err) + return fmt.Errorf("unable to decode channels.deleteHistory#9baa9647: %w", err) } return d.DecodeBare(b) } @@ -164,25 +192,50 @@ func (d *ChannelsDeleteHistoryRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (d *ChannelsDeleteHistoryRequest) DecodeBare(b *bin.Buffer) error { if d == nil { - return fmt.Errorf("can't decode channels.deleteHistory#af369d42 to nil") + return fmt.Errorf("can't decode channels.deleteHistory#9baa9647 to nil") } + { + if err := d.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode channels.deleteHistory#9baa9647: field flags: %w", err) + } + } + d.ForEveryone = d.Flags.Has(0) { value, err := DecodeInputChannel(b) if err != nil { - return fmt.Errorf("unable to decode channels.deleteHistory#af369d42: field channel: %w", err) + return fmt.Errorf("unable to decode channels.deleteHistory#9baa9647: field channel: %w", err) } d.Channel = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channels.deleteHistory#af369d42: field max_id: %w", err) + return fmt.Errorf("unable to decode channels.deleteHistory#9baa9647: field max_id: %w", err) } d.MaxID = value } return nil } +// SetForEveryone sets value of ForEveryone conditional field. +func (d *ChannelsDeleteHistoryRequest) SetForEveryone(value bool) { + if value { + d.Flags.Set(0) + d.ForEveryone = true + } else { + d.Flags.Unset(0) + d.ForEveryone = false + } +} + +// GetForEveryone returns value of ForEveryone conditional field. +func (d *ChannelsDeleteHistoryRequest) GetForEveryone() (value bool) { + if d == nil { + return + } + return d.Flags.Has(0) +} + // GetChannel returns value of Channel field. func (d *ChannelsDeleteHistoryRequest) GetChannel() (value InputChannelClass) { if d == nil { @@ -204,7 +257,7 @@ func (d *ChannelsDeleteHistoryRequest) GetChannelAsNotEmpty() (NotEmptyInputChan return d.Channel.AsNotEmpty() } -// ChannelsDeleteHistory invokes method channels.deleteHistory#af369d42 returning error if any. +// ChannelsDeleteHistory invokes method channels.deleteHistory#9baa9647 returning error if any. // Delete the history of a supergroup¹ // // Links: @@ -215,12 +268,11 @@ func (d *ChannelsDeleteHistoryRequest) GetChannelAsNotEmpty() (NotEmptyInputChan // 400 CHANNEL_PRIVATE: You haven't joined this channel/supergroup. // // See https://core.telegram.org/method/channels.deleteHistory for reference. -func (c *Client) ChannelsDeleteHistory(ctx context.Context, request *ChannelsDeleteHistoryRequest) (bool, error) { - var result BoolBox +func (c *Client) ChannelsDeleteHistory(ctx context.Context, request *ChannelsDeleteHistoryRequest) (UpdatesClass, error) { + var result UpdatesBox if err := c.rpc.Invoke(ctx, request, &result); err != nil { - return false, err + return nil, err } - _, ok := result.Bool.(*BoolTrue) - return ok, nil + return result.Updates, nil } diff --git a/tg/tl_chat_full_gen.go b/tg/tl_chat_full_gen.go index c1aa18f6db..2e9b9dd063 100644 --- a/tg/tl_chat_full_gen.go +++ b/tg/tl_chat_full_gen.go @@ -983,7 +983,7 @@ func (c *ChatFull) GetAvailableReactions() (value []string, ok bool) { return c.AvailableReactions, true } -// ChannelFull represents TL type `channelFull#e13c3d20`. +// ChannelFull represents TL type `channelFull#ea68a619`. // Full info about a channel/supergroup¹ // // Links: @@ -1022,6 +1022,10 @@ type ChannelFull struct { // Links: // 1) https://core.telegram.org/api/discussion Blocked bool + // Flags2 field of ChannelFull. + Flags2 bin.Fields + // CanDeleteChannel field of ChannelFull. + CanDeleteChannel bool // ID of the channel ID int64 // Info about the channel @@ -1181,7 +1185,7 @@ type ChannelFull struct { } // ChannelFullTypeID is TL type id of ChannelFull. -const ChannelFullTypeID = 0xe13c3d20 +const ChannelFullTypeID = 0xea68a619 // construct implements constructor of ChatFullClass. func (c ChannelFull) construct() ChatFullClass { return &c } @@ -1227,6 +1231,12 @@ func (c *ChannelFull) Zero() bool { if !(c.Blocked == false) { return false } + if !(c.Flags2.Zero()) { + return false + } + if !(c.CanDeleteChannel == false) { + return false + } if !(c.ID == 0) { return false } @@ -1355,6 +1365,7 @@ func (c *ChannelFull) FillFrom(from interface { GetHasScheduled() (value bool) GetCanViewStats() (value bool) GetBlocked() (value bool) + GetCanDeleteChannel() (value bool) GetID() (value int64) GetAbout() (value string) GetParticipantsCount() (value int, ok bool) @@ -1399,6 +1410,7 @@ func (c *ChannelFull) FillFrom(from interface { c.HasScheduled = from.GetHasScheduled() c.CanViewStats = from.GetCanViewStats() c.Blocked = from.GetBlocked() + c.CanDeleteChannel = from.GetCanDeleteChannel() c.ID = from.GetID() c.About = from.GetAbout() if val, ok := from.GetParticipantsCount(); ok { @@ -1577,6 +1589,11 @@ func (c *ChannelFull) TypeInfo() tdp.Type { SchemaName: "blocked", Null: !c.Flags.Has(22), }, + { + Name: "CanDeleteChannel", + SchemaName: "can_delete_channel", + Null: !c.Flags2.Has(0), + }, { Name: "ID", SchemaName: "id", @@ -1773,6 +1790,9 @@ func (c *ChannelFull) SetFlags() { if !(c.Blocked == false) { c.Flags.Set(22) } + if !(c.CanDeleteChannel == false) { + c.Flags2.Set(0) + } if !(c.ParticipantsCount == 0) { c.Flags.Set(0) } @@ -1856,7 +1876,7 @@ func (c *ChannelFull) SetFlags() { // Encode implements bin.Encoder. func (c *ChannelFull) Encode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode channelFull#e13c3d20 as nil") + return fmt.Errorf("can't encode channelFull#ea68a619 as nil") } b.PutID(ChannelFullTypeID) return c.EncodeBare(b) @@ -1865,11 +1885,14 @@ func (c *ChannelFull) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode channelFull#e13c3d20 as nil") + return fmt.Errorf("can't encode channelFull#ea68a619 as nil") } c.SetFlags() if err := c.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#e13c3d20: field flags: %w", err) + return fmt.Errorf("unable to encode channelFull#ea68a619: field flags: %w", err) + } + if err := c.Flags2.Encode(b); err != nil { + return fmt.Errorf("unable to encode channelFull#ea68a619: field flags2: %w", err) } b.PutLong(c.ID) b.PutString(c.About) @@ -1892,23 +1915,23 @@ func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { b.PutInt(c.ReadOutboxMaxID) b.PutInt(c.UnreadCount) if c.ChatPhoto == nil { - return fmt.Errorf("unable to encode channelFull#e13c3d20: field chat_photo is nil") + return fmt.Errorf("unable to encode channelFull#ea68a619: field chat_photo is nil") } if err := c.ChatPhoto.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#e13c3d20: field chat_photo: %w", err) + return fmt.Errorf("unable to encode channelFull#ea68a619: field chat_photo: %w", err) } if err := c.NotifySettings.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#e13c3d20: field notify_settings: %w", err) + return fmt.Errorf("unable to encode channelFull#ea68a619: field notify_settings: %w", err) } if c.Flags.Has(23) { if err := c.ExportedInvite.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#e13c3d20: field exported_invite: %w", err) + return fmt.Errorf("unable to encode channelFull#ea68a619: field exported_invite: %w", err) } } b.PutVectorHeader(len(c.BotInfo)) for idx, v := range c.BotInfo { if err := v.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#e13c3d20: field bot_info element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode channelFull#ea68a619: field bot_info element with index %d: %w", idx, err) } } if c.Flags.Has(4) { @@ -1922,7 +1945,7 @@ func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { } if c.Flags.Has(8) { if err := c.Stickerset.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#e13c3d20: field stickerset: %w", err) + return fmt.Errorf("unable to encode channelFull#ea68a619: field stickerset: %w", err) } } if c.Flags.Has(9) { @@ -1936,10 +1959,10 @@ func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { } if c.Flags.Has(15) { if c.Location == nil { - return fmt.Errorf("unable to encode channelFull#e13c3d20: field location is nil") + return fmt.Errorf("unable to encode channelFull#ea68a619: field location is nil") } if err := c.Location.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#e13c3d20: field location: %w", err) + return fmt.Errorf("unable to encode channelFull#ea68a619: field location: %w", err) } } if c.Flags.Has(17) { @@ -1954,7 +1977,7 @@ func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { b.PutInt(c.Pts) if c.Flags.Has(21) { if err := c.Call.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#e13c3d20: field call: %w", err) + return fmt.Errorf("unable to encode channelFull#ea68a619: field call: %w", err) } } if c.Flags.Has(24) { @@ -1968,10 +1991,10 @@ func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { } if c.Flags.Has(26) { if c.GroupcallDefaultJoinAs == nil { - return fmt.Errorf("unable to encode channelFull#e13c3d20: field groupcall_default_join_as is nil") + return fmt.Errorf("unable to encode channelFull#ea68a619: field groupcall_default_join_as is nil") } if err := c.GroupcallDefaultJoinAs.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#e13c3d20: field groupcall_default_join_as: %w", err) + return fmt.Errorf("unable to encode channelFull#ea68a619: field groupcall_default_join_as: %w", err) } } if c.Flags.Has(27) { @@ -1988,10 +2011,10 @@ func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { } if c.Flags.Has(29) { if c.DefaultSendAs == nil { - return fmt.Errorf("unable to encode channelFull#e13c3d20: field default_send_as is nil") + return fmt.Errorf("unable to encode channelFull#ea68a619: field default_send_as is nil") } if err := c.DefaultSendAs.Encode(b); err != nil { - return fmt.Errorf("unable to encode channelFull#e13c3d20: field default_send_as: %w", err) + return fmt.Errorf("unable to encode channelFull#ea68a619: field default_send_as: %w", err) } } if c.Flags.Has(30) { @@ -2006,10 +2029,10 @@ func (c *ChannelFull) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (c *ChannelFull) Decode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode channelFull#e13c3d20 to nil") + return fmt.Errorf("can't decode channelFull#ea68a619 to nil") } if err := b.ConsumeID(ChannelFullTypeID); err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: %w", err) } return c.DecodeBare(b) } @@ -2017,11 +2040,11 @@ func (c *ChannelFull) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode channelFull#e13c3d20 to nil") + return fmt.Errorf("can't decode channelFull#ea68a619 to nil") } { if err := c.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field flags: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field flags: %w", err) } } c.CanViewParticipants = c.Flags.Has(3) @@ -2032,97 +2055,103 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { c.HasScheduled = c.Flags.Has(19) c.CanViewStats = c.Flags.Has(20) c.Blocked = c.Flags.Has(22) + { + if err := c.Flags2.Decode(b); err != nil { + return fmt.Errorf("unable to decode channelFull#ea68a619: field flags2: %w", err) + } + } + c.CanDeleteChannel = c.Flags2.Has(0) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field id: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field id: %w", err) } c.ID = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field about: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field about: %w", err) } c.About = value } if c.Flags.Has(0) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field participants_count: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field participants_count: %w", err) } c.ParticipantsCount = value } if c.Flags.Has(1) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field admins_count: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field admins_count: %w", err) } c.AdminsCount = value } if c.Flags.Has(2) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field kicked_count: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field kicked_count: %w", err) } c.KickedCount = value } if c.Flags.Has(2) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field banned_count: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field banned_count: %w", err) } c.BannedCount = value } if c.Flags.Has(13) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field online_count: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field online_count: %w", err) } c.OnlineCount = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field read_inbox_max_id: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field read_inbox_max_id: %w", err) } c.ReadInboxMaxID = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field read_outbox_max_id: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field read_outbox_max_id: %w", err) } c.ReadOutboxMaxID = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field unread_count: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field unread_count: %w", err) } c.UnreadCount = value } { value, err := DecodePhoto(b) if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field chat_photo: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field chat_photo: %w", err) } c.ChatPhoto = value } { if err := c.NotifySettings.Decode(b); err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field notify_settings: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field notify_settings: %w", err) } } if c.Flags.Has(23) { if err := c.ExportedInvite.Decode(b); err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field exported_invite: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field exported_invite: %w", err) } } { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field bot_info: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field bot_info: %w", err) } if headerLen > 0 { @@ -2131,7 +2160,7 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value BotInfo if err := value.Decode(b); err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field bot_info: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field bot_info: %w", err) } c.BotInfo = append(c.BotInfo, value) } @@ -2139,101 +2168,101 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { if c.Flags.Has(4) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field migrated_from_chat_id: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field migrated_from_chat_id: %w", err) } c.MigratedFromChatID = value } if c.Flags.Has(4) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field migrated_from_max_id: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field migrated_from_max_id: %w", err) } c.MigratedFromMaxID = value } if c.Flags.Has(5) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field pinned_msg_id: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field pinned_msg_id: %w", err) } c.PinnedMsgID = value } if c.Flags.Has(8) { if err := c.Stickerset.Decode(b); err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field stickerset: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field stickerset: %w", err) } } if c.Flags.Has(9) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field available_min_id: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field available_min_id: %w", err) } c.AvailableMinID = value } if c.Flags.Has(11) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field folder_id: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field folder_id: %w", err) } c.FolderID = value } if c.Flags.Has(14) { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field linked_chat_id: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field linked_chat_id: %w", err) } c.LinkedChatID = value } if c.Flags.Has(15) { value, err := DecodeChannelLocation(b) if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field location: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field location: %w", err) } c.Location = value } if c.Flags.Has(17) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field slowmode_seconds: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field slowmode_seconds: %w", err) } c.SlowmodeSeconds = value } if c.Flags.Has(18) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field slowmode_next_send_date: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field slowmode_next_send_date: %w", err) } c.SlowmodeNextSendDate = value } if c.Flags.Has(12) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field stats_dc: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field stats_dc: %w", err) } c.StatsDC = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field pts: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field pts: %w", err) } c.Pts = value } if c.Flags.Has(21) { if err := c.Call.Decode(b); err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field call: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field call: %w", err) } } if c.Flags.Has(24) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field ttl_period: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field ttl_period: %w", err) } c.TTLPeriod = value } if c.Flags.Has(25) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field pending_suggestions: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field pending_suggestions: %w", err) } if headerLen > 0 { @@ -2242,7 +2271,7 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field pending_suggestions: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field pending_suggestions: %w", err) } c.PendingSuggestions = append(c.PendingSuggestions, value) } @@ -2250,28 +2279,28 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { if c.Flags.Has(26) { value, err := DecodePeer(b) if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field groupcall_default_join_as: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field groupcall_default_join_as: %w", err) } c.GroupcallDefaultJoinAs = value } if c.Flags.Has(27) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field theme_emoticon: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field theme_emoticon: %w", err) } c.ThemeEmoticon = value } if c.Flags.Has(28) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field requests_pending: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field requests_pending: %w", err) } c.RequestsPending = value } if c.Flags.Has(28) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field recent_requesters: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field recent_requesters: %w", err) } if headerLen > 0 { @@ -2280,7 +2309,7 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field recent_requesters: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field recent_requesters: %w", err) } c.RecentRequesters = append(c.RecentRequesters, value) } @@ -2288,14 +2317,14 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { if c.Flags.Has(29) { value, err := DecodePeer(b) if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field default_send_as: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field default_send_as: %w", err) } c.DefaultSendAs = value } if c.Flags.Has(30) { headerLen, err := b.VectorHeader() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field available_reactions: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field available_reactions: %w", err) } if headerLen > 0 { @@ -2304,7 +2333,7 @@ func (c *ChannelFull) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode channelFull#e13c3d20: field available_reactions: %w", err) + return fmt.Errorf("unable to decode channelFull#ea68a619: field available_reactions: %w", err) } c.AvailableReactions = append(c.AvailableReactions, value) } @@ -2464,6 +2493,25 @@ func (c *ChannelFull) GetBlocked() (value bool) { return c.Flags.Has(22) } +// SetCanDeleteChannel sets value of CanDeleteChannel conditional field. +func (c *ChannelFull) SetCanDeleteChannel(value bool) { + if value { + c.Flags2.Set(0) + c.CanDeleteChannel = true + } else { + c.Flags2.Unset(0) + c.CanDeleteChannel = false + } +} + +// GetCanDeleteChannel returns value of CanDeleteChannel conditional field. +func (c *ChannelFull) GetCanDeleteChannel() (value bool) { + if c == nil { + return + } + return c.Flags2.Has(0) +} + // GetID returns value of ID field. func (c *ChannelFull) GetID() (value int64) { if c == nil { @@ -3018,7 +3066,7 @@ const ChatFullClassName = "ChatFull" // } // switch v := g.(type) { // case *tg.ChatFull: // chatFull#d18ee226 -// case *tg.ChannelFull: // channelFull#e13c3d20 +// case *tg.ChannelFull: // channelFull#ea68a619 // default: panic(v) // } type ChatFullClass interface { @@ -3112,7 +3160,7 @@ func DecodeChatFull(buf *bin.Buffer) (ChatFullClass, error) { } return &v, nil case ChannelFullTypeID: - // Decoding channelFull#e13c3d20. + // Decoding channelFull#ea68a619. v := ChannelFull{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode ChatFullClass: %w", err) diff --git a/tg/tl_chat_gen.go b/tg/tl_chat_gen.go index cef5f6a0b7..bc4b4b4ff7 100644 --- a/tg/tl_chat_gen.go +++ b/tg/tl_chat_gen.go @@ -178,8 +178,6 @@ type Chat struct { Flags bin.Fields // Whether the current user is the creator of the group Creator bool - // Whether the current user was kicked from the group - Kicked bool // Whether the current user has left the group Left bool // Whether the group was migrated¹ @@ -254,9 +252,6 @@ func (c *Chat) Zero() bool { if !(c.Creator == false) { return false } - if !(c.Kicked == false) { - return false - } if !(c.Left == false) { return false } @@ -315,7 +310,6 @@ func (c *Chat) String() string { // FillFrom fills Chat from given interface. func (c *Chat) FillFrom(from interface { GetCreator() (value bool) - GetKicked() (value bool) GetLeft() (value bool) GetDeactivated() (value bool) GetCallActive() (value bool) @@ -332,7 +326,6 @@ func (c *Chat) FillFrom(from interface { GetDefaultBannedRights() (value ChatBannedRights, ok bool) }) { c.Creator = from.GetCreator() - c.Kicked = from.GetKicked() c.Left = from.GetLeft() c.Deactivated = from.GetDeactivated() c.CallActive = from.GetCallActive() @@ -386,11 +379,6 @@ func (c *Chat) TypeInfo() tdp.Type { SchemaName: "creator", Null: !c.Flags.Has(0), }, - { - Name: "Kicked", - SchemaName: "kicked", - Null: !c.Flags.Has(1), - }, { Name: "Left", SchemaName: "left", @@ -464,9 +452,6 @@ func (c *Chat) SetFlags() { if !(c.Creator == false) { c.Flags.Set(0) } - if !(c.Kicked == false) { - c.Flags.Set(1) - } if !(c.Left == false) { c.Flags.Set(2) } @@ -565,7 +550,6 @@ func (c *Chat) DecodeBare(b *bin.Buffer) error { } } c.Creator = c.Flags.Has(0) - c.Kicked = c.Flags.Has(1) c.Left = c.Flags.Has(2) c.Deactivated = c.Flags.Has(5) c.CallActive = c.Flags.Has(23) @@ -652,25 +636,6 @@ func (c *Chat) GetCreator() (value bool) { return c.Flags.Has(0) } -// SetKicked sets value of Kicked conditional field. -func (c *Chat) SetKicked(value bool) { - if value { - c.Flags.Set(1) - c.Kicked = true - } else { - c.Flags.Unset(1) - c.Kicked = false - } -} - -// GetKicked returns value of Kicked conditional field. -func (c *Chat) GetKicked() (value bool) { - if c == nil { - return - } - return c.Flags.Has(1) -} - // SetLeft sets value of Left conditional field. func (c *Chat) SetLeft(value bool) { if value { diff --git a/tg/tl_handlers_gen.go b/tg/tl_handlers_gen.go index 7684ee3990..90a09dfbf1 100644 --- a/tg/tl_handlers_gen.go +++ b/tg/tl_handlers_gen.go @@ -1065,3 +1065,43 @@ func (u UpdateDispatcher) OnMessageReactions(handler MessageReactionsHandler) { return handler(ctx, e, update.(*UpdateMessageReactions)) } } + +// AttachMenuBotsHandler is a AttachMenuBots event handler. +type AttachMenuBotsHandler func(ctx context.Context, e Entities, update *UpdateAttachMenuBots) error + +// OnAttachMenuBots sets AttachMenuBots handler. +func (u UpdateDispatcher) OnAttachMenuBots(handler AttachMenuBotsHandler) { + u.handlers[UpdateAttachMenuBotsTypeID] = func(ctx context.Context, e Entities, update UpdateClass) error { + return handler(ctx, e, update.(*UpdateAttachMenuBots)) + } +} + +// WebViewResultSentHandler is a WebViewResultSent event handler. +type WebViewResultSentHandler func(ctx context.Context, e Entities, update *UpdateWebViewResultSent) error + +// OnWebViewResultSent sets WebViewResultSent handler. +func (u UpdateDispatcher) OnWebViewResultSent(handler WebViewResultSentHandler) { + u.handlers[UpdateWebViewResultSentTypeID] = func(ctx context.Context, e Entities, update UpdateClass) error { + return handler(ctx, e, update.(*UpdateWebViewResultSent)) + } +} + +// BotMenuButtonHandler is a BotMenuButton event handler. +type BotMenuButtonHandler func(ctx context.Context, e Entities, update *UpdateBotMenuButton) error + +// OnBotMenuButton sets BotMenuButton handler. +func (u UpdateDispatcher) OnBotMenuButton(handler BotMenuButtonHandler) { + u.handlers[UpdateBotMenuButtonTypeID] = func(ctx context.Context, e Entities, update UpdateClass) error { + return handler(ctx, e, update.(*UpdateBotMenuButton)) + } +} + +// SavedRingtonesHandler is a SavedRingtones event handler. +type SavedRingtonesHandler func(ctx context.Context, e Entities, update *UpdateSavedRingtones) error + +// OnSavedRingtones sets SavedRingtones handler. +func (u UpdateDispatcher) OnSavedRingtones(handler SavedRingtonesHandler) { + u.handlers[UpdateSavedRingtonesTypeID] = func(ctx context.Context, e Entities, update UpdateClass) error { + return handler(ctx, e, update.(*UpdateSavedRingtones)) + } +} diff --git a/tg/tl_input_peer_notify_settings_gen.go b/tg/tl_input_peer_notify_settings_gen.go index b9d847f98c..954f4128ef 100644 --- a/tg/tl_input_peer_notify_settings_gen.go +++ b/tg/tl_input_peer_notify_settings_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// InputPeerNotifySettings represents TL type `inputPeerNotifySettings#9c3d198e`. +// InputPeerNotifySettings represents TL type `inputPeerNotifySettings#df1f002b`. // Notification settings. // // See https://core.telegram.org/constructor/inputPeerNotifySettings for reference. @@ -56,11 +56,11 @@ type InputPeerNotifySettings struct { // Name of an audio file for notification // // Use SetSound and GetSound helpers. - Sound string + Sound NotificationSoundClass } // InputPeerNotifySettingsTypeID is TL type id of InputPeerNotifySettings. -const InputPeerNotifySettingsTypeID = 0x9c3d198e +const InputPeerNotifySettingsTypeID = 0xdf1f002b // Ensuring interfaces in compile-time for InputPeerNotifySettings. var ( @@ -86,7 +86,7 @@ func (i *InputPeerNotifySettings) Zero() bool { if !(i.MuteUntil == 0) { return false } - if !(i.Sound == "") { + if !(i.Sound == nil) { return false } @@ -107,7 +107,7 @@ func (i *InputPeerNotifySettings) FillFrom(from interface { GetShowPreviews() (value bool, ok bool) GetSilent() (value bool, ok bool) GetMuteUntil() (value int, ok bool) - GetSound() (value string, ok bool) + GetSound() (value NotificationSoundClass, ok bool) }) { if val, ok := from.GetShowPreviews(); ok { i.ShowPreviews = val @@ -185,7 +185,7 @@ func (i *InputPeerNotifySettings) SetFlags() { if !(i.MuteUntil == 0) { i.Flags.Set(2) } - if !(i.Sound == "") { + if !(i.Sound == nil) { i.Flags.Set(3) } } @@ -193,7 +193,7 @@ func (i *InputPeerNotifySettings) SetFlags() { // Encode implements bin.Encoder. func (i *InputPeerNotifySettings) Encode(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't encode inputPeerNotifySettings#9c3d198e as nil") + return fmt.Errorf("can't encode inputPeerNotifySettings#df1f002b as nil") } b.PutID(InputPeerNotifySettingsTypeID) return i.EncodeBare(b) @@ -202,11 +202,11 @@ func (i *InputPeerNotifySettings) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (i *InputPeerNotifySettings) EncodeBare(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't encode inputPeerNotifySettings#9c3d198e as nil") + return fmt.Errorf("can't encode inputPeerNotifySettings#df1f002b as nil") } i.SetFlags() if err := i.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode inputPeerNotifySettings#9c3d198e: field flags: %w", err) + return fmt.Errorf("unable to encode inputPeerNotifySettings#df1f002b: field flags: %w", err) } if i.Flags.Has(0) { b.PutBool(i.ShowPreviews) @@ -218,7 +218,12 @@ func (i *InputPeerNotifySettings) EncodeBare(b *bin.Buffer) error { b.PutInt(i.MuteUntil) } if i.Flags.Has(3) { - b.PutString(i.Sound) + if i.Sound == nil { + return fmt.Errorf("unable to encode inputPeerNotifySettings#df1f002b: field sound is nil") + } + if err := i.Sound.Encode(b); err != nil { + return fmt.Errorf("unable to encode inputPeerNotifySettings#df1f002b: field sound: %w", err) + } } return nil } @@ -226,10 +231,10 @@ func (i *InputPeerNotifySettings) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (i *InputPeerNotifySettings) Decode(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't decode inputPeerNotifySettings#9c3d198e to nil") + return fmt.Errorf("can't decode inputPeerNotifySettings#df1f002b to nil") } if err := b.ConsumeID(InputPeerNotifySettingsTypeID); err != nil { - return fmt.Errorf("unable to decode inputPeerNotifySettings#9c3d198e: %w", err) + return fmt.Errorf("unable to decode inputPeerNotifySettings#df1f002b: %w", err) } return i.DecodeBare(b) } @@ -237,38 +242,38 @@ func (i *InputPeerNotifySettings) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (i *InputPeerNotifySettings) DecodeBare(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't decode inputPeerNotifySettings#9c3d198e to nil") + return fmt.Errorf("can't decode inputPeerNotifySettings#df1f002b to nil") } { if err := i.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode inputPeerNotifySettings#9c3d198e: field flags: %w", err) + return fmt.Errorf("unable to decode inputPeerNotifySettings#df1f002b: field flags: %w", err) } } if i.Flags.Has(0) { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode inputPeerNotifySettings#9c3d198e: field show_previews: %w", err) + return fmt.Errorf("unable to decode inputPeerNotifySettings#df1f002b: field show_previews: %w", err) } i.ShowPreviews = value } if i.Flags.Has(1) { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode inputPeerNotifySettings#9c3d198e: field silent: %w", err) + return fmt.Errorf("unable to decode inputPeerNotifySettings#df1f002b: field silent: %w", err) } i.Silent = value } if i.Flags.Has(2) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode inputPeerNotifySettings#9c3d198e: field mute_until: %w", err) + return fmt.Errorf("unable to decode inputPeerNotifySettings#df1f002b: field mute_until: %w", err) } i.MuteUntil = value } if i.Flags.Has(3) { - value, err := b.String() + value, err := DecodeNotificationSound(b) if err != nil { - return fmt.Errorf("unable to decode inputPeerNotifySettings#9c3d198e: field sound: %w", err) + return fmt.Errorf("unable to decode inputPeerNotifySettings#df1f002b: field sound: %w", err) } i.Sound = value } @@ -330,14 +335,14 @@ func (i *InputPeerNotifySettings) GetMuteUntil() (value int, ok bool) { } // SetSound sets value of Sound conditional field. -func (i *InputPeerNotifySettings) SetSound(value string) { +func (i *InputPeerNotifySettings) SetSound(value NotificationSoundClass) { i.Flags.Set(3) i.Sound = value } // GetSound returns value of Sound conditional field and // boolean which is true if field was set. -func (i *InputPeerNotifySettings) GetSound() (value string, ok bool) { +func (i *InputPeerNotifySettings) GetSound() (value NotificationSoundClass, ok bool) { if i == nil { return } diff --git a/tg/tl_keyboard_button_gen.go b/tg/tl_keyboard_button_gen.go index dac4133e7f..b2350f7ff7 100644 --- a/tg/tl_keyboard_button_gen.go +++ b/tg/tl_keyboard_button_gen.go @@ -2455,6 +2455,328 @@ func (k *KeyboardButtonUserProfile) GetUserID() (value int64) { return k.UserID } +// KeyboardButtonWebView represents TL type `keyboardButtonWebView#13767230`. +// +// See https://core.telegram.org/constructor/keyboardButtonWebView for reference. +type KeyboardButtonWebView struct { + // Text field of KeyboardButtonWebView. + Text string + // URL field of KeyboardButtonWebView. + URL string +} + +// KeyboardButtonWebViewTypeID is TL type id of KeyboardButtonWebView. +const KeyboardButtonWebViewTypeID = 0x13767230 + +// 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.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 { + GetText() (value string) + GetURL() (value string) +}) { + 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: "Text", + SchemaName: "text", + }, + { + Name: "URL", + SchemaName: "url", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (k *KeyboardButtonWebView) Encode(b *bin.Buffer) error { + if k == nil { + return fmt.Errorf("can't encode keyboardButtonWebView#13767230 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#13767230 as nil") + } + 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#13767230 to nil") + } + if err := b.ConsumeID(KeyboardButtonWebViewTypeID); err != nil { + return fmt.Errorf("unable to decode keyboardButtonWebView#13767230: %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#13767230 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode keyboardButtonWebView#13767230: field text: %w", err) + } + k.Text = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode keyboardButtonWebView#13767230: field url: %w", err) + } + k.URL = value + } + return nil +} + +// 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#a0c0505c`. +// +// See https://core.telegram.org/constructor/keyboardButtonSimpleWebView for reference. +type KeyboardButtonSimpleWebView struct { + // Text field of KeyboardButtonSimpleWebView. + Text string + // URL field of KeyboardButtonSimpleWebView. + URL string +} + +// KeyboardButtonSimpleWebViewTypeID is TL type id of KeyboardButtonSimpleWebView. +const KeyboardButtonSimpleWebViewTypeID = 0xa0c0505c + +// 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.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 { + GetText() (value string) + GetURL() (value string) +}) { + 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: "Text", + SchemaName: "text", + }, + { + Name: "URL", + SchemaName: "url", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (k *KeyboardButtonSimpleWebView) Encode(b *bin.Buffer) error { + if k == nil { + return fmt.Errorf("can't encode keyboardButtonSimpleWebView#a0c0505c 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#a0c0505c as nil") + } + 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#a0c0505c to nil") + } + if err := b.ConsumeID(KeyboardButtonSimpleWebViewTypeID); err != nil { + return fmt.Errorf("unable to decode keyboardButtonSimpleWebView#a0c0505c: %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#a0c0505c to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode keyboardButtonSimpleWebView#a0c0505c: field text: %w", err) + } + k.Text = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode keyboardButtonSimpleWebView#a0c0505c: field url: %w", err) + } + k.URL = value + } + return nil +} + +// 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 +} + // KeyboardButtonClassName is schema name of KeyboardButtonClass. const KeyboardButtonClassName = "KeyboardButton" @@ -2481,6 +2803,8 @@ const KeyboardButtonClassName = "KeyboardButton" // case *tg.KeyboardButtonRequestPoll: // keyboardButtonRequestPoll#bbc7515d // case *tg.InputKeyboardButtonUserProfile: // inputKeyboardButtonUserProfile#e988037b // case *tg.KeyboardButtonUserProfile: // keyboardButtonUserProfile#308660c1 +// case *tg.KeyboardButtonWebView: // keyboardButtonWebView#13767230 +// case *tg.KeyboardButtonSimpleWebView: // keyboardButtonSimpleWebView#a0c0505c // default: panic(v) // } type KeyboardButtonClass interface { @@ -2603,6 +2927,20 @@ func DecodeKeyboardButton(buf *bin.Buffer) (KeyboardButtonClass, error) { return nil, fmt.Errorf("unable to decode KeyboardButtonClass: %w", err) } return &v, nil + case KeyboardButtonWebViewTypeID: + // Decoding keyboardButtonWebView#13767230. + 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#a0c0505c. + v := KeyboardButtonSimpleWebView{} + 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)) } diff --git a/tg/tl_keyboard_button_slices_gen.go b/tg/tl_keyboard_button_slices_gen.go index 2b7d853e37..3915018007 100644 --- a/tg/tl_keyboard_button_slices_gen.go +++ b/tg/tl_keyboard_button_slices_gen.go @@ -285,6 +285,32 @@ func (s KeyboardButtonClassArray) AsKeyboardButtonUserProfile() (to KeyboardButt 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 +} + // KeyboardButtonArray is adapter for slice of KeyboardButton. type KeyboardButtonArray []KeyboardButton @@ -1350,3 +1376,167 @@ func (s *KeyboardButtonUserProfileArray) Pop() (v KeyboardButtonUserProfile, ok 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 +} diff --git a/tg/tl_message_action_gen.go b/tg/tl_message_action_gen.go index 99be1c5674..eb1cddfb8a 100644 --- a/tg/tl_message_action_gen.go +++ b/tg/tl_message_action_gen.go @@ -4647,6 +4647,301 @@ func (m *MessageActionChatJoinedByRequest) DecodeBare(b *bin.Buffer) error { return nil } +// MessageActionWebViewDataSentMe represents TL type `messageActionWebViewDataSentMe#47dd8079`. +// +// See https://core.telegram.org/constructor/messageActionWebViewDataSentMe for reference. +type MessageActionWebViewDataSentMe struct { + // Text field of MessageActionWebViewDataSentMe. + Text string + // Data field of MessageActionWebViewDataSentMe. + Data string +} + +// MessageActionWebViewDataSentMeTypeID is TL type id of MessageActionWebViewDataSentMe. +const MessageActionWebViewDataSentMeTypeID = 0x47dd8079 + +// construct implements constructor of MessageActionClass. +func (m MessageActionWebViewDataSentMe) construct() MessageActionClass { return &m } + +// Ensuring interfaces in compile-time for MessageActionWebViewDataSentMe. +var ( + _ bin.Encoder = &MessageActionWebViewDataSentMe{} + _ bin.Decoder = &MessageActionWebViewDataSentMe{} + _ bin.BareEncoder = &MessageActionWebViewDataSentMe{} + _ bin.BareDecoder = &MessageActionWebViewDataSentMe{} + + _ MessageActionClass = &MessageActionWebViewDataSentMe{} +) + +func (m *MessageActionWebViewDataSentMe) Zero() bool { + if m == nil { + return true + } + if !(m.Text == "") { + return false + } + if !(m.Data == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (m *MessageActionWebViewDataSentMe) String() string { + if m == nil { + return "MessageActionWebViewDataSentMe(nil)" + } + type Alias MessageActionWebViewDataSentMe + return fmt.Sprintf("MessageActionWebViewDataSentMe%+v", Alias(*m)) +} + +// FillFrom fills MessageActionWebViewDataSentMe from given interface. +func (m *MessageActionWebViewDataSentMe) FillFrom(from interface { + GetText() (value string) + GetData() (value string) +}) { + m.Text = from.GetText() + m.Data = from.GetData() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessageActionWebViewDataSentMe) TypeID() uint32 { + return MessageActionWebViewDataSentMeTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessageActionWebViewDataSentMe) TypeName() string { + return "messageActionWebViewDataSentMe" +} + +// TypeInfo returns info about TL type. +func (m *MessageActionWebViewDataSentMe) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messageActionWebViewDataSentMe", + ID: MessageActionWebViewDataSentMeTypeID, + } + if m == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Text", + SchemaName: "text", + }, + { + Name: "Data", + SchemaName: "data", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (m *MessageActionWebViewDataSentMe) Encode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionWebViewDataSentMe#47dd8079 as nil") + } + b.PutID(MessageActionWebViewDataSentMeTypeID) + return m.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (m *MessageActionWebViewDataSentMe) EncodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionWebViewDataSentMe#47dd8079 as nil") + } + b.PutString(m.Text) + b.PutString(m.Data) + return nil +} + +// Decode implements bin.Decoder. +func (m *MessageActionWebViewDataSentMe) Decode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionWebViewDataSentMe#47dd8079 to nil") + } + if err := b.ConsumeID(MessageActionWebViewDataSentMeTypeID); err != nil { + return fmt.Errorf("unable to decode messageActionWebViewDataSentMe#47dd8079: %w", err) + } + return m.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (m *MessageActionWebViewDataSentMe) DecodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionWebViewDataSentMe#47dd8079 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messageActionWebViewDataSentMe#47dd8079: field text: %w", err) + } + m.Text = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messageActionWebViewDataSentMe#47dd8079: field data: %w", err) + } + m.Data = value + } + return nil +} + +// GetText returns value of Text field. +func (m *MessageActionWebViewDataSentMe) GetText() (value string) { + if m == nil { + return + } + return m.Text +} + +// GetData returns value of Data field. +func (m *MessageActionWebViewDataSentMe) GetData() (value string) { + if m == nil { + return + } + return m.Data +} + +// MessageActionWebViewDataSent represents TL type `messageActionWebViewDataSent#b4c38cb5`. +// +// See https://core.telegram.org/constructor/messageActionWebViewDataSent for reference. +type MessageActionWebViewDataSent struct { + // Text field of MessageActionWebViewDataSent. + Text string +} + +// MessageActionWebViewDataSentTypeID is TL type id of MessageActionWebViewDataSent. +const MessageActionWebViewDataSentTypeID = 0xb4c38cb5 + +// construct implements constructor of MessageActionClass. +func (m MessageActionWebViewDataSent) construct() MessageActionClass { return &m } + +// Ensuring interfaces in compile-time for MessageActionWebViewDataSent. +var ( + _ bin.Encoder = &MessageActionWebViewDataSent{} + _ bin.Decoder = &MessageActionWebViewDataSent{} + _ bin.BareEncoder = &MessageActionWebViewDataSent{} + _ bin.BareDecoder = &MessageActionWebViewDataSent{} + + _ MessageActionClass = &MessageActionWebViewDataSent{} +) + +func (m *MessageActionWebViewDataSent) Zero() bool { + if m == nil { + return true + } + if !(m.Text == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (m *MessageActionWebViewDataSent) String() string { + if m == nil { + return "MessageActionWebViewDataSent(nil)" + } + type Alias MessageActionWebViewDataSent + return fmt.Sprintf("MessageActionWebViewDataSent%+v", Alias(*m)) +} + +// FillFrom fills MessageActionWebViewDataSent from given interface. +func (m *MessageActionWebViewDataSent) FillFrom(from interface { + GetText() (value string) +}) { + m.Text = from.GetText() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessageActionWebViewDataSent) TypeID() uint32 { + return MessageActionWebViewDataSentTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessageActionWebViewDataSent) TypeName() string { + return "messageActionWebViewDataSent" +} + +// TypeInfo returns info about TL type. +func (m *MessageActionWebViewDataSent) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messageActionWebViewDataSent", + ID: MessageActionWebViewDataSentTypeID, + } + if m == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Text", + SchemaName: "text", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (m *MessageActionWebViewDataSent) Encode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionWebViewDataSent#b4c38cb5 as nil") + } + b.PutID(MessageActionWebViewDataSentTypeID) + return m.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (m *MessageActionWebViewDataSent) EncodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageActionWebViewDataSent#b4c38cb5 as nil") + } + b.PutString(m.Text) + return nil +} + +// Decode implements bin.Decoder. +func (m *MessageActionWebViewDataSent) Decode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionWebViewDataSent#b4c38cb5 to nil") + } + if err := b.ConsumeID(MessageActionWebViewDataSentTypeID); err != nil { + return fmt.Errorf("unable to decode messageActionWebViewDataSent#b4c38cb5: %w", err) + } + return m.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (m *MessageActionWebViewDataSent) DecodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageActionWebViewDataSent#b4c38cb5 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messageActionWebViewDataSent#b4c38cb5: field text: %w", err) + } + m.Text = value + } + return nil +} + +// GetText returns value of Text field. +func (m *MessageActionWebViewDataSent) GetText() (value string) { + if m == nil { + return + } + return m.Text +} + // MessageActionClassName is schema name of MessageActionClass. const MessageActionClassName = "MessageAction" @@ -4690,6 +4985,8 @@ const MessageActionClassName = "MessageAction" // case *tg.MessageActionGroupCallScheduled: // messageActionGroupCallScheduled#b3a07661 // case *tg.MessageActionSetChatTheme: // messageActionSetChatTheme#aa786345 // case *tg.MessageActionChatJoinedByRequest: // messageActionChatJoinedByRequest#ebbca3cb +// case *tg.MessageActionWebViewDataSentMe: // messageActionWebViewDataSentMe#47dd8079 +// case *tg.MessageActionWebViewDataSent: // messageActionWebViewDataSent#b4c38cb5 // default: panic(v) // } type MessageActionClass interface { @@ -4928,6 +5225,20 @@ func DecodeMessageAction(buf *bin.Buffer) (MessageActionClass, error) { return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err) } return &v, nil + case MessageActionWebViewDataSentMeTypeID: + // Decoding messageActionWebViewDataSentMe#47dd8079. + v := MessageActionWebViewDataSentMe{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err) + } + return &v, nil + case MessageActionWebViewDataSentTypeID: + // Decoding messageActionWebViewDataSent#b4c38cb5. + v := MessageActionWebViewDataSent{} + 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 74172795e2..3431de8fad 100644 --- a/tg/tl_message_action_slices_gen.go +++ b/tg/tl_message_action_slices_gen.go @@ -415,6 +415,32 @@ func (s MessageActionClassArray) AsMessageActionSetChatTheme() (to MessageAction return to } +// AsMessageActionWebViewDataSentMe returns copy with only MessageActionWebViewDataSentMe constructors. +func (s MessageActionClassArray) AsMessageActionWebViewDataSentMe() (to MessageActionWebViewDataSentMeArray) { + for _, elem := range s { + value, ok := elem.(*MessageActionWebViewDataSentMe) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsMessageActionWebViewDataSent returns copy with only MessageActionWebViewDataSent constructors. +func (s MessageActionClassArray) AsMessageActionWebViewDataSent() (to MessageActionWebViewDataSentArray) { + for _, elem := range s { + value, ok := elem.(*MessageActionWebViewDataSent) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // MessageActionChatCreateArray is adapter for slice of MessageActionChatCreate. type MessageActionChatCreateArray []MessageActionChatCreate @@ -2300,3 +2326,167 @@ func (s *MessageActionSetChatThemeArray) Pop() (v MessageActionSetChatTheme, ok return v, true } + +// MessageActionWebViewDataSentMeArray is adapter for slice of MessageActionWebViewDataSentMe. +type MessageActionWebViewDataSentMeArray []MessageActionWebViewDataSentMe + +// Sort sorts slice of MessageActionWebViewDataSentMe. +func (s MessageActionWebViewDataSentMeArray) Sort(less func(a, b MessageActionWebViewDataSentMe) bool) MessageActionWebViewDataSentMeArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessageActionWebViewDataSentMe. +func (s MessageActionWebViewDataSentMeArray) SortStable(less func(a, b MessageActionWebViewDataSentMe) bool) MessageActionWebViewDataSentMeArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessageActionWebViewDataSentMe. +func (s MessageActionWebViewDataSentMeArray) Retain(keep func(x MessageActionWebViewDataSentMe) bool) MessageActionWebViewDataSentMeArray { + 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 MessageActionWebViewDataSentMeArray) First() (v MessageActionWebViewDataSentMe, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessageActionWebViewDataSentMeArray) Last() (v MessageActionWebViewDataSentMe, 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 *MessageActionWebViewDataSentMeArray) PopFirst() (v MessageActionWebViewDataSentMe, 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 MessageActionWebViewDataSentMe + 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 *MessageActionWebViewDataSentMeArray) Pop() (v MessageActionWebViewDataSentMe, 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 +} + +// MessageActionWebViewDataSentArray is adapter for slice of MessageActionWebViewDataSent. +type MessageActionWebViewDataSentArray []MessageActionWebViewDataSent + +// Sort sorts slice of MessageActionWebViewDataSent. +func (s MessageActionWebViewDataSentArray) Sort(less func(a, b MessageActionWebViewDataSent) bool) MessageActionWebViewDataSentArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of MessageActionWebViewDataSent. +func (s MessageActionWebViewDataSentArray) SortStable(less func(a, b MessageActionWebViewDataSent) bool) MessageActionWebViewDataSentArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of MessageActionWebViewDataSent. +func (s MessageActionWebViewDataSentArray) Retain(keep func(x MessageActionWebViewDataSent) bool) MessageActionWebViewDataSentArray { + 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 MessageActionWebViewDataSentArray) First() (v MessageActionWebViewDataSent, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s MessageActionWebViewDataSentArray) Last() (v MessageActionWebViewDataSent, 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 *MessageActionWebViewDataSentArray) PopFirst() (v MessageActionWebViewDataSent, 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 MessageActionWebViewDataSent + 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 *MessageActionWebViewDataSentArray) Pop() (v MessageActionWebViewDataSent, 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_get_attach_menu_bot_gen.go b/tg/tl_messages_get_attach_menu_bot_gen.go new file mode 100644 index 0000000000..af95ed91aa --- /dev/null +++ b/tg/tl_messages_get_attach_menu_bot_gen.go @@ -0,0 +1,181 @@ +// 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{} +) + +// MessagesGetAttachMenuBotRequest represents TL type `messages.getAttachMenuBot#77216192`. +// +// See https://core.telegram.org/method/messages.getAttachMenuBot for reference. +type MessagesGetAttachMenuBotRequest struct { + // Bot field of MessagesGetAttachMenuBotRequest. + Bot InputUserClass +} + +// MessagesGetAttachMenuBotRequestTypeID is TL type id of MessagesGetAttachMenuBotRequest. +const MessagesGetAttachMenuBotRequestTypeID = 0x77216192 + +// Ensuring interfaces in compile-time for MessagesGetAttachMenuBotRequest. +var ( + _ bin.Encoder = &MessagesGetAttachMenuBotRequest{} + _ bin.Decoder = &MessagesGetAttachMenuBotRequest{} + _ bin.BareEncoder = &MessagesGetAttachMenuBotRequest{} + _ bin.BareDecoder = &MessagesGetAttachMenuBotRequest{} +) + +func (g *MessagesGetAttachMenuBotRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Bot == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *MessagesGetAttachMenuBotRequest) String() string { + if g == nil { + return "MessagesGetAttachMenuBotRequest(nil)" + } + type Alias MessagesGetAttachMenuBotRequest + return fmt.Sprintf("MessagesGetAttachMenuBotRequest%+v", Alias(*g)) +} + +// FillFrom fills MessagesGetAttachMenuBotRequest from given interface. +func (g *MessagesGetAttachMenuBotRequest) FillFrom(from interface { + GetBot() (value InputUserClass) +}) { + g.Bot = from.GetBot() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesGetAttachMenuBotRequest) TypeID() uint32 { + return MessagesGetAttachMenuBotRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesGetAttachMenuBotRequest) TypeName() string { + return "messages.getAttachMenuBot" +} + +// TypeInfo returns info about TL type. +func (g *MessagesGetAttachMenuBotRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.getAttachMenuBot", + ID: MessagesGetAttachMenuBotRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Bot", + SchemaName: "bot", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *MessagesGetAttachMenuBotRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode messages.getAttachMenuBot#77216192 as nil") + } + b.PutID(MessagesGetAttachMenuBotRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *MessagesGetAttachMenuBotRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode messages.getAttachMenuBot#77216192 as nil") + } + if g.Bot == nil { + return fmt.Errorf("unable to encode messages.getAttachMenuBot#77216192: field bot is nil") + } + if err := g.Bot.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.getAttachMenuBot#77216192: field bot: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (g *MessagesGetAttachMenuBotRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode messages.getAttachMenuBot#77216192 to nil") + } + if err := b.ConsumeID(MessagesGetAttachMenuBotRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.getAttachMenuBot#77216192: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *MessagesGetAttachMenuBotRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode messages.getAttachMenuBot#77216192 to nil") + } + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode messages.getAttachMenuBot#77216192: field bot: %w", err) + } + g.Bot = value + } + return nil +} + +// GetBot returns value of Bot field. +func (g *MessagesGetAttachMenuBotRequest) GetBot() (value InputUserClass) { + if g == nil { + return + } + return g.Bot +} + +// MessagesGetAttachMenuBot invokes method messages.getAttachMenuBot#77216192 returning error if any. +// +// See https://core.telegram.org/method/messages.getAttachMenuBot for reference. +func (c *Client) MessagesGetAttachMenuBot(ctx context.Context, bot InputUserClass) (*AttachMenuBotsBot, error) { + var result AttachMenuBotsBot + + request := &MessagesGetAttachMenuBotRequest{ + Bot: bot, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_messages_get_attach_menu_bot_slices_gen.go b/tg/tl_messages_get_attach_menu_bot_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_get_attach_menu_bot_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_messages_get_attach_menu_bots_gen.go b/tg/tl_messages_get_attach_menu_bots_gen.go new file mode 100644 index 0000000000..22538aab5b --- /dev/null +++ b/tg/tl_messages_get_attach_menu_bots_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{} +) + +// MessagesGetAttachMenuBotsRequest represents TL type `messages.getAttachMenuBots#16fcc2cb`. +// +// See https://core.telegram.org/method/messages.getAttachMenuBots for reference. +type MessagesGetAttachMenuBotsRequest struct { + // Hash field of MessagesGetAttachMenuBotsRequest. + Hash int64 +} + +// MessagesGetAttachMenuBotsRequestTypeID is TL type id of MessagesGetAttachMenuBotsRequest. +const MessagesGetAttachMenuBotsRequestTypeID = 0x16fcc2cb + +// Ensuring interfaces in compile-time for MessagesGetAttachMenuBotsRequest. +var ( + _ bin.Encoder = &MessagesGetAttachMenuBotsRequest{} + _ bin.Decoder = &MessagesGetAttachMenuBotsRequest{} + _ bin.BareEncoder = &MessagesGetAttachMenuBotsRequest{} + _ bin.BareDecoder = &MessagesGetAttachMenuBotsRequest{} +) + +func (g *MessagesGetAttachMenuBotsRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Hash == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *MessagesGetAttachMenuBotsRequest) String() string { + if g == nil { + return "MessagesGetAttachMenuBotsRequest(nil)" + } + type Alias MessagesGetAttachMenuBotsRequest + return fmt.Sprintf("MessagesGetAttachMenuBotsRequest%+v", Alias(*g)) +} + +// FillFrom fills MessagesGetAttachMenuBotsRequest from given interface. +func (g *MessagesGetAttachMenuBotsRequest) FillFrom(from interface { + GetHash() (value int64) +}) { + g.Hash = from.GetHash() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesGetAttachMenuBotsRequest) TypeID() uint32 { + return MessagesGetAttachMenuBotsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesGetAttachMenuBotsRequest) TypeName() string { + return "messages.getAttachMenuBots" +} + +// TypeInfo returns info about TL type. +func (g *MessagesGetAttachMenuBotsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.getAttachMenuBots", + ID: MessagesGetAttachMenuBotsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Hash", + SchemaName: "hash", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *MessagesGetAttachMenuBotsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode messages.getAttachMenuBots#16fcc2cb as nil") + } + b.PutID(MessagesGetAttachMenuBotsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *MessagesGetAttachMenuBotsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode messages.getAttachMenuBots#16fcc2cb as nil") + } + b.PutLong(g.Hash) + return nil +} + +// Decode implements bin.Decoder. +func (g *MessagesGetAttachMenuBotsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode messages.getAttachMenuBots#16fcc2cb to nil") + } + if err := b.ConsumeID(MessagesGetAttachMenuBotsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.getAttachMenuBots#16fcc2cb: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *MessagesGetAttachMenuBotsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode messages.getAttachMenuBots#16fcc2cb to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messages.getAttachMenuBots#16fcc2cb: field hash: %w", err) + } + g.Hash = value + } + return nil +} + +// GetHash returns value of Hash field. +func (g *MessagesGetAttachMenuBotsRequest) GetHash() (value int64) { + if g == nil { + return + } + return g.Hash +} + +// MessagesGetAttachMenuBots invokes method messages.getAttachMenuBots#16fcc2cb returning error if any. +// +// See https://core.telegram.org/method/messages.getAttachMenuBots for reference. +func (c *Client) MessagesGetAttachMenuBots(ctx context.Context, hash int64) (AttachMenuBotsClass, error) { + var result AttachMenuBotsBox + + request := &MessagesGetAttachMenuBotsRequest{ + Hash: hash, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return result.AttachMenuBots, nil +} diff --git a/tg/tl_messages_get_attach_menu_bots_slices_gen.go b/tg/tl_messages_get_attach_menu_bots_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_get_attach_menu_bots_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_messages_prolong_web_view_gen.go b/tg/tl_messages_prolong_web_view_gen.go new file mode 100644 index 0000000000..08b4a4a197 --- /dev/null +++ b/tg/tl_messages_prolong_web_view_gen.go @@ -0,0 +1,339 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// MessagesProlongWebViewRequest represents TL type `messages.prolongWebView#d22ad148`. +// +// See https://core.telegram.org/method/messages.prolongWebView for reference. +type MessagesProlongWebViewRequest struct { + // Flags field of MessagesProlongWebViewRequest. + Flags bin.Fields + // Silent field of MessagesProlongWebViewRequest. + Silent bool + // Peer field of MessagesProlongWebViewRequest. + Peer InputPeerClass + // Bot field of MessagesProlongWebViewRequest. + Bot InputUserClass + // QueryID field of MessagesProlongWebViewRequest. + QueryID int64 + // ReplyToMsgID field of MessagesProlongWebViewRequest. + // + // Use SetReplyToMsgID and GetReplyToMsgID helpers. + ReplyToMsgID int +} + +// MessagesProlongWebViewRequestTypeID is TL type id of MessagesProlongWebViewRequest. +const MessagesProlongWebViewRequestTypeID = 0xd22ad148 + +// Ensuring interfaces in compile-time for MessagesProlongWebViewRequest. +var ( + _ bin.Encoder = &MessagesProlongWebViewRequest{} + _ bin.Decoder = &MessagesProlongWebViewRequest{} + _ bin.BareEncoder = &MessagesProlongWebViewRequest{} + _ bin.BareDecoder = &MessagesProlongWebViewRequest{} +) + +func (p *MessagesProlongWebViewRequest) Zero() bool { + if p == nil { + return true + } + if !(p.Flags.Zero()) { + return false + } + if !(p.Silent == false) { + return false + } + if !(p.Peer == nil) { + return false + } + if !(p.Bot == nil) { + return false + } + if !(p.QueryID == 0) { + return false + } + if !(p.ReplyToMsgID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (p *MessagesProlongWebViewRequest) String() string { + if p == nil { + return "MessagesProlongWebViewRequest(nil)" + } + type Alias MessagesProlongWebViewRequest + return fmt.Sprintf("MessagesProlongWebViewRequest%+v", Alias(*p)) +} + +// FillFrom fills MessagesProlongWebViewRequest from given interface. +func (p *MessagesProlongWebViewRequest) FillFrom(from interface { + GetSilent() (value bool) + GetPeer() (value InputPeerClass) + GetBot() (value InputUserClass) + GetQueryID() (value int64) + GetReplyToMsgID() (value int, ok bool) +}) { + p.Silent = from.GetSilent() + p.Peer = from.GetPeer() + p.Bot = from.GetBot() + p.QueryID = from.GetQueryID() + if val, ok := from.GetReplyToMsgID(); ok { + p.ReplyToMsgID = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesProlongWebViewRequest) TypeID() uint32 { + return MessagesProlongWebViewRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesProlongWebViewRequest) TypeName() string { + return "messages.prolongWebView" +} + +// TypeInfo returns info about TL type. +func (p *MessagesProlongWebViewRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.prolongWebView", + ID: MessagesProlongWebViewRequestTypeID, + } + if p == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Silent", + SchemaName: "silent", + Null: !p.Flags.Has(5), + }, + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "Bot", + SchemaName: "bot", + }, + { + Name: "QueryID", + SchemaName: "query_id", + }, + { + Name: "ReplyToMsgID", + SchemaName: "reply_to_msg_id", + Null: !p.Flags.Has(0), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (p *MessagesProlongWebViewRequest) SetFlags() { + if !(p.Silent == false) { + p.Flags.Set(5) + } + if !(p.ReplyToMsgID == 0) { + p.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (p *MessagesProlongWebViewRequest) Encode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode messages.prolongWebView#d22ad148 as nil") + } + b.PutID(MessagesProlongWebViewRequestTypeID) + return p.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (p *MessagesProlongWebViewRequest) EncodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't encode messages.prolongWebView#d22ad148 as nil") + } + p.SetFlags() + if err := p.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.prolongWebView#d22ad148: field flags: %w", err) + } + if p.Peer == nil { + return fmt.Errorf("unable to encode messages.prolongWebView#d22ad148: field peer is nil") + } + if err := p.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.prolongWebView#d22ad148: field peer: %w", err) + } + if p.Bot == nil { + return fmt.Errorf("unable to encode messages.prolongWebView#d22ad148: field bot is nil") + } + if err := p.Bot.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.prolongWebView#d22ad148: field bot: %w", err) + } + b.PutLong(p.QueryID) + if p.Flags.Has(0) { + b.PutInt(p.ReplyToMsgID) + } + return nil +} + +// Decode implements bin.Decoder. +func (p *MessagesProlongWebViewRequest) Decode(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode messages.prolongWebView#d22ad148 to nil") + } + if err := b.ConsumeID(MessagesProlongWebViewRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.prolongWebView#d22ad148: %w", err) + } + return p.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (p *MessagesProlongWebViewRequest) DecodeBare(b *bin.Buffer) error { + if p == nil { + return fmt.Errorf("can't decode messages.prolongWebView#d22ad148 to nil") + } + { + if err := p.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.prolongWebView#d22ad148: field flags: %w", err) + } + } + p.Silent = p.Flags.Has(5) + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode messages.prolongWebView#d22ad148: field peer: %w", err) + } + p.Peer = value + } + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode messages.prolongWebView#d22ad148: field bot: %w", err) + } + p.Bot = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messages.prolongWebView#d22ad148: field query_id: %w", err) + } + p.QueryID = value + } + if p.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.prolongWebView#d22ad148: field reply_to_msg_id: %w", err) + } + p.ReplyToMsgID = value + } + return nil +} + +// SetSilent sets value of Silent conditional field. +func (p *MessagesProlongWebViewRequest) SetSilent(value bool) { + if value { + p.Flags.Set(5) + p.Silent = true + } else { + p.Flags.Unset(5) + p.Silent = false + } +} + +// GetSilent returns value of Silent conditional field. +func (p *MessagesProlongWebViewRequest) GetSilent() (value bool) { + if p == nil { + return + } + return p.Flags.Has(5) +} + +// GetPeer returns value of Peer field. +func (p *MessagesProlongWebViewRequest) GetPeer() (value InputPeerClass) { + if p == nil { + return + } + return p.Peer +} + +// GetBot returns value of Bot field. +func (p *MessagesProlongWebViewRequest) GetBot() (value InputUserClass) { + if p == nil { + return + } + return p.Bot +} + +// GetQueryID returns value of QueryID field. +func (p *MessagesProlongWebViewRequest) GetQueryID() (value int64) { + if p == nil { + return + } + return p.QueryID +} + +// SetReplyToMsgID sets value of ReplyToMsgID conditional field. +func (p *MessagesProlongWebViewRequest) SetReplyToMsgID(value int) { + p.Flags.Set(0) + p.ReplyToMsgID = value +} + +// GetReplyToMsgID returns value of ReplyToMsgID conditional field and +// boolean which is true if field was set. +func (p *MessagesProlongWebViewRequest) GetReplyToMsgID() (value int, ok bool) { + if p == nil { + return + } + if !p.Flags.Has(0) { + return value, false + } + return p.ReplyToMsgID, true +} + +// MessagesProlongWebView invokes method messages.prolongWebView#d22ad148 returning error if any. +// +// See https://core.telegram.org/method/messages.prolongWebView for reference. +func (c *Client) MessagesProlongWebView(ctx context.Context, request *MessagesProlongWebViewRequest) (bool, error) { + var result BoolBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return false, err + } + _, ok := result.Bool.(*BoolTrue) + return ok, nil +} diff --git a/tg/tl_messages_prolong_web_view_slices_gen.go b/tg/tl_messages_prolong_web_view_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_prolong_web_view_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_messages_request_simple_web_view_gen.go b/tg/tl_messages_request_simple_web_view_gen.go new file mode 100644 index 0000000000..136c5b1259 --- /dev/null +++ b/tg/tl_messages_request_simple_web_view_gen.go @@ -0,0 +1,271 @@ +// 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{} +) + +// MessagesRequestSimpleWebViewRequest represents TL type `messages.requestSimpleWebView#6abb2f73`. +// +// See https://core.telegram.org/method/messages.requestSimpleWebView for reference. +type MessagesRequestSimpleWebViewRequest struct { + // Flags field of MessagesRequestSimpleWebViewRequest. + Flags bin.Fields + // Bot field of MessagesRequestSimpleWebViewRequest. + Bot InputUserClass + // URL field of MessagesRequestSimpleWebViewRequest. + URL string + // ThemeParams field of MessagesRequestSimpleWebViewRequest. + // + // Use SetThemeParams and GetThemeParams helpers. + ThemeParams DataJSON +} + +// MessagesRequestSimpleWebViewRequestTypeID is TL type id of MessagesRequestSimpleWebViewRequest. +const MessagesRequestSimpleWebViewRequestTypeID = 0x6abb2f73 + +// Ensuring interfaces in compile-time for MessagesRequestSimpleWebViewRequest. +var ( + _ bin.Encoder = &MessagesRequestSimpleWebViewRequest{} + _ bin.Decoder = &MessagesRequestSimpleWebViewRequest{} + _ bin.BareEncoder = &MessagesRequestSimpleWebViewRequest{} + _ bin.BareDecoder = &MessagesRequestSimpleWebViewRequest{} +) + +func (r *MessagesRequestSimpleWebViewRequest) Zero() bool { + if r == nil { + return true + } + if !(r.Flags.Zero()) { + return false + } + if !(r.Bot == nil) { + return false + } + if !(r.URL == "") { + return false + } + if !(r.ThemeParams.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (r *MessagesRequestSimpleWebViewRequest) String() string { + if r == nil { + return "MessagesRequestSimpleWebViewRequest(nil)" + } + type Alias MessagesRequestSimpleWebViewRequest + return fmt.Sprintf("MessagesRequestSimpleWebViewRequest%+v", Alias(*r)) +} + +// FillFrom fills MessagesRequestSimpleWebViewRequest from given interface. +func (r *MessagesRequestSimpleWebViewRequest) FillFrom(from interface { + GetBot() (value InputUserClass) + GetURL() (value string) + GetThemeParams() (value DataJSON, ok bool) +}) { + r.Bot = from.GetBot() + r.URL = from.GetURL() + if val, ok := from.GetThemeParams(); ok { + r.ThemeParams = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesRequestSimpleWebViewRequest) TypeID() uint32 { + return MessagesRequestSimpleWebViewRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesRequestSimpleWebViewRequest) TypeName() string { + return "messages.requestSimpleWebView" +} + +// TypeInfo returns info about TL type. +func (r *MessagesRequestSimpleWebViewRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.requestSimpleWebView", + ID: MessagesRequestSimpleWebViewRequestTypeID, + } + if r == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Bot", + SchemaName: "bot", + }, + { + Name: "URL", + SchemaName: "url", + }, + { + Name: "ThemeParams", + SchemaName: "theme_params", + Null: !r.Flags.Has(0), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (r *MessagesRequestSimpleWebViewRequest) SetFlags() { + if !(r.ThemeParams.Zero()) { + r.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (r *MessagesRequestSimpleWebViewRequest) Encode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode messages.requestSimpleWebView#6abb2f73 as nil") + } + b.PutID(MessagesRequestSimpleWebViewRequestTypeID) + return r.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (r *MessagesRequestSimpleWebViewRequest) EncodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode messages.requestSimpleWebView#6abb2f73 as nil") + } + r.SetFlags() + if err := r.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.requestSimpleWebView#6abb2f73: field flags: %w", err) + } + if r.Bot == nil { + return fmt.Errorf("unable to encode messages.requestSimpleWebView#6abb2f73: field bot is nil") + } + if err := r.Bot.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.requestSimpleWebView#6abb2f73: field bot: %w", err) + } + b.PutString(r.URL) + if r.Flags.Has(0) { + if err := r.ThemeParams.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.requestSimpleWebView#6abb2f73: field theme_params: %w", err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (r *MessagesRequestSimpleWebViewRequest) Decode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode messages.requestSimpleWebView#6abb2f73 to nil") + } + if err := b.ConsumeID(MessagesRequestSimpleWebViewRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.requestSimpleWebView#6abb2f73: %w", err) + } + return r.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (r *MessagesRequestSimpleWebViewRequest) DecodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode messages.requestSimpleWebView#6abb2f73 to nil") + } + { + if err := r.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.requestSimpleWebView#6abb2f73: field flags: %w", err) + } + } + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode messages.requestSimpleWebView#6abb2f73: field bot: %w", err) + } + r.Bot = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messages.requestSimpleWebView#6abb2f73: field url: %w", err) + } + r.URL = value + } + if r.Flags.Has(0) { + if err := r.ThemeParams.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.requestSimpleWebView#6abb2f73: field theme_params: %w", err) + } + } + return nil +} + +// GetBot returns value of Bot field. +func (r *MessagesRequestSimpleWebViewRequest) GetBot() (value InputUserClass) { + if r == nil { + return + } + return r.Bot +} + +// GetURL returns value of URL field. +func (r *MessagesRequestSimpleWebViewRequest) GetURL() (value string) { + if r == nil { + return + } + return r.URL +} + +// SetThemeParams sets value of ThemeParams conditional field. +func (r *MessagesRequestSimpleWebViewRequest) SetThemeParams(value DataJSON) { + r.Flags.Set(0) + r.ThemeParams = value +} + +// GetThemeParams returns value of ThemeParams conditional field and +// boolean which is true if field was set. +func (r *MessagesRequestSimpleWebViewRequest) GetThemeParams() (value DataJSON, ok bool) { + if r == nil { + return + } + if !r.Flags.Has(0) { + return value, false + } + return r.ThemeParams, true +} + +// MessagesRequestSimpleWebView invokes method messages.requestSimpleWebView#6abb2f73 returning error if any. +// +// See https://core.telegram.org/method/messages.requestSimpleWebView for reference. +func (c *Client) MessagesRequestSimpleWebView(ctx context.Context, request *MessagesRequestSimpleWebViewRequest) (*SimpleWebViewResultURL, error) { + var result SimpleWebViewResultURL + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_messages_request_simple_web_view_slices_gen.go b/tg/tl_messages_request_simple_web_view_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_request_simple_web_view_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_messages_request_web_view_gen.go b/tg/tl_messages_request_web_view_gen.go new file mode 100644 index 0000000000..a3697ad009 --- /dev/null +++ b/tg/tl_messages_request_web_view_gen.go @@ -0,0 +1,490 @@ +// 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{} +) + +// MessagesRequestWebViewRequest represents TL type `messages.requestWebView#fa04dff`. +// +// See https://core.telegram.org/method/messages.requestWebView for reference. +type MessagesRequestWebViewRequest struct { + // Flags field of MessagesRequestWebViewRequest. + Flags bin.Fields + // FromBotMenu field of MessagesRequestWebViewRequest. + FromBotMenu bool + // Silent field of MessagesRequestWebViewRequest. + Silent bool + // Peer field of MessagesRequestWebViewRequest. + Peer InputPeerClass + // Bot field of MessagesRequestWebViewRequest. + Bot InputUserClass + // URL field of MessagesRequestWebViewRequest. + // + // Use SetURL and GetURL helpers. + URL string + // StartParam field of MessagesRequestWebViewRequest. + // + // Use SetStartParam and GetStartParam helpers. + StartParam string + // ThemeParams field of MessagesRequestWebViewRequest. + // + // Use SetThemeParams and GetThemeParams helpers. + ThemeParams DataJSON + // ReplyToMsgID field of MessagesRequestWebViewRequest. + // + // Use SetReplyToMsgID and GetReplyToMsgID helpers. + ReplyToMsgID int +} + +// MessagesRequestWebViewRequestTypeID is TL type id of MessagesRequestWebViewRequest. +const MessagesRequestWebViewRequestTypeID = 0xfa04dff + +// Ensuring interfaces in compile-time for MessagesRequestWebViewRequest. +var ( + _ bin.Encoder = &MessagesRequestWebViewRequest{} + _ bin.Decoder = &MessagesRequestWebViewRequest{} + _ bin.BareEncoder = &MessagesRequestWebViewRequest{} + _ bin.BareDecoder = &MessagesRequestWebViewRequest{} +) + +func (r *MessagesRequestWebViewRequest) Zero() bool { + if r == nil { + return true + } + if !(r.Flags.Zero()) { + return false + } + if !(r.FromBotMenu == false) { + return false + } + if !(r.Silent == false) { + return false + } + if !(r.Peer == nil) { + return false + } + if !(r.Bot == nil) { + return false + } + if !(r.URL == "") { + return false + } + if !(r.StartParam == "") { + return false + } + if !(r.ThemeParams.Zero()) { + return false + } + if !(r.ReplyToMsgID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (r *MessagesRequestWebViewRequest) String() string { + if r == nil { + return "MessagesRequestWebViewRequest(nil)" + } + type Alias MessagesRequestWebViewRequest + return fmt.Sprintf("MessagesRequestWebViewRequest%+v", Alias(*r)) +} + +// FillFrom fills MessagesRequestWebViewRequest from given interface. +func (r *MessagesRequestWebViewRequest) FillFrom(from interface { + GetFromBotMenu() (value bool) + GetSilent() (value bool) + GetPeer() (value InputPeerClass) + GetBot() (value InputUserClass) + GetURL() (value string, ok bool) + GetStartParam() (value string, ok bool) + GetThemeParams() (value DataJSON, ok bool) + GetReplyToMsgID() (value int, ok bool) +}) { + r.FromBotMenu = from.GetFromBotMenu() + r.Silent = from.GetSilent() + r.Peer = from.GetPeer() + r.Bot = from.GetBot() + if val, ok := from.GetURL(); ok { + r.URL = val + } + + if val, ok := from.GetStartParam(); ok { + r.StartParam = val + } + + if val, ok := from.GetThemeParams(); ok { + r.ThemeParams = val + } + + if val, ok := from.GetReplyToMsgID(); ok { + r.ReplyToMsgID = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesRequestWebViewRequest) TypeID() uint32 { + return MessagesRequestWebViewRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesRequestWebViewRequest) TypeName() string { + return "messages.requestWebView" +} + +// TypeInfo returns info about TL type. +func (r *MessagesRequestWebViewRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.requestWebView", + ID: MessagesRequestWebViewRequestTypeID, + } + if r == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "FromBotMenu", + SchemaName: "from_bot_menu", + Null: !r.Flags.Has(4), + }, + { + Name: "Silent", + SchemaName: "silent", + Null: !r.Flags.Has(5), + }, + { + Name: "Peer", + SchemaName: "peer", + }, + { + Name: "Bot", + SchemaName: "bot", + }, + { + Name: "URL", + SchemaName: "url", + Null: !r.Flags.Has(1), + }, + { + Name: "StartParam", + SchemaName: "start_param", + Null: !r.Flags.Has(3), + }, + { + Name: "ThemeParams", + SchemaName: "theme_params", + Null: !r.Flags.Has(2), + }, + { + Name: "ReplyToMsgID", + SchemaName: "reply_to_msg_id", + Null: !r.Flags.Has(0), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (r *MessagesRequestWebViewRequest) SetFlags() { + if !(r.FromBotMenu == false) { + r.Flags.Set(4) + } + if !(r.Silent == false) { + r.Flags.Set(5) + } + if !(r.URL == "") { + r.Flags.Set(1) + } + if !(r.StartParam == "") { + r.Flags.Set(3) + } + if !(r.ThemeParams.Zero()) { + r.Flags.Set(2) + } + if !(r.ReplyToMsgID == 0) { + r.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (r *MessagesRequestWebViewRequest) Encode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode messages.requestWebView#fa04dff as nil") + } + b.PutID(MessagesRequestWebViewRequestTypeID) + return r.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (r *MessagesRequestWebViewRequest) EncodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode messages.requestWebView#fa04dff as nil") + } + r.SetFlags() + if err := r.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.requestWebView#fa04dff: field flags: %w", err) + } + if r.Peer == nil { + return fmt.Errorf("unable to encode messages.requestWebView#fa04dff: field peer is nil") + } + if err := r.Peer.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.requestWebView#fa04dff: field peer: %w", err) + } + if r.Bot == nil { + return fmt.Errorf("unable to encode messages.requestWebView#fa04dff: field bot is nil") + } + if err := r.Bot.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.requestWebView#fa04dff: field bot: %w", err) + } + if r.Flags.Has(1) { + b.PutString(r.URL) + } + if r.Flags.Has(3) { + b.PutString(r.StartParam) + } + if r.Flags.Has(2) { + if err := r.ThemeParams.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.requestWebView#fa04dff: field theme_params: %w", err) + } + } + if r.Flags.Has(0) { + b.PutInt(r.ReplyToMsgID) + } + return nil +} + +// Decode implements bin.Decoder. +func (r *MessagesRequestWebViewRequest) Decode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode messages.requestWebView#fa04dff to nil") + } + if err := b.ConsumeID(MessagesRequestWebViewRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.requestWebView#fa04dff: %w", err) + } + return r.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (r *MessagesRequestWebViewRequest) DecodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode messages.requestWebView#fa04dff to nil") + } + { + if err := r.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.requestWebView#fa04dff: field flags: %w", err) + } + } + r.FromBotMenu = r.Flags.Has(4) + r.Silent = r.Flags.Has(5) + { + value, err := DecodeInputPeer(b) + if err != nil { + return fmt.Errorf("unable to decode messages.requestWebView#fa04dff: field peer: %w", err) + } + r.Peer = value + } + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode messages.requestWebView#fa04dff: field bot: %w", err) + } + r.Bot = value + } + if r.Flags.Has(1) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messages.requestWebView#fa04dff: field url: %w", err) + } + r.URL = value + } + if r.Flags.Has(3) { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messages.requestWebView#fa04dff: field start_param: %w", err) + } + r.StartParam = value + } + if r.Flags.Has(2) { + if err := r.ThemeParams.Decode(b); err != nil { + return fmt.Errorf("unable to decode messages.requestWebView#fa04dff: field theme_params: %w", err) + } + } + if r.Flags.Has(0) { + value, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode messages.requestWebView#fa04dff: field reply_to_msg_id: %w", err) + } + r.ReplyToMsgID = value + } + return nil +} + +// SetFromBotMenu sets value of FromBotMenu conditional field. +func (r *MessagesRequestWebViewRequest) SetFromBotMenu(value bool) { + if value { + r.Flags.Set(4) + r.FromBotMenu = true + } else { + r.Flags.Unset(4) + r.FromBotMenu = false + } +} + +// GetFromBotMenu returns value of FromBotMenu conditional field. +func (r *MessagesRequestWebViewRequest) GetFromBotMenu() (value bool) { + if r == nil { + return + } + return r.Flags.Has(4) +} + +// SetSilent sets value of Silent conditional field. +func (r *MessagesRequestWebViewRequest) SetSilent(value bool) { + if value { + r.Flags.Set(5) + r.Silent = true + } else { + r.Flags.Unset(5) + r.Silent = false + } +} + +// GetSilent returns value of Silent conditional field. +func (r *MessagesRequestWebViewRequest) GetSilent() (value bool) { + if r == nil { + return + } + return r.Flags.Has(5) +} + +// GetPeer returns value of Peer field. +func (r *MessagesRequestWebViewRequest) GetPeer() (value InputPeerClass) { + if r == nil { + return + } + return r.Peer +} + +// GetBot returns value of Bot field. +func (r *MessagesRequestWebViewRequest) GetBot() (value InputUserClass) { + if r == nil { + return + } + return r.Bot +} + +// SetURL sets value of URL conditional field. +func (r *MessagesRequestWebViewRequest) SetURL(value string) { + r.Flags.Set(1) + r.URL = value +} + +// GetURL returns value of URL conditional field and +// boolean which is true if field was set. +func (r *MessagesRequestWebViewRequest) GetURL() (value string, ok bool) { + if r == nil { + return + } + if !r.Flags.Has(1) { + return value, false + } + return r.URL, true +} + +// SetStartParam sets value of StartParam conditional field. +func (r *MessagesRequestWebViewRequest) SetStartParam(value string) { + r.Flags.Set(3) + r.StartParam = value +} + +// GetStartParam returns value of StartParam conditional field and +// boolean which is true if field was set. +func (r *MessagesRequestWebViewRequest) GetStartParam() (value string, ok bool) { + if r == nil { + return + } + if !r.Flags.Has(3) { + return value, false + } + return r.StartParam, true +} + +// SetThemeParams sets value of ThemeParams conditional field. +func (r *MessagesRequestWebViewRequest) SetThemeParams(value DataJSON) { + r.Flags.Set(2) + r.ThemeParams = value +} + +// GetThemeParams returns value of ThemeParams conditional field and +// boolean which is true if field was set. +func (r *MessagesRequestWebViewRequest) GetThemeParams() (value DataJSON, ok bool) { + if r == nil { + return + } + if !r.Flags.Has(2) { + return value, false + } + return r.ThemeParams, true +} + +// SetReplyToMsgID sets value of ReplyToMsgID conditional field. +func (r *MessagesRequestWebViewRequest) SetReplyToMsgID(value int) { + r.Flags.Set(0) + r.ReplyToMsgID = value +} + +// GetReplyToMsgID returns value of ReplyToMsgID conditional field and +// boolean which is true if field was set. +func (r *MessagesRequestWebViewRequest) GetReplyToMsgID() (value int, ok bool) { + if r == nil { + return + } + if !r.Flags.Has(0) { + return value, false + } + return r.ReplyToMsgID, true +} + +// MessagesRequestWebView invokes method messages.requestWebView#fa04dff returning error if any. +// +// See https://core.telegram.org/method/messages.requestWebView for reference. +func (c *Client) MessagesRequestWebView(ctx context.Context, request *MessagesRequestWebViewRequest) (*WebViewResultURL, error) { + var result WebViewResultURL + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_messages_request_web_view_slices_gen.go b/tg/tl_messages_request_web_view_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_request_web_view_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_messages_send_web_view_data_gen.go b/tg/tl_messages_send_web_view_data_gen.go new file mode 100644 index 0000000000..5b37f25f2c --- /dev/null +++ b/tg/tl_messages_send_web_view_data_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{} +) + +// MessagesSendWebViewDataRequest represents TL type `messages.sendWebViewData#dc0242c8`. +// +// See https://core.telegram.org/method/messages.sendWebViewData for reference. +type MessagesSendWebViewDataRequest struct { + // Bot field of MessagesSendWebViewDataRequest. + Bot InputUserClass + // RandomID field of MessagesSendWebViewDataRequest. + RandomID int64 + // ButtonText field of MessagesSendWebViewDataRequest. + ButtonText string + // Data field of MessagesSendWebViewDataRequest. + Data string +} + +// MessagesSendWebViewDataRequestTypeID is TL type id of MessagesSendWebViewDataRequest. +const MessagesSendWebViewDataRequestTypeID = 0xdc0242c8 + +// Ensuring interfaces in compile-time for MessagesSendWebViewDataRequest. +var ( + _ bin.Encoder = &MessagesSendWebViewDataRequest{} + _ bin.Decoder = &MessagesSendWebViewDataRequest{} + _ bin.BareEncoder = &MessagesSendWebViewDataRequest{} + _ bin.BareDecoder = &MessagesSendWebViewDataRequest{} +) + +func (s *MessagesSendWebViewDataRequest) Zero() bool { + if s == nil { + return true + } + if !(s.Bot == nil) { + return false + } + if !(s.RandomID == 0) { + return false + } + if !(s.ButtonText == "") { + return false + } + if !(s.Data == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *MessagesSendWebViewDataRequest) String() string { + if s == nil { + return "MessagesSendWebViewDataRequest(nil)" + } + type Alias MessagesSendWebViewDataRequest + return fmt.Sprintf("MessagesSendWebViewDataRequest%+v", Alias(*s)) +} + +// FillFrom fills MessagesSendWebViewDataRequest from given interface. +func (s *MessagesSendWebViewDataRequest) FillFrom(from interface { + GetBot() (value InputUserClass) + GetRandomID() (value int64) + GetButtonText() (value string) + GetData() (value string) +}) { + s.Bot = from.GetBot() + s.RandomID = from.GetRandomID() + s.ButtonText = from.GetButtonText() + s.Data = from.GetData() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesSendWebViewDataRequest) TypeID() uint32 { + return MessagesSendWebViewDataRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesSendWebViewDataRequest) TypeName() string { + return "messages.sendWebViewData" +} + +// TypeInfo returns info about TL type. +func (s *MessagesSendWebViewDataRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.sendWebViewData", + ID: MessagesSendWebViewDataRequestTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Bot", + SchemaName: "bot", + }, + { + Name: "RandomID", + SchemaName: "random_id", + }, + { + Name: "ButtonText", + SchemaName: "button_text", + }, + { + Name: "Data", + SchemaName: "data", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *MessagesSendWebViewDataRequest) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode messages.sendWebViewData#dc0242c8 as nil") + } + b.PutID(MessagesSendWebViewDataRequestTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *MessagesSendWebViewDataRequest) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode messages.sendWebViewData#dc0242c8 as nil") + } + if s.Bot == nil { + return fmt.Errorf("unable to encode messages.sendWebViewData#dc0242c8: field bot is nil") + } + if err := s.Bot.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.sendWebViewData#dc0242c8: field bot: %w", err) + } + b.PutLong(s.RandomID) + b.PutString(s.ButtonText) + b.PutString(s.Data) + return nil +} + +// Decode implements bin.Decoder. +func (s *MessagesSendWebViewDataRequest) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode messages.sendWebViewData#dc0242c8 to nil") + } + if err := b.ConsumeID(MessagesSendWebViewDataRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.sendWebViewData#dc0242c8: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *MessagesSendWebViewDataRequest) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode messages.sendWebViewData#dc0242c8 to nil") + } + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode messages.sendWebViewData#dc0242c8: field bot: %w", err) + } + s.Bot = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode messages.sendWebViewData#dc0242c8: field random_id: %w", err) + } + s.RandomID = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messages.sendWebViewData#dc0242c8: field button_text: %w", err) + } + s.ButtonText = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messages.sendWebViewData#dc0242c8: field data: %w", err) + } + s.Data = value + } + return nil +} + +// GetBot returns value of Bot field. +func (s *MessagesSendWebViewDataRequest) GetBot() (value InputUserClass) { + if s == nil { + return + } + return s.Bot +} + +// GetRandomID returns value of RandomID field. +func (s *MessagesSendWebViewDataRequest) GetRandomID() (value int64) { + if s == nil { + return + } + return s.RandomID +} + +// GetButtonText returns value of ButtonText field. +func (s *MessagesSendWebViewDataRequest) GetButtonText() (value string) { + if s == nil { + return + } + return s.ButtonText +} + +// GetData returns value of Data field. +func (s *MessagesSendWebViewDataRequest) GetData() (value string) { + if s == nil { + return + } + return s.Data +} + +// MessagesSendWebViewData invokes method messages.sendWebViewData#dc0242c8 returning error if any. +// +// See https://core.telegram.org/method/messages.sendWebViewData for reference. +func (c *Client) MessagesSendWebViewData(ctx context.Context, request *MessagesSendWebViewDataRequest) (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_messages_send_web_view_data_slices_gen.go b/tg/tl_messages_send_web_view_data_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_send_web_view_data_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_messages_send_web_view_result_message_gen.go b/tg/tl_messages_send_web_view_result_message_gen.go new file mode 100644 index 0000000000..e844ae7952 --- /dev/null +++ b/tg/tl_messages_send_web_view_result_message_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{} +) + +// MessagesSendWebViewResultMessageRequest represents TL type `messages.sendWebViewResultMessage#a4314f5`. +// +// See https://core.telegram.org/method/messages.sendWebViewResultMessage for reference. +type MessagesSendWebViewResultMessageRequest struct { + // BotQueryID field of MessagesSendWebViewResultMessageRequest. + BotQueryID string + // Result field of MessagesSendWebViewResultMessageRequest. + Result InputBotInlineResultClass +} + +// MessagesSendWebViewResultMessageRequestTypeID is TL type id of MessagesSendWebViewResultMessageRequest. +const MessagesSendWebViewResultMessageRequestTypeID = 0xa4314f5 + +// Ensuring interfaces in compile-time for MessagesSendWebViewResultMessageRequest. +var ( + _ bin.Encoder = &MessagesSendWebViewResultMessageRequest{} + _ bin.Decoder = &MessagesSendWebViewResultMessageRequest{} + _ bin.BareEncoder = &MessagesSendWebViewResultMessageRequest{} + _ bin.BareDecoder = &MessagesSendWebViewResultMessageRequest{} +) + +func (s *MessagesSendWebViewResultMessageRequest) Zero() bool { + if s == nil { + return true + } + if !(s.BotQueryID == "") { + return false + } + if !(s.Result == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *MessagesSendWebViewResultMessageRequest) String() string { + if s == nil { + return "MessagesSendWebViewResultMessageRequest(nil)" + } + type Alias MessagesSendWebViewResultMessageRequest + return fmt.Sprintf("MessagesSendWebViewResultMessageRequest%+v", Alias(*s)) +} + +// FillFrom fills MessagesSendWebViewResultMessageRequest from given interface. +func (s *MessagesSendWebViewResultMessageRequest) FillFrom(from interface { + GetBotQueryID() (value string) + GetResult() (value InputBotInlineResultClass) +}) { + s.BotQueryID = from.GetBotQueryID() + s.Result = from.GetResult() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesSendWebViewResultMessageRequest) TypeID() uint32 { + return MessagesSendWebViewResultMessageRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesSendWebViewResultMessageRequest) TypeName() string { + return "messages.sendWebViewResultMessage" +} + +// TypeInfo returns info about TL type. +func (s *MessagesSendWebViewResultMessageRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.sendWebViewResultMessage", + ID: MessagesSendWebViewResultMessageRequestTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "BotQueryID", + SchemaName: "bot_query_id", + }, + { + Name: "Result", + SchemaName: "result", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *MessagesSendWebViewResultMessageRequest) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode messages.sendWebViewResultMessage#a4314f5 as nil") + } + b.PutID(MessagesSendWebViewResultMessageRequestTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *MessagesSendWebViewResultMessageRequest) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode messages.sendWebViewResultMessage#a4314f5 as nil") + } + b.PutString(s.BotQueryID) + if s.Result == nil { + return fmt.Errorf("unable to encode messages.sendWebViewResultMessage#a4314f5: field result is nil") + } + if err := s.Result.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.sendWebViewResultMessage#a4314f5: field result: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *MessagesSendWebViewResultMessageRequest) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode messages.sendWebViewResultMessage#a4314f5 to nil") + } + if err := b.ConsumeID(MessagesSendWebViewResultMessageRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.sendWebViewResultMessage#a4314f5: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *MessagesSendWebViewResultMessageRequest) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode messages.sendWebViewResultMessage#a4314f5 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messages.sendWebViewResultMessage#a4314f5: field bot_query_id: %w", err) + } + s.BotQueryID = value + } + { + value, err := DecodeInputBotInlineResult(b) + if err != nil { + return fmt.Errorf("unable to decode messages.sendWebViewResultMessage#a4314f5: field result: %w", err) + } + s.Result = value + } + return nil +} + +// GetBotQueryID returns value of BotQueryID field. +func (s *MessagesSendWebViewResultMessageRequest) GetBotQueryID() (value string) { + if s == nil { + return + } + return s.BotQueryID +} + +// GetResult returns value of Result field. +func (s *MessagesSendWebViewResultMessageRequest) GetResult() (value InputBotInlineResultClass) { + if s == nil { + return + } + return s.Result +} + +// MessagesSendWebViewResultMessage invokes method messages.sendWebViewResultMessage#a4314f5 returning error if any. +// +// See https://core.telegram.org/method/messages.sendWebViewResultMessage for reference. +func (c *Client) MessagesSendWebViewResultMessage(ctx context.Context, request *MessagesSendWebViewResultMessageRequest) (*WebViewMessageSent, error) { + var result WebViewMessageSent + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tg/tl_messages_send_web_view_result_message_slices_gen.go b/tg/tl_messages_send_web_view_result_message_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_send_web_view_result_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_messages_toggle_bot_in_attach_menu_gen.go b/tg/tl_messages_toggle_bot_in_attach_menu_gen.go new file mode 100644 index 0000000000..2295e08818 --- /dev/null +++ b/tg/tl_messages_toggle_bot_in_attach_menu_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{} +) + +// MessagesToggleBotInAttachMenuRequest represents TL type `messages.toggleBotInAttachMenu#1aee33af`. +// +// See https://core.telegram.org/method/messages.toggleBotInAttachMenu for reference. +type MessagesToggleBotInAttachMenuRequest struct { + // Bot field of MessagesToggleBotInAttachMenuRequest. + Bot InputUserClass + // Enabled field of MessagesToggleBotInAttachMenuRequest. + Enabled bool +} + +// MessagesToggleBotInAttachMenuRequestTypeID is TL type id of MessagesToggleBotInAttachMenuRequest. +const MessagesToggleBotInAttachMenuRequestTypeID = 0x1aee33af + +// Ensuring interfaces in compile-time for MessagesToggleBotInAttachMenuRequest. +var ( + _ bin.Encoder = &MessagesToggleBotInAttachMenuRequest{} + _ bin.Decoder = &MessagesToggleBotInAttachMenuRequest{} + _ bin.BareEncoder = &MessagesToggleBotInAttachMenuRequest{} + _ bin.BareDecoder = &MessagesToggleBotInAttachMenuRequest{} +) + +func (t *MessagesToggleBotInAttachMenuRequest) Zero() bool { + if t == nil { + return true + } + if !(t.Bot == nil) { + return false + } + if !(t.Enabled == false) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (t *MessagesToggleBotInAttachMenuRequest) String() string { + if t == nil { + return "MessagesToggleBotInAttachMenuRequest(nil)" + } + type Alias MessagesToggleBotInAttachMenuRequest + return fmt.Sprintf("MessagesToggleBotInAttachMenuRequest%+v", Alias(*t)) +} + +// FillFrom fills MessagesToggleBotInAttachMenuRequest from given interface. +func (t *MessagesToggleBotInAttachMenuRequest) FillFrom(from interface { + GetBot() (value InputUserClass) + GetEnabled() (value bool) +}) { + t.Bot = from.GetBot() + t.Enabled = from.GetEnabled() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessagesToggleBotInAttachMenuRequest) TypeID() uint32 { + return MessagesToggleBotInAttachMenuRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessagesToggleBotInAttachMenuRequest) TypeName() string { + return "messages.toggleBotInAttachMenu" +} + +// TypeInfo returns info about TL type. +func (t *MessagesToggleBotInAttachMenuRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messages.toggleBotInAttachMenu", + ID: MessagesToggleBotInAttachMenuRequestTypeID, + } + if t == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Bot", + SchemaName: "bot", + }, + { + Name: "Enabled", + SchemaName: "enabled", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (t *MessagesToggleBotInAttachMenuRequest) Encode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode messages.toggleBotInAttachMenu#1aee33af as nil") + } + b.PutID(MessagesToggleBotInAttachMenuRequestTypeID) + return t.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (t *MessagesToggleBotInAttachMenuRequest) EncodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode messages.toggleBotInAttachMenu#1aee33af as nil") + } + if t.Bot == nil { + return fmt.Errorf("unable to encode messages.toggleBotInAttachMenu#1aee33af: field bot is nil") + } + if err := t.Bot.Encode(b); err != nil { + return fmt.Errorf("unable to encode messages.toggleBotInAttachMenu#1aee33af: field bot: %w", err) + } + b.PutBool(t.Enabled) + return nil +} + +// Decode implements bin.Decoder. +func (t *MessagesToggleBotInAttachMenuRequest) Decode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode messages.toggleBotInAttachMenu#1aee33af to nil") + } + if err := b.ConsumeID(MessagesToggleBotInAttachMenuRequestTypeID); err != nil { + return fmt.Errorf("unable to decode messages.toggleBotInAttachMenu#1aee33af: %w", err) + } + return t.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (t *MessagesToggleBotInAttachMenuRequest) DecodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode messages.toggleBotInAttachMenu#1aee33af to nil") + } + { + value, err := DecodeInputUser(b) + if err != nil { + return fmt.Errorf("unable to decode messages.toggleBotInAttachMenu#1aee33af: field bot: %w", err) + } + t.Bot = value + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode messages.toggleBotInAttachMenu#1aee33af: field enabled: %w", err) + } + t.Enabled = value + } + return nil +} + +// GetBot returns value of Bot field. +func (t *MessagesToggleBotInAttachMenuRequest) GetBot() (value InputUserClass) { + if t == nil { + return + } + return t.Bot +} + +// GetEnabled returns value of Enabled field. +func (t *MessagesToggleBotInAttachMenuRequest) GetEnabled() (value bool) { + if t == nil { + return + } + return t.Enabled +} + +// MessagesToggleBotInAttachMenu invokes method messages.toggleBotInAttachMenu#1aee33af returning error if any. +// +// See https://core.telegram.org/method/messages.toggleBotInAttachMenu for reference. +func (c *Client) MessagesToggleBotInAttachMenu(ctx context.Context, request *MessagesToggleBotInAttachMenuRequest) (bool, error) { + var result BoolBox + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return false, err + } + _, ok := result.Bool.(*BoolTrue) + return ok, nil +} diff --git a/tg/tl_messages_toggle_bot_in_attach_menu_slices_gen.go b/tg/tl_messages_toggle_bot_in_attach_menu_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_messages_toggle_bot_in_attach_menu_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_notification_sound_gen.go b/tg/tl_notification_sound_gen.go new file mode 100644 index 0000000000..fc8c688ec6 --- /dev/null +++ b/tg/tl_notification_sound_gen.go @@ -0,0 +1,633 @@ +// 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{} +) + +// NotificationSoundDefault represents TL type `notificationSoundDefault#97e8bebe`. +// +// See https://core.telegram.org/constructor/notificationSoundDefault for reference. +type NotificationSoundDefault struct { +} + +// NotificationSoundDefaultTypeID is TL type id of NotificationSoundDefault. +const NotificationSoundDefaultTypeID = 0x97e8bebe + +// construct implements constructor of NotificationSoundClass. +func (n NotificationSoundDefault) construct() NotificationSoundClass { return &n } + +// Ensuring interfaces in compile-time for NotificationSoundDefault. +var ( + _ bin.Encoder = &NotificationSoundDefault{} + _ bin.Decoder = &NotificationSoundDefault{} + _ bin.BareEncoder = &NotificationSoundDefault{} + _ bin.BareDecoder = &NotificationSoundDefault{} + + _ NotificationSoundClass = &NotificationSoundDefault{} +) + +func (n *NotificationSoundDefault) Zero() bool { + if n == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (n *NotificationSoundDefault) String() string { + if n == nil { + return "NotificationSoundDefault(nil)" + } + type Alias NotificationSoundDefault + return fmt.Sprintf("NotificationSoundDefault%+v", Alias(*n)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*NotificationSoundDefault) TypeID() uint32 { + return NotificationSoundDefaultTypeID +} + +// TypeName returns name of type in TL schema. +func (*NotificationSoundDefault) TypeName() string { + return "notificationSoundDefault" +} + +// TypeInfo returns info about TL type. +func (n *NotificationSoundDefault) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "notificationSoundDefault", + ID: NotificationSoundDefaultTypeID, + } + if n == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (n *NotificationSoundDefault) Encode(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't encode notificationSoundDefault#97e8bebe as nil") + } + b.PutID(NotificationSoundDefaultTypeID) + return n.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (n *NotificationSoundDefault) EncodeBare(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't encode notificationSoundDefault#97e8bebe as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (n *NotificationSoundDefault) Decode(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't decode notificationSoundDefault#97e8bebe to nil") + } + if err := b.ConsumeID(NotificationSoundDefaultTypeID); err != nil { + return fmt.Errorf("unable to decode notificationSoundDefault#97e8bebe: %w", err) + } + return n.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (n *NotificationSoundDefault) DecodeBare(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't decode notificationSoundDefault#97e8bebe to nil") + } + return nil +} + +// NotificationSoundNone represents TL type `notificationSoundNone#6f0c34df`. +// +// See https://core.telegram.org/constructor/notificationSoundNone for reference. +type NotificationSoundNone struct { +} + +// NotificationSoundNoneTypeID is TL type id of NotificationSoundNone. +const NotificationSoundNoneTypeID = 0x6f0c34df + +// construct implements constructor of NotificationSoundClass. +func (n NotificationSoundNone) construct() NotificationSoundClass { return &n } + +// Ensuring interfaces in compile-time for NotificationSoundNone. +var ( + _ bin.Encoder = &NotificationSoundNone{} + _ bin.Decoder = &NotificationSoundNone{} + _ bin.BareEncoder = &NotificationSoundNone{} + _ bin.BareDecoder = &NotificationSoundNone{} + + _ NotificationSoundClass = &NotificationSoundNone{} +) + +func (n *NotificationSoundNone) Zero() bool { + if n == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (n *NotificationSoundNone) String() string { + if n == nil { + return "NotificationSoundNone(nil)" + } + type Alias NotificationSoundNone + return fmt.Sprintf("NotificationSoundNone%+v", Alias(*n)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*NotificationSoundNone) TypeID() uint32 { + return NotificationSoundNoneTypeID +} + +// TypeName returns name of type in TL schema. +func (*NotificationSoundNone) TypeName() string { + return "notificationSoundNone" +} + +// TypeInfo returns info about TL type. +func (n *NotificationSoundNone) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "notificationSoundNone", + ID: NotificationSoundNoneTypeID, + } + if n == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (n *NotificationSoundNone) Encode(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't encode notificationSoundNone#6f0c34df as nil") + } + b.PutID(NotificationSoundNoneTypeID) + return n.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (n *NotificationSoundNone) EncodeBare(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't encode notificationSoundNone#6f0c34df as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (n *NotificationSoundNone) Decode(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't decode notificationSoundNone#6f0c34df to nil") + } + if err := b.ConsumeID(NotificationSoundNoneTypeID); err != nil { + return fmt.Errorf("unable to decode notificationSoundNone#6f0c34df: %w", err) + } + return n.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (n *NotificationSoundNone) DecodeBare(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't decode notificationSoundNone#6f0c34df to nil") + } + return nil +} + +// NotificationSoundLocal represents TL type `notificationSoundLocal#830b9ae4`. +// +// See https://core.telegram.org/constructor/notificationSoundLocal for reference. +type NotificationSoundLocal struct { + // Title field of NotificationSoundLocal. + Title string + // Data field of NotificationSoundLocal. + Data string +} + +// NotificationSoundLocalTypeID is TL type id of NotificationSoundLocal. +const NotificationSoundLocalTypeID = 0x830b9ae4 + +// construct implements constructor of NotificationSoundClass. +func (n NotificationSoundLocal) construct() NotificationSoundClass { return &n } + +// Ensuring interfaces in compile-time for NotificationSoundLocal. +var ( + _ bin.Encoder = &NotificationSoundLocal{} + _ bin.Decoder = &NotificationSoundLocal{} + _ bin.BareEncoder = &NotificationSoundLocal{} + _ bin.BareDecoder = &NotificationSoundLocal{} + + _ NotificationSoundClass = &NotificationSoundLocal{} +) + +func (n *NotificationSoundLocal) Zero() bool { + if n == nil { + return true + } + if !(n.Title == "") { + return false + } + if !(n.Data == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (n *NotificationSoundLocal) String() string { + if n == nil { + return "NotificationSoundLocal(nil)" + } + type Alias NotificationSoundLocal + return fmt.Sprintf("NotificationSoundLocal%+v", Alias(*n)) +} + +// FillFrom fills NotificationSoundLocal from given interface. +func (n *NotificationSoundLocal) FillFrom(from interface { + GetTitle() (value string) + GetData() (value string) +}) { + n.Title = from.GetTitle() + n.Data = from.GetData() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*NotificationSoundLocal) TypeID() uint32 { + return NotificationSoundLocalTypeID +} + +// TypeName returns name of type in TL schema. +func (*NotificationSoundLocal) TypeName() string { + return "notificationSoundLocal" +} + +// TypeInfo returns info about TL type. +func (n *NotificationSoundLocal) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "notificationSoundLocal", + ID: NotificationSoundLocalTypeID, + } + if n == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Title", + SchemaName: "title", + }, + { + Name: "Data", + SchemaName: "data", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (n *NotificationSoundLocal) Encode(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't encode notificationSoundLocal#830b9ae4 as nil") + } + b.PutID(NotificationSoundLocalTypeID) + return n.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (n *NotificationSoundLocal) EncodeBare(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't encode notificationSoundLocal#830b9ae4 as nil") + } + b.PutString(n.Title) + b.PutString(n.Data) + return nil +} + +// Decode implements bin.Decoder. +func (n *NotificationSoundLocal) Decode(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't decode notificationSoundLocal#830b9ae4 to nil") + } + if err := b.ConsumeID(NotificationSoundLocalTypeID); err != nil { + return fmt.Errorf("unable to decode notificationSoundLocal#830b9ae4: %w", err) + } + return n.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (n *NotificationSoundLocal) DecodeBare(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't decode notificationSoundLocal#830b9ae4 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode notificationSoundLocal#830b9ae4: field title: %w", err) + } + n.Title = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode notificationSoundLocal#830b9ae4: field data: %w", err) + } + n.Data = value + } + return nil +} + +// GetTitle returns value of Title field. +func (n *NotificationSoundLocal) GetTitle() (value string) { + if n == nil { + return + } + return n.Title +} + +// GetData returns value of Data field. +func (n *NotificationSoundLocal) GetData() (value string) { + if n == nil { + return + } + return n.Data +} + +// NotificationSoundRingtone represents TL type `notificationSoundRingtone#ff6c8049`. +// +// See https://core.telegram.org/constructor/notificationSoundRingtone for reference. +type NotificationSoundRingtone struct { + // ID field of NotificationSoundRingtone. + ID int64 +} + +// NotificationSoundRingtoneTypeID is TL type id of NotificationSoundRingtone. +const NotificationSoundRingtoneTypeID = 0xff6c8049 + +// construct implements constructor of NotificationSoundClass. +func (n NotificationSoundRingtone) construct() NotificationSoundClass { return &n } + +// Ensuring interfaces in compile-time for NotificationSoundRingtone. +var ( + _ bin.Encoder = &NotificationSoundRingtone{} + _ bin.Decoder = &NotificationSoundRingtone{} + _ bin.BareEncoder = &NotificationSoundRingtone{} + _ bin.BareDecoder = &NotificationSoundRingtone{} + + _ NotificationSoundClass = &NotificationSoundRingtone{} +) + +func (n *NotificationSoundRingtone) Zero() bool { + if n == nil { + return true + } + if !(n.ID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (n *NotificationSoundRingtone) String() string { + if n == nil { + return "NotificationSoundRingtone(nil)" + } + type Alias NotificationSoundRingtone + return fmt.Sprintf("NotificationSoundRingtone%+v", Alias(*n)) +} + +// FillFrom fills NotificationSoundRingtone from given interface. +func (n *NotificationSoundRingtone) FillFrom(from interface { + GetID() (value int64) +}) { + n.ID = from.GetID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*NotificationSoundRingtone) TypeID() uint32 { + return NotificationSoundRingtoneTypeID +} + +// TypeName returns name of type in TL schema. +func (*NotificationSoundRingtone) TypeName() string { + return "notificationSoundRingtone" +} + +// TypeInfo returns info about TL type. +func (n *NotificationSoundRingtone) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "notificationSoundRingtone", + ID: NotificationSoundRingtoneTypeID, + } + if n == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ID", + SchemaName: "id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (n *NotificationSoundRingtone) Encode(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't encode notificationSoundRingtone#ff6c8049 as nil") + } + b.PutID(NotificationSoundRingtoneTypeID) + return n.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (n *NotificationSoundRingtone) EncodeBare(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't encode notificationSoundRingtone#ff6c8049 as nil") + } + b.PutLong(n.ID) + return nil +} + +// Decode implements bin.Decoder. +func (n *NotificationSoundRingtone) Decode(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't decode notificationSoundRingtone#ff6c8049 to nil") + } + if err := b.ConsumeID(NotificationSoundRingtoneTypeID); err != nil { + return fmt.Errorf("unable to decode notificationSoundRingtone#ff6c8049: %w", err) + } + return n.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (n *NotificationSoundRingtone) DecodeBare(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't decode notificationSoundRingtone#ff6c8049 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode notificationSoundRingtone#ff6c8049: field id: %w", err) + } + n.ID = value + } + return nil +} + +// GetID returns value of ID field. +func (n *NotificationSoundRingtone) GetID() (value int64) { + if n == nil { + return + } + return n.ID +} + +// NotificationSoundClassName is schema name of NotificationSoundClass. +const NotificationSoundClassName = "NotificationSound" + +// NotificationSoundClass represents NotificationSound generic type. +// +// See https://core.telegram.org/type/NotificationSound for reference. +// +// Example: +// g, err := tg.DecodeNotificationSound(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tg.NotificationSoundDefault: // notificationSoundDefault#97e8bebe +// case *tg.NotificationSoundNone: // notificationSoundNone#6f0c34df +// case *tg.NotificationSoundLocal: // notificationSoundLocal#830b9ae4 +// case *tg.NotificationSoundRingtone: // notificationSoundRingtone#ff6c8049 +// default: panic(v) +// } +type NotificationSoundClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() NotificationSoundClass + + // 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 +} + +// DecodeNotificationSound implements binary de-serialization for NotificationSoundClass. +func DecodeNotificationSound(buf *bin.Buffer) (NotificationSoundClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case NotificationSoundDefaultTypeID: + // Decoding notificationSoundDefault#97e8bebe. + v := NotificationSoundDefault{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode NotificationSoundClass: %w", err) + } + return &v, nil + case NotificationSoundNoneTypeID: + // Decoding notificationSoundNone#6f0c34df. + v := NotificationSoundNone{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode NotificationSoundClass: %w", err) + } + return &v, nil + case NotificationSoundLocalTypeID: + // Decoding notificationSoundLocal#830b9ae4. + v := NotificationSoundLocal{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode NotificationSoundClass: %w", err) + } + return &v, nil + case NotificationSoundRingtoneTypeID: + // Decoding notificationSoundRingtone#ff6c8049. + v := NotificationSoundRingtone{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode NotificationSoundClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode NotificationSoundClass: %w", bin.NewUnexpectedID(id)) + } +} + +// NotificationSound boxes the NotificationSoundClass providing a helper. +type NotificationSoundBox struct { + NotificationSound NotificationSoundClass +} + +// Decode implements bin.Decoder for NotificationSoundBox. +func (b *NotificationSoundBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode NotificationSoundBox to nil") + } + v, err := DecodeNotificationSound(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.NotificationSound = v + return nil +} + +// Encode implements bin.Encode for NotificationSoundBox. +func (b *NotificationSoundBox) Encode(buf *bin.Buffer) error { + if b == nil || b.NotificationSound == nil { + return fmt.Errorf("unable to encode NotificationSoundClass as nil") + } + return b.NotificationSound.Encode(buf) +} diff --git a/tg/tl_notification_sound_slices_gen.go b/tg/tl_notification_sound_slices_gen.go new file mode 100644 index 0000000000..abbb9a7d2e --- /dev/null +++ b/tg/tl_notification_sound_slices_gen.go @@ -0,0 +1,335 @@ +//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{} +) + +// NotificationSoundClassArray is adapter for slice of NotificationSoundClass. +type NotificationSoundClassArray []NotificationSoundClass + +// Sort sorts slice of NotificationSoundClass. +func (s NotificationSoundClassArray) Sort(less func(a, b NotificationSoundClass) bool) NotificationSoundClassArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of NotificationSoundClass. +func (s NotificationSoundClassArray) SortStable(less func(a, b NotificationSoundClass) bool) NotificationSoundClassArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of NotificationSoundClass. +func (s NotificationSoundClassArray) Retain(keep func(x NotificationSoundClass) bool) NotificationSoundClassArray { + 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 NotificationSoundClassArray) First() (v NotificationSoundClass, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s NotificationSoundClassArray) Last() (v NotificationSoundClass, 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 *NotificationSoundClassArray) PopFirst() (v NotificationSoundClass, 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 NotificationSoundClass + 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 *NotificationSoundClassArray) Pop() (v NotificationSoundClass, 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 +} + +// AsNotificationSoundLocal returns copy with only NotificationSoundLocal constructors. +func (s NotificationSoundClassArray) AsNotificationSoundLocal() (to NotificationSoundLocalArray) { + for _, elem := range s { + value, ok := elem.(*NotificationSoundLocal) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsNotificationSoundRingtone returns copy with only NotificationSoundRingtone constructors. +func (s NotificationSoundClassArray) AsNotificationSoundRingtone() (to NotificationSoundRingtoneArray) { + for _, elem := range s { + value, ok := elem.(*NotificationSoundRingtone) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// NotificationSoundLocalArray is adapter for slice of NotificationSoundLocal. +type NotificationSoundLocalArray []NotificationSoundLocal + +// Sort sorts slice of NotificationSoundLocal. +func (s NotificationSoundLocalArray) Sort(less func(a, b NotificationSoundLocal) bool) NotificationSoundLocalArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of NotificationSoundLocal. +func (s NotificationSoundLocalArray) SortStable(less func(a, b NotificationSoundLocal) bool) NotificationSoundLocalArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of NotificationSoundLocal. +func (s NotificationSoundLocalArray) Retain(keep func(x NotificationSoundLocal) bool) NotificationSoundLocalArray { + 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 NotificationSoundLocalArray) First() (v NotificationSoundLocal, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s NotificationSoundLocalArray) Last() (v NotificationSoundLocal, 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 *NotificationSoundLocalArray) PopFirst() (v NotificationSoundLocal, 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 NotificationSoundLocal + 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 *NotificationSoundLocalArray) Pop() (v NotificationSoundLocal, 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 +} + +// NotificationSoundRingtoneArray is adapter for slice of NotificationSoundRingtone. +type NotificationSoundRingtoneArray []NotificationSoundRingtone + +// Sort sorts slice of NotificationSoundRingtone. +func (s NotificationSoundRingtoneArray) Sort(less func(a, b NotificationSoundRingtone) bool) NotificationSoundRingtoneArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of NotificationSoundRingtone. +func (s NotificationSoundRingtoneArray) SortStable(less func(a, b NotificationSoundRingtone) bool) NotificationSoundRingtoneArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of NotificationSoundRingtone. +func (s NotificationSoundRingtoneArray) Retain(keep func(x NotificationSoundRingtone) bool) NotificationSoundRingtoneArray { + 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 NotificationSoundRingtoneArray) First() (v NotificationSoundRingtone, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s NotificationSoundRingtoneArray) Last() (v NotificationSoundRingtone, 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 *NotificationSoundRingtoneArray) PopFirst() (v NotificationSoundRingtone, 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 NotificationSoundRingtone + 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 *NotificationSoundRingtoneArray) Pop() (v NotificationSoundRingtone, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} + +// SortByID sorts slice of NotificationSoundRingtone by ID. +func (s NotificationSoundRingtoneArray) SortByID() NotificationSoundRingtoneArray { + return s.Sort(func(a, b NotificationSoundRingtone) bool { + return a.GetID() < b.GetID() + }) +} + +// SortStableByID sorts slice of NotificationSoundRingtone by ID. +func (s NotificationSoundRingtoneArray) SortStableByID() NotificationSoundRingtoneArray { + return s.SortStable(func(a, b NotificationSoundRingtone) bool { + return a.GetID() < b.GetID() + }) +} + +// FillMap fills constructors to given map. +func (s NotificationSoundRingtoneArray) FillMap(to map[int64]NotificationSoundRingtone) { + for _, value := range s { + to[value.GetID()] = value + } +} + +// ToMap collects constructors to map. +func (s NotificationSoundRingtoneArray) ToMap() map[int64]NotificationSoundRingtone { + r := make(map[int64]NotificationSoundRingtone, len(s)) + s.FillMap(r) + return r +} diff --git a/tg/tl_peer_notify_settings_gen.go b/tg/tl_peer_notify_settings_gen.go index fdab070b78..b3f120bf9a 100644 --- a/tg/tl_peer_notify_settings_gen.go +++ b/tg/tl_peer_notify_settings_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// PeerNotifySettings represents TL type `peerNotifySettings#af509d20`. +// PeerNotifySettings represents TL type `peerNotifySettings#a83b0426`. // Notification settings. // // See https://core.telegram.org/constructor/peerNotifySettings for reference. @@ -53,14 +53,22 @@ type PeerNotifySettings struct { // // Use SetMuteUntil and GetMuteUntil helpers. MuteUntil int - // Audio file name for notifications + // IosSound field of PeerNotifySettings. // - // Use SetSound and GetSound helpers. - Sound string + // Use SetIosSound and GetIosSound helpers. + IosSound NotificationSoundClass + // AndroidSound field of PeerNotifySettings. + // + // Use SetAndroidSound and GetAndroidSound helpers. + AndroidSound NotificationSoundClass + // OtherSound field of PeerNotifySettings. + // + // Use SetOtherSound and GetOtherSound helpers. + OtherSound NotificationSoundClass } // PeerNotifySettingsTypeID is TL type id of PeerNotifySettings. -const PeerNotifySettingsTypeID = 0xaf509d20 +const PeerNotifySettingsTypeID = 0xa83b0426 // Ensuring interfaces in compile-time for PeerNotifySettings. var ( @@ -86,7 +94,13 @@ func (p *PeerNotifySettings) Zero() bool { if !(p.MuteUntil == 0) { return false } - if !(p.Sound == "") { + if !(p.IosSound == nil) { + return false + } + if !(p.AndroidSound == nil) { + return false + } + if !(p.OtherSound == nil) { return false } @@ -107,7 +121,9 @@ func (p *PeerNotifySettings) FillFrom(from interface { GetShowPreviews() (value bool, ok bool) GetSilent() (value bool, ok bool) GetMuteUntil() (value int, ok bool) - GetSound() (value string, ok bool) + GetIosSound() (value NotificationSoundClass, ok bool) + GetAndroidSound() (value NotificationSoundClass, ok bool) + GetOtherSound() (value NotificationSoundClass, ok bool) }) { if val, ok := from.GetShowPreviews(); ok { p.ShowPreviews = val @@ -121,8 +137,16 @@ func (p *PeerNotifySettings) FillFrom(from interface { p.MuteUntil = val } - if val, ok := from.GetSound(); ok { - p.Sound = val + if val, ok := from.GetIosSound(); ok { + p.IosSound = val + } + + if val, ok := from.GetAndroidSound(); ok { + p.AndroidSound = val + } + + if val, ok := from.GetOtherSound(); ok { + p.OtherSound = val } } @@ -166,10 +190,20 @@ func (p *PeerNotifySettings) TypeInfo() tdp.Type { Null: !p.Flags.Has(2), }, { - Name: "Sound", - SchemaName: "sound", + Name: "IosSound", + SchemaName: "ios_sound", Null: !p.Flags.Has(3), }, + { + Name: "AndroidSound", + SchemaName: "android_sound", + Null: !p.Flags.Has(4), + }, + { + Name: "OtherSound", + SchemaName: "other_sound", + Null: !p.Flags.Has(5), + }, } return typ } @@ -185,15 +219,21 @@ func (p *PeerNotifySettings) SetFlags() { if !(p.MuteUntil == 0) { p.Flags.Set(2) } - if !(p.Sound == "") { + if !(p.IosSound == nil) { p.Flags.Set(3) } + if !(p.AndroidSound == nil) { + p.Flags.Set(4) + } + if !(p.OtherSound == nil) { + p.Flags.Set(5) + } } // Encode implements bin.Encoder. func (p *PeerNotifySettings) Encode(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't encode peerNotifySettings#af509d20 as nil") + return fmt.Errorf("can't encode peerNotifySettings#a83b0426 as nil") } b.PutID(PeerNotifySettingsTypeID) return p.EncodeBare(b) @@ -202,11 +242,11 @@ func (p *PeerNotifySettings) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (p *PeerNotifySettings) EncodeBare(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't encode peerNotifySettings#af509d20 as nil") + return fmt.Errorf("can't encode peerNotifySettings#a83b0426 as nil") } p.SetFlags() if err := p.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode peerNotifySettings#af509d20: field flags: %w", err) + return fmt.Errorf("unable to encode peerNotifySettings#a83b0426: field flags: %w", err) } if p.Flags.Has(0) { b.PutBool(p.ShowPreviews) @@ -218,7 +258,28 @@ func (p *PeerNotifySettings) EncodeBare(b *bin.Buffer) error { b.PutInt(p.MuteUntil) } if p.Flags.Has(3) { - b.PutString(p.Sound) + if p.IosSound == nil { + return fmt.Errorf("unable to encode peerNotifySettings#a83b0426: field ios_sound is nil") + } + if err := p.IosSound.Encode(b); err != nil { + return fmt.Errorf("unable to encode peerNotifySettings#a83b0426: field ios_sound: %w", err) + } + } + if p.Flags.Has(4) { + if p.AndroidSound == nil { + return fmt.Errorf("unable to encode peerNotifySettings#a83b0426: field android_sound is nil") + } + if err := p.AndroidSound.Encode(b); err != nil { + return fmt.Errorf("unable to encode peerNotifySettings#a83b0426: field android_sound: %w", err) + } + } + if p.Flags.Has(5) { + if p.OtherSound == nil { + return fmt.Errorf("unable to encode peerNotifySettings#a83b0426: field other_sound is nil") + } + if err := p.OtherSound.Encode(b); err != nil { + return fmt.Errorf("unable to encode peerNotifySettings#a83b0426: field other_sound: %w", err) + } } return nil } @@ -226,10 +287,10 @@ func (p *PeerNotifySettings) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (p *PeerNotifySettings) Decode(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't decode peerNotifySettings#af509d20 to nil") + return fmt.Errorf("can't decode peerNotifySettings#a83b0426 to nil") } if err := b.ConsumeID(PeerNotifySettingsTypeID); err != nil { - return fmt.Errorf("unable to decode peerNotifySettings#af509d20: %w", err) + return fmt.Errorf("unable to decode peerNotifySettings#a83b0426: %w", err) } return p.DecodeBare(b) } @@ -237,40 +298,54 @@ func (p *PeerNotifySettings) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (p *PeerNotifySettings) DecodeBare(b *bin.Buffer) error { if p == nil { - return fmt.Errorf("can't decode peerNotifySettings#af509d20 to nil") + return fmt.Errorf("can't decode peerNotifySettings#a83b0426 to nil") } { if err := p.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode peerNotifySettings#af509d20: field flags: %w", err) + return fmt.Errorf("unable to decode peerNotifySettings#a83b0426: field flags: %w", err) } } if p.Flags.Has(0) { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode peerNotifySettings#af509d20: field show_previews: %w", err) + return fmt.Errorf("unable to decode peerNotifySettings#a83b0426: field show_previews: %w", err) } p.ShowPreviews = value } if p.Flags.Has(1) { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode peerNotifySettings#af509d20: field silent: %w", err) + return fmt.Errorf("unable to decode peerNotifySettings#a83b0426: field silent: %w", err) } p.Silent = value } if p.Flags.Has(2) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode peerNotifySettings#af509d20: field mute_until: %w", err) + return fmt.Errorf("unable to decode peerNotifySettings#a83b0426: field mute_until: %w", err) } p.MuteUntil = value } if p.Flags.Has(3) { - value, err := b.String() + value, err := DecodeNotificationSound(b) + if err != nil { + return fmt.Errorf("unable to decode peerNotifySettings#a83b0426: field ios_sound: %w", err) + } + p.IosSound = value + } + if p.Flags.Has(4) { + value, err := DecodeNotificationSound(b) if err != nil { - return fmt.Errorf("unable to decode peerNotifySettings#af509d20: field sound: %w", err) + return fmt.Errorf("unable to decode peerNotifySettings#a83b0426: field android_sound: %w", err) } - p.Sound = value + p.AndroidSound = value + } + if p.Flags.Has(5) { + value, err := DecodeNotificationSound(b) + if err != nil { + return fmt.Errorf("unable to decode peerNotifySettings#a83b0426: field other_sound: %w", err) + } + p.OtherSound = value } return nil } @@ -329,20 +404,56 @@ func (p *PeerNotifySettings) GetMuteUntil() (value int, ok bool) { return p.MuteUntil, true } -// SetSound sets value of Sound conditional field. -func (p *PeerNotifySettings) SetSound(value string) { +// SetIosSound sets value of IosSound conditional field. +func (p *PeerNotifySettings) SetIosSound(value NotificationSoundClass) { p.Flags.Set(3) - p.Sound = value + p.IosSound = value } -// GetSound returns value of Sound conditional field and +// GetIosSound returns value of IosSound conditional field and // boolean which is true if field was set. -func (p *PeerNotifySettings) GetSound() (value string, ok bool) { +func (p *PeerNotifySettings) GetIosSound() (value NotificationSoundClass, ok bool) { if p == nil { return } if !p.Flags.Has(3) { return value, false } - return p.Sound, true + return p.IosSound, true +} + +// SetAndroidSound sets value of AndroidSound conditional field. +func (p *PeerNotifySettings) SetAndroidSound(value NotificationSoundClass) { + p.Flags.Set(4) + p.AndroidSound = value +} + +// GetAndroidSound returns value of AndroidSound conditional field and +// boolean which is true if field was set. +func (p *PeerNotifySettings) GetAndroidSound() (value NotificationSoundClass, ok bool) { + if p == nil { + return + } + if !p.Flags.Has(4) { + return value, false + } + return p.AndroidSound, true +} + +// SetOtherSound sets value of OtherSound conditional field. +func (p *PeerNotifySettings) SetOtherSound(value NotificationSoundClass) { + p.Flags.Set(5) + p.OtherSound = value +} + +// GetOtherSound returns value of OtherSound conditional field and +// boolean which is true if field was set. +func (p *PeerNotifySettings) GetOtherSound() (value NotificationSoundClass, ok bool) { + if p == nil { + return + } + if !p.Flags.Has(5) { + return value, false + } + return p.OtherSound, true } diff --git a/tg/tl_registry_gen.go b/tg/tl_registry_gen.go index c7afb143cc..72d4aabf6a 100644 --- a/tg/tl_registry_gen.go +++ b/tg/tl_registry_gen.go @@ -32,7 +32,7 @@ var ( ) // Layer version of schema. -const Layer = 139 +const Layer = 140 // TypesMap returns mapping from type ids to TL type names. func TypesMap() map[uint32]string { @@ -117,7 +117,7 @@ func TypesMap() map[uint32]string { ChannelTypeID: "channel#8261ac61", ChannelForbiddenTypeID: "channelForbidden#17d493d5", ChatFullTypeID: "chatFull#d18ee226", - ChannelFullTypeID: "channelFull#e13c3d20", + ChannelFullTypeID: "channelFull#ea68a619", ChatParticipantTypeID: "chatParticipant#c02d4007", ChatParticipantCreatorTypeID: "chatParticipantCreator#e46bcee4", ChatParticipantAdminTypeID: "chatParticipantAdmin#a0933f5b", @@ -171,6 +171,8 @@ func TypesMap() map[uint32]string { MessageActionGroupCallScheduledTypeID: "messageActionGroupCallScheduled#b3a07661", MessageActionSetChatThemeTypeID: "messageActionSetChatTheme#aa786345", MessageActionChatJoinedByRequestTypeID: "messageActionChatJoinedByRequest#ebbca3cb", + MessageActionWebViewDataSentMeTypeID: "messageActionWebViewDataSentMe#47dd8079", + MessageActionWebViewDataSentTypeID: "messageActionWebViewDataSent#b4c38cb5", DialogTypeID: "dialog#a8edd0f5", DialogFolderTypeID: "dialogFolder#71bd134c", PhotoEmptyTypeID: "photoEmpty#2331b22d", @@ -191,8 +193,8 @@ func TypesMap() map[uint32]string { InputNotifyUsersTypeID: "inputNotifyUsers#193b4417", InputNotifyChatsTypeID: "inputNotifyChats#4a95e84e", InputNotifyBroadcastsTypeID: "inputNotifyBroadcasts#b1db7c7e", - InputPeerNotifySettingsTypeID: "inputPeerNotifySettings#9c3d198e", - PeerNotifySettingsTypeID: "peerNotifySettings#af509d20", + InputPeerNotifySettingsTypeID: "inputPeerNotifySettings#df1f002b", + PeerNotifySettingsTypeID: "peerNotifySettings#a83b0426", PeerSettingsTypeID: "peerSettings#a518110d", WallPaperTypeID: "wallPaper#a437c3ed", WallPaperNoFileTypeID: "wallPaperNoFile#e0804116", @@ -206,7 +208,7 @@ func TypesMap() map[uint32]string { InputReportReasonFakeTypeID: "inputReportReasonFake#f5ddd6e7", InputReportReasonIllegalDrugsTypeID: "inputReportReasonIllegalDrugs#a8eb2be", InputReportReasonPersonalDetailsTypeID: "inputReportReasonPersonalDetails#9ec7863d", - UserFullTypeID: "userFull#cf366521", + UserFullTypeID: "userFull#8c72ea81", ContactTypeID: "contact#145ade0b", ImportedContactTypeID: "importedContact#c13e3c50", ContactStatusTypeID: "contactStatus#16d9703b", @@ -339,6 +341,10 @@ func TypesMap() map[uint32]string { UpdatePendingJoinRequestsTypeID: "updatePendingJoinRequests#7063c3db", UpdateBotChatInviteRequesterTypeID: "updateBotChatInviteRequester#11dfa986", UpdateMessageReactionsTypeID: "updateMessageReactions#154798c3", + UpdateAttachMenuBotsTypeID: "updateAttachMenuBots#17b7a20b", + UpdateWebViewResultSentTypeID: "updateWebViewResultSent#1592b79d", + UpdateBotMenuButtonTypeID: "updateBotMenuButton#14b85813", + UpdateSavedRingtonesTypeID: "updateSavedRingtones#74d8be99", UpdatesStateTypeID: "updates.state#a56c2a3e", UpdatesDifferenceEmptyTypeID: "updates.differenceEmpty#5d75a138", UpdatesDifferenceTypeID: "updates.difference#f49ca0", @@ -480,7 +486,7 @@ func TypesMap() map[uint32]string { MessagesStickerSetTypeID: "messages.stickerSet#b60a24a6", MessagesStickerSetNotModifiedTypeID: "messages.stickerSetNotModified#d3f924eb", BotCommandTypeID: "botCommand#c27ac8c7", - BotInfoTypeID: "botInfo#1b74b335", + BotInfoTypeID: "botInfo#e4169b5d", KeyboardButtonTypeID: "keyboardButton#a2fa4880", KeyboardButtonURLTypeID: "keyboardButtonUrl#258aff05", KeyboardButtonCallbackTypeID: "keyboardButtonCallback#35bbdb6b", @@ -494,6 +500,8 @@ func TypesMap() map[uint32]string { KeyboardButtonRequestPollTypeID: "keyboardButtonRequestPoll#bbc7515d", InputKeyboardButtonUserProfileTypeID: "inputKeyboardButtonUserProfile#e988037b", KeyboardButtonUserProfileTypeID: "keyboardButtonUserProfile#308660c1", + KeyboardButtonWebViewTypeID: "keyboardButtonWebView#13767230", + KeyboardButtonSimpleWebViewTypeID: "keyboardButtonSimpleWebView#a0c0505c", KeyboardButtonRowTypeID: "keyboardButtonRow#77608b83", ReplyKeyboardHideTypeID: "replyKeyboardHide#a03e5b85", ReplyKeyboardForceReplyTypeID: "replyKeyboardForceReply#86b40b08", @@ -995,6 +1003,26 @@ func TypesMap() map[uint32]string { GroupCallStreamChannelTypeID: "groupCallStreamChannel#80eb48af", PhoneGroupCallStreamChannelsTypeID: "phone.groupCallStreamChannels#d0e482b2", PhoneGroupCallStreamRtmpURLTypeID: "phone.groupCallStreamRtmpUrl#2dbf3432", + AttachMenuBotIconColorTypeID: "attachMenuBotIconColor#4576f3f0", + AttachMenuBotIconTypeID: "attachMenuBotIcon#b2a7386b", + AttachMenuBotTypeID: "attachMenuBot#e93cb772", + AttachMenuBotsNotModifiedTypeID: "attachMenuBotsNotModified#f1d88a5c", + AttachMenuBotsTypeID: "attachMenuBots#3c4301c0", + AttachMenuBotsBotTypeID: "attachMenuBotsBot#93bf667f", + WebViewResultURLTypeID: "webViewResultUrl#c14557c", + SimpleWebViewResultURLTypeID: "simpleWebViewResultUrl#882f76bb", + WebViewMessageSentTypeID: "webViewMessageSent#c94511c", + BotMenuButtonDefaultTypeID: "botMenuButtonDefault#7533a588", + BotMenuButtonCommandsTypeID: "botMenuButtonCommands#4258c205", + BotMenuButtonTypeID: "botMenuButton#c7b57ce6", + AccountSavedRingtonesNotModifiedTypeID: "account.savedRingtonesNotModified#fbf6e8b1", + AccountSavedRingtonesTypeID: "account.savedRingtones#c1e92cc5", + NotificationSoundDefaultTypeID: "notificationSoundDefault#97e8bebe", + NotificationSoundNoneTypeID: "notificationSoundNone#6f0c34df", + NotificationSoundLocalTypeID: "notificationSoundLocal#830b9ae4", + NotificationSoundRingtoneTypeID: "notificationSoundRingtone#ff6c8049", + AccountSavedRingtoneTypeID: "account.savedRingtone#b7263f6d", + AccountSavedRingtoneConvertedTypeID: "account.savedRingtoneConverted#1f307eb7", InvokeAfterMsgRequestTypeID: "invokeAfterMsg#cb9f372d", InvokeAfterMsgsRequestTypeID: "invokeAfterMsgs#3dc4b4f0", InitConnectionRequestTypeID: "initConnection#c1cd5ea9", @@ -1094,6 +1122,9 @@ func TypesMap() map[uint32]string { AccountGetChatThemesRequestTypeID: "account.getChatThemes#d638de89", AccountSetAuthorizationTTLRequestTypeID: "account.setAuthorizationTTL#bf899aa0", AccountChangeAuthorizationSettingsRequestTypeID: "account.changeAuthorizationSettings#40f48462", + AccountGetSavedRingtonesRequestTypeID: "account.getSavedRingtones#e1902288", + AccountSaveRingtoneRequestTypeID: "account.saveRingtone#3dea5b03", + AccountUploadRingtoneRequestTypeID: "account.uploadRingtone#831a83a2", UsersGetUsersRequestTypeID: "users.getUsers#d91a548", UsersGetFullUserRequestTypeID: "users.getFullUser#b60f5918", UsersSetSecureValueErrorsRequestTypeID: "users.setSecureValueErrors#90c894b5", @@ -1277,6 +1308,14 @@ func TypesMap() map[uint32]string { MessagesGetUnreadReactionsRequestTypeID: "messages.getUnreadReactions#e85bae1a", MessagesReadReactionsRequestTypeID: "messages.readReactions#82e251d7", MessagesSearchSentMediaRequestTypeID: "messages.searchSentMedia#107e31a0", + MessagesGetAttachMenuBotsRequestTypeID: "messages.getAttachMenuBots#16fcc2cb", + MessagesGetAttachMenuBotRequestTypeID: "messages.getAttachMenuBot#77216192", + MessagesToggleBotInAttachMenuRequestTypeID: "messages.toggleBotInAttachMenu#1aee33af", + MessagesRequestWebViewRequestTypeID: "messages.requestWebView#fa04dff", + MessagesProlongWebViewRequestTypeID: "messages.prolongWebView#d22ad148", + MessagesRequestSimpleWebViewRequestTypeID: "messages.requestSimpleWebView#6abb2f73", + MessagesSendWebViewResultMessageRequestTypeID: "messages.sendWebViewResultMessage#a4314f5", + MessagesSendWebViewDataRequestTypeID: "messages.sendWebViewData#dc0242c8", UpdatesGetStateRequestTypeID: "updates.getState#edd4882a", UpdatesGetDifferenceRequestTypeID: "updates.getDifference#25939651", UpdatesGetChannelDifferenceRequestTypeID: "updates.getChannelDifference#3173d78", @@ -1339,7 +1378,7 @@ func TypesMap() map[uint32]string { ChannelsGetAdminLogRequestTypeID: "channels.getAdminLog#33ddf480", ChannelsSetStickersRequestTypeID: "channels.setStickers#ea8ca4f9", ChannelsReadMessageContentsRequestTypeID: "channels.readMessageContents#eab5dc38", - ChannelsDeleteHistoryRequestTypeID: "channels.deleteHistory#af369d42", + ChannelsDeleteHistoryRequestTypeID: "channels.deleteHistory#9baa9647", ChannelsTogglePreHistoryHiddenRequestTypeID: "channels.togglePreHistoryHidden#eabbb94c", ChannelsGetLeftChannelsRequestTypeID: "channels.getLeftChannels#8341ecc0", ChannelsGetGroupsForDiscussionRequestTypeID: "channels.getGroupsForDiscussion#f5dad378", @@ -1358,6 +1397,10 @@ func TypesMap() map[uint32]string { BotsSetBotCommandsRequestTypeID: "bots.setBotCommands#517165a", BotsResetBotCommandsRequestTypeID: "bots.resetBotCommands#3d8de0f9", BotsGetBotCommandsRequestTypeID: "bots.getBotCommands#e34c0dd6", + BotsSetBotMenuButtonRequestTypeID: "bots.setBotMenuButton#4504d54f", + BotsGetBotMenuButtonRequestTypeID: "bots.getBotMenuButton#9c60eb28", + BotsSetBotBroadcastDefaultAdminRightsRequestTypeID: "bots.setBotBroadcastDefaultAdminRights#788464e1", + BotsSetBotGroupDefaultAdminRightsRequestTypeID: "bots.setBotGroupDefaultAdminRights#925ec9ea", PaymentsGetPaymentFormRequestTypeID: "payments.getPaymentForm#8a333c8d", PaymentsGetPaymentReceiptRequestTypeID: "payments.getPaymentReceipt#2478d1cc", PaymentsValidateRequestedInfoRequestTypeID: "payments.validateRequestedInfo#db103170", @@ -1567,6 +1610,8 @@ func NamesMap() map[string]uint32 { "messageActionGroupCallScheduled": MessageActionGroupCallScheduledTypeID, "messageActionSetChatTheme": MessageActionSetChatThemeTypeID, "messageActionChatJoinedByRequest": MessageActionChatJoinedByRequestTypeID, + "messageActionWebViewDataSentMe": MessageActionWebViewDataSentMeTypeID, + "messageActionWebViewDataSent": MessageActionWebViewDataSentTypeID, "dialog": DialogTypeID, "dialogFolder": DialogFolderTypeID, "photoEmpty": PhotoEmptyTypeID, @@ -1735,6 +1780,10 @@ func NamesMap() map[string]uint32 { "updatePendingJoinRequests": UpdatePendingJoinRequestsTypeID, "updateBotChatInviteRequester": UpdateBotChatInviteRequesterTypeID, "updateMessageReactions": UpdateMessageReactionsTypeID, + "updateAttachMenuBots": UpdateAttachMenuBotsTypeID, + "updateWebViewResultSent": UpdateWebViewResultSentTypeID, + "updateBotMenuButton": UpdateBotMenuButtonTypeID, + "updateSavedRingtones": UpdateSavedRingtonesTypeID, "updates.state": UpdatesStateTypeID, "updates.differenceEmpty": UpdatesDifferenceEmptyTypeID, "updates.difference": UpdatesDifferenceTypeID, @@ -1890,6 +1939,8 @@ func NamesMap() map[string]uint32 { "keyboardButtonRequestPoll": KeyboardButtonRequestPollTypeID, "inputKeyboardButtonUserProfile": InputKeyboardButtonUserProfileTypeID, "keyboardButtonUserProfile": KeyboardButtonUserProfileTypeID, + "keyboardButtonWebView": KeyboardButtonWebViewTypeID, + "keyboardButtonSimpleWebView": KeyboardButtonSimpleWebViewTypeID, "keyboardButtonRow": KeyboardButtonRowTypeID, "replyKeyboardHide": ReplyKeyboardHideTypeID, "replyKeyboardForceReply": ReplyKeyboardForceReplyTypeID, @@ -2391,6 +2442,26 @@ func NamesMap() map[string]uint32 { "groupCallStreamChannel": GroupCallStreamChannelTypeID, "phone.groupCallStreamChannels": PhoneGroupCallStreamChannelsTypeID, "phone.groupCallStreamRtmpUrl": PhoneGroupCallStreamRtmpURLTypeID, + "attachMenuBotIconColor": AttachMenuBotIconColorTypeID, + "attachMenuBotIcon": AttachMenuBotIconTypeID, + "attachMenuBot": AttachMenuBotTypeID, + "attachMenuBotsNotModified": AttachMenuBotsNotModifiedTypeID, + "attachMenuBots": AttachMenuBotsTypeID, + "attachMenuBotsBot": AttachMenuBotsBotTypeID, + "webViewResultUrl": WebViewResultURLTypeID, + "simpleWebViewResultUrl": SimpleWebViewResultURLTypeID, + "webViewMessageSent": WebViewMessageSentTypeID, + "botMenuButtonDefault": BotMenuButtonDefaultTypeID, + "botMenuButtonCommands": BotMenuButtonCommandsTypeID, + "botMenuButton": BotMenuButtonTypeID, + "account.savedRingtonesNotModified": AccountSavedRingtonesNotModifiedTypeID, + "account.savedRingtones": AccountSavedRingtonesTypeID, + "notificationSoundDefault": NotificationSoundDefaultTypeID, + "notificationSoundNone": NotificationSoundNoneTypeID, + "notificationSoundLocal": NotificationSoundLocalTypeID, + "notificationSoundRingtone": NotificationSoundRingtoneTypeID, + "account.savedRingtone": AccountSavedRingtoneTypeID, + "account.savedRingtoneConverted": AccountSavedRingtoneConvertedTypeID, "invokeAfterMsg": InvokeAfterMsgRequestTypeID, "invokeAfterMsgs": InvokeAfterMsgsRequestTypeID, "initConnection": InitConnectionRequestTypeID, @@ -2490,6 +2561,9 @@ func NamesMap() map[string]uint32 { "account.getChatThemes": AccountGetChatThemesRequestTypeID, "account.setAuthorizationTTL": AccountSetAuthorizationTTLRequestTypeID, "account.changeAuthorizationSettings": AccountChangeAuthorizationSettingsRequestTypeID, + "account.getSavedRingtones": AccountGetSavedRingtonesRequestTypeID, + "account.saveRingtone": AccountSaveRingtoneRequestTypeID, + "account.uploadRingtone": AccountUploadRingtoneRequestTypeID, "users.getUsers": UsersGetUsersRequestTypeID, "users.getFullUser": UsersGetFullUserRequestTypeID, "users.setSecureValueErrors": UsersSetSecureValueErrorsRequestTypeID, @@ -2673,6 +2747,14 @@ func NamesMap() map[string]uint32 { "messages.getUnreadReactions": MessagesGetUnreadReactionsRequestTypeID, "messages.readReactions": MessagesReadReactionsRequestTypeID, "messages.searchSentMedia": MessagesSearchSentMediaRequestTypeID, + "messages.getAttachMenuBots": MessagesGetAttachMenuBotsRequestTypeID, + "messages.getAttachMenuBot": MessagesGetAttachMenuBotRequestTypeID, + "messages.toggleBotInAttachMenu": MessagesToggleBotInAttachMenuRequestTypeID, + "messages.requestWebView": MessagesRequestWebViewRequestTypeID, + "messages.prolongWebView": MessagesProlongWebViewRequestTypeID, + "messages.requestSimpleWebView": MessagesRequestSimpleWebViewRequestTypeID, + "messages.sendWebViewResultMessage": MessagesSendWebViewResultMessageRequestTypeID, + "messages.sendWebViewData": MessagesSendWebViewDataRequestTypeID, "updates.getState": UpdatesGetStateRequestTypeID, "updates.getDifference": UpdatesGetDifferenceRequestTypeID, "updates.getChannelDifference": UpdatesGetChannelDifferenceRequestTypeID, @@ -2754,6 +2836,10 @@ func NamesMap() map[string]uint32 { "bots.setBotCommands": BotsSetBotCommandsRequestTypeID, "bots.resetBotCommands": BotsResetBotCommandsRequestTypeID, "bots.getBotCommands": BotsGetBotCommandsRequestTypeID, + "bots.setBotMenuButton": BotsSetBotMenuButtonRequestTypeID, + "bots.getBotMenuButton": BotsGetBotMenuButtonRequestTypeID, + "bots.setBotBroadcastDefaultAdminRights": BotsSetBotBroadcastDefaultAdminRightsRequestTypeID, + "bots.setBotGroupDefaultAdminRights": BotsSetBotGroupDefaultAdminRightsRequestTypeID, "payments.getPaymentForm": PaymentsGetPaymentFormRequestTypeID, "payments.getPaymentReceipt": PaymentsGetPaymentReceiptRequestTypeID, "payments.validateRequestedInfo": PaymentsValidateRequestedInfoRequestTypeID, @@ -2963,6 +3049,8 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MessageActionGroupCallScheduledTypeID: func() bin.Object { return &MessageActionGroupCallScheduled{} }, MessageActionSetChatThemeTypeID: func() bin.Object { return &MessageActionSetChatTheme{} }, MessageActionChatJoinedByRequestTypeID: func() bin.Object { return &MessageActionChatJoinedByRequest{} }, + MessageActionWebViewDataSentMeTypeID: func() bin.Object { return &MessageActionWebViewDataSentMe{} }, + MessageActionWebViewDataSentTypeID: func() bin.Object { return &MessageActionWebViewDataSent{} }, DialogTypeID: func() bin.Object { return &Dialog{} }, DialogFolderTypeID: func() bin.Object { return &DialogFolder{} }, PhotoEmptyTypeID: func() bin.Object { return &PhotoEmpty{} }, @@ -3131,6 +3219,10 @@ func TypesConstructorMap() map[uint32]func() bin.Object { UpdatePendingJoinRequestsTypeID: func() bin.Object { return &UpdatePendingJoinRequests{} }, UpdateBotChatInviteRequesterTypeID: func() bin.Object { return &UpdateBotChatInviteRequester{} }, UpdateMessageReactionsTypeID: func() bin.Object { return &UpdateMessageReactions{} }, + UpdateAttachMenuBotsTypeID: func() bin.Object { return &UpdateAttachMenuBots{} }, + UpdateWebViewResultSentTypeID: func() bin.Object { return &UpdateWebViewResultSent{} }, + UpdateBotMenuButtonTypeID: func() bin.Object { return &UpdateBotMenuButton{} }, + UpdateSavedRingtonesTypeID: func() bin.Object { return &UpdateSavedRingtones{} }, UpdatesStateTypeID: func() bin.Object { return &UpdatesState{} }, UpdatesDifferenceEmptyTypeID: func() bin.Object { return &UpdatesDifferenceEmpty{} }, UpdatesDifferenceTypeID: func() bin.Object { return &UpdatesDifference{} }, @@ -3286,6 +3378,8 @@ func TypesConstructorMap() map[uint32]func() bin.Object { 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{} }, KeyboardButtonRowTypeID: func() bin.Object { return &KeyboardButtonRow{} }, ReplyKeyboardHideTypeID: func() bin.Object { return &ReplyKeyboardHide{} }, ReplyKeyboardForceReplyTypeID: func() bin.Object { return &ReplyKeyboardForceReply{} }, @@ -3787,6 +3881,26 @@ func TypesConstructorMap() map[uint32]func() bin.Object { GroupCallStreamChannelTypeID: func() bin.Object { return &GroupCallStreamChannel{} }, PhoneGroupCallStreamChannelsTypeID: func() bin.Object { return &PhoneGroupCallStreamChannels{} }, PhoneGroupCallStreamRtmpURLTypeID: func() bin.Object { return &PhoneGroupCallStreamRtmpURL{} }, + AttachMenuBotIconColorTypeID: func() bin.Object { return &AttachMenuBotIconColor{} }, + AttachMenuBotIconTypeID: func() bin.Object { return &AttachMenuBotIcon{} }, + AttachMenuBotTypeID: func() bin.Object { return &AttachMenuBot{} }, + AttachMenuBotsNotModifiedTypeID: func() bin.Object { return &AttachMenuBotsNotModified{} }, + AttachMenuBotsTypeID: func() bin.Object { return &AttachMenuBots{} }, + AttachMenuBotsBotTypeID: func() bin.Object { return &AttachMenuBotsBot{} }, + WebViewResultURLTypeID: func() bin.Object { return &WebViewResultURL{} }, + SimpleWebViewResultURLTypeID: func() bin.Object { return &SimpleWebViewResultURL{} }, + WebViewMessageSentTypeID: func() bin.Object { return &WebViewMessageSent{} }, + BotMenuButtonDefaultTypeID: func() bin.Object { return &BotMenuButtonDefault{} }, + BotMenuButtonCommandsTypeID: func() bin.Object { return &BotMenuButtonCommands{} }, + BotMenuButtonTypeID: func() bin.Object { return &BotMenuButton{} }, + AccountSavedRingtonesNotModifiedTypeID: func() bin.Object { return &AccountSavedRingtonesNotModified{} }, + AccountSavedRingtonesTypeID: func() bin.Object { return &AccountSavedRingtones{} }, + NotificationSoundDefaultTypeID: func() bin.Object { return &NotificationSoundDefault{} }, + NotificationSoundNoneTypeID: func() bin.Object { return &NotificationSoundNone{} }, + NotificationSoundLocalTypeID: func() bin.Object { return &NotificationSoundLocal{} }, + NotificationSoundRingtoneTypeID: func() bin.Object { return &NotificationSoundRingtone{} }, + AccountSavedRingtoneTypeID: func() bin.Object { return &AccountSavedRingtone{} }, + AccountSavedRingtoneConvertedTypeID: func() bin.Object { return &AccountSavedRingtoneConverted{} }, InvokeAfterMsgRequestTypeID: func() bin.Object { return &InvokeAfterMsgRequest{} }, InvokeAfterMsgsRequestTypeID: func() bin.Object { return &InvokeAfterMsgsRequest{} }, InitConnectionRequestTypeID: func() bin.Object { return &InitConnectionRequest{} }, @@ -3886,6 +4000,9 @@ func TypesConstructorMap() map[uint32]func() bin.Object { AccountGetChatThemesRequestTypeID: func() bin.Object { return &AccountGetChatThemesRequest{} }, AccountSetAuthorizationTTLRequestTypeID: func() bin.Object { return &AccountSetAuthorizationTTLRequest{} }, AccountChangeAuthorizationSettingsRequestTypeID: func() bin.Object { return &AccountChangeAuthorizationSettingsRequest{} }, + AccountGetSavedRingtonesRequestTypeID: func() bin.Object { return &AccountGetSavedRingtonesRequest{} }, + AccountSaveRingtoneRequestTypeID: func() bin.Object { return &AccountSaveRingtoneRequest{} }, + AccountUploadRingtoneRequestTypeID: func() bin.Object { return &AccountUploadRingtoneRequest{} }, UsersGetUsersRequestTypeID: func() bin.Object { return &UsersGetUsersRequest{} }, UsersGetFullUserRequestTypeID: func() bin.Object { return &UsersGetFullUserRequest{} }, UsersSetSecureValueErrorsRequestTypeID: func() bin.Object { return &UsersSetSecureValueErrorsRequest{} }, @@ -4069,6 +4186,14 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MessagesGetUnreadReactionsRequestTypeID: func() bin.Object { return &MessagesGetUnreadReactionsRequest{} }, MessagesReadReactionsRequestTypeID: func() bin.Object { return &MessagesReadReactionsRequest{} }, MessagesSearchSentMediaRequestTypeID: func() bin.Object { return &MessagesSearchSentMediaRequest{} }, + MessagesGetAttachMenuBotsRequestTypeID: func() bin.Object { return &MessagesGetAttachMenuBotsRequest{} }, + MessagesGetAttachMenuBotRequestTypeID: func() bin.Object { return &MessagesGetAttachMenuBotRequest{} }, + MessagesToggleBotInAttachMenuRequestTypeID: func() bin.Object { return &MessagesToggleBotInAttachMenuRequest{} }, + MessagesRequestWebViewRequestTypeID: func() bin.Object { return &MessagesRequestWebViewRequest{} }, + MessagesProlongWebViewRequestTypeID: func() bin.Object { return &MessagesProlongWebViewRequest{} }, + MessagesRequestSimpleWebViewRequestTypeID: func() bin.Object { return &MessagesRequestSimpleWebViewRequest{} }, + MessagesSendWebViewResultMessageRequestTypeID: func() bin.Object { return &MessagesSendWebViewResultMessageRequest{} }, + MessagesSendWebViewDataRequestTypeID: func() bin.Object { return &MessagesSendWebViewDataRequest{} }, UpdatesGetStateRequestTypeID: func() bin.Object { return &UpdatesGetStateRequest{} }, UpdatesGetDifferenceRequestTypeID: func() bin.Object { return &UpdatesGetDifferenceRequest{} }, UpdatesGetChannelDifferenceRequestTypeID: func() bin.Object { return &UpdatesGetChannelDifferenceRequest{} }, @@ -4150,6 +4275,10 @@ func TypesConstructorMap() map[uint32]func() bin.Object { BotsSetBotCommandsRequestTypeID: func() bin.Object { return &BotsSetBotCommandsRequest{} }, BotsResetBotCommandsRequestTypeID: func() bin.Object { return &BotsResetBotCommandsRequest{} }, BotsGetBotCommandsRequestTypeID: func() bin.Object { return &BotsGetBotCommandsRequest{} }, + BotsSetBotMenuButtonRequestTypeID: func() bin.Object { return &BotsSetBotMenuButtonRequest{} }, + BotsGetBotMenuButtonRequestTypeID: func() bin.Object { return &BotsGetBotMenuButtonRequest{} }, + BotsSetBotBroadcastDefaultAdminRightsRequestTypeID: func() bin.Object { return &BotsSetBotBroadcastDefaultAdminRightsRequest{} }, + BotsSetBotGroupDefaultAdminRightsRequestTypeID: func() bin.Object { return &BotsSetBotGroupDefaultAdminRightsRequest{} }, PaymentsGetPaymentFormRequestTypeID: func() bin.Object { return &PaymentsGetPaymentFormRequest{} }, PaymentsGetPaymentReceiptRequestTypeID: func() bin.Object { return &PaymentsGetPaymentReceiptRequest{} }, PaymentsValidateRequestedInfoRequestTypeID: func() bin.Object { return &PaymentsValidateRequestedInfoRequest{} }, @@ -4230,6 +4359,14 @@ func ClassConstructorsMap() map[string][]uint32 { AccountResetPasswordRequestedWaitTypeID, AccountResetPasswordOkTypeID, }, + AccountSavedRingtoneClassName: { + AccountSavedRingtoneTypeID, + AccountSavedRingtoneConvertedTypeID, + }, + AccountSavedRingtonesClassName: { + AccountSavedRingtonesNotModifiedTypeID, + AccountSavedRingtonesTypeID, + }, AccountThemesClassName: { AccountThemesNotModifiedTypeID, AccountThemesTypeID, @@ -4238,6 +4375,10 @@ func ClassConstructorsMap() map[string][]uint32 { AccountWallPapersNotModifiedTypeID, AccountWallPapersTypeID, }, + AttachMenuBotsClassName: { + AttachMenuBotsNotModifiedTypeID, + AttachMenuBotsTypeID, + }, AuthAuthorizationClassName: { AuthAuthorizationTypeID, AuthAuthorizationSignUpRequiredTypeID, @@ -4292,6 +4433,11 @@ func ClassConstructorsMap() map[string][]uint32 { BotInlineResultTypeID, BotInlineMediaResultTypeID, }, + BotMenuButtonClassName: { + BotMenuButtonDefaultTypeID, + BotMenuButtonCommandsTypeID, + BotMenuButtonTypeID, + }, ChannelAdminLogEventActionClassName: { ChannelAdminLogEventActionChangeTitleTypeID, ChannelAdminLogEventActionChangeAboutTypeID, @@ -4691,6 +4837,8 @@ func ClassConstructorsMap() map[string][]uint32 { KeyboardButtonRequestPollTypeID, InputKeyboardButtonUserProfileTypeID, KeyboardButtonUserProfileTypeID, + KeyboardButtonWebViewTypeID, + KeyboardButtonSimpleWebViewTypeID, }, LangPackStringClassName: { LangPackStringTypeID, @@ -4728,6 +4876,8 @@ func ClassConstructorsMap() map[string][]uint32 { MessageActionGroupCallScheduledTypeID, MessageActionSetChatThemeTypeID, MessageActionChatJoinedByRequestTypeID, + MessageActionWebViewDataSentMeTypeID, + MessageActionWebViewDataSentTypeID, }, MessageClassName: { MessageEmptyTypeID, @@ -4866,6 +5016,12 @@ func ClassConstructorsMap() map[string][]uint32 { MessagesTranslateNoResultTypeID, MessagesTranslateResultTextTypeID, }, + NotificationSoundClassName: { + NotificationSoundDefaultTypeID, + NotificationSoundNoneTypeID, + NotificationSoundLocalTypeID, + NotificationSoundRingtoneTypeID, + }, NotifyPeerClassName: { NotifyPeerTypeID, NotifyUsersTypeID, @@ -5221,6 +5377,10 @@ func ClassConstructorsMap() map[string][]uint32 { UpdatePendingJoinRequestsTypeID, UpdateBotChatInviteRequesterTypeID, UpdateMessageReactionsTypeID, + UpdateAttachMenuBotsTypeID, + UpdateWebViewResultSentTypeID, + UpdateBotMenuButtonTypeID, + UpdateSavedRingtonesTypeID, }, UpdatesChannelDifferenceClassName: { UpdatesChannelDifferenceEmptyTypeID, diff --git a/tg/tl_server_gen.go b/tg/tl_server_gen.go index 57a5350536..f65c4383ac 100644 --- a/tg/tl_server_gen.go +++ b/tg/tl_server_gen.go @@ -1785,6 +1785,57 @@ func (s *ServerDispatcher) OnAccountChangeAuthorizationSettings(f func(ctx conte s.handlers[AccountChangeAuthorizationSettingsRequestTypeID] = handler } +func (s *ServerDispatcher) OnAccountGetSavedRingtones(f func(ctx context.Context, hash int64) (AccountSavedRingtonesClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request AccountGetSavedRingtonesRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, request.Hash) + if err != nil { + return nil, err + } + return &AccountSavedRingtonesBox{SavedRingtones: response}, nil + } + + s.handlers[AccountGetSavedRingtonesRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnAccountSaveRingtone(f func(ctx context.Context, request *AccountSaveRingtoneRequest) (AccountSavedRingtoneClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request AccountSaveRingtoneRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return &AccountSavedRingtoneBox{SavedRingtone: response}, nil + } + + s.handlers[AccountSaveRingtoneRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnAccountUploadRingtone(f func(ctx context.Context, request *AccountUploadRingtoneRequest) (DocumentClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request AccountUploadRingtoneRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, &request) + if err != nil { + return nil, err + } + return &DocumentBox{Document: response}, nil + } + + s.handlers[AccountUploadRingtoneRequestTypeID] = handler +} + func (s *ServerDispatcher) OnUsersGetUsers(f func(ctx context.Context, id []InputUserClass) ([]UserClass, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request UsersGetUsersRequest @@ -5076,6 +5127,150 @@ func (s *ServerDispatcher) OnMessagesSearchSentMedia(f func(ctx context.Context, s.handlers[MessagesSearchSentMediaRequestTypeID] = handler } +func (s *ServerDispatcher) OnMessagesGetAttachMenuBots(f func(ctx context.Context, hash int64) (AttachMenuBotsClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesGetAttachMenuBotsRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, request.Hash) + if err != nil { + return nil, err + } + return &AttachMenuBotsBox{AttachMenuBots: response}, nil + } + + s.handlers[MessagesGetAttachMenuBotsRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnMessagesGetAttachMenuBot(f func(ctx context.Context, bot InputUserClass) (*AttachMenuBotsBot, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesGetAttachMenuBotRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, request.Bot) + if err != nil { + return nil, err + } + return response, nil + } + + s.handlers[MessagesGetAttachMenuBotRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnMessagesToggleBotInAttachMenu(f func(ctx context.Context, request *MessagesToggleBotInAttachMenuRequest) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesToggleBotInAttachMenuRequest + 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[MessagesToggleBotInAttachMenuRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnMessagesRequestWebView(f func(ctx context.Context, request *MessagesRequestWebViewRequest) (*WebViewResultURL, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesRequestWebViewRequest + 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[MessagesRequestWebViewRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnMessagesProlongWebView(f func(ctx context.Context, request *MessagesProlongWebViewRequest) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesProlongWebViewRequest + 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[MessagesProlongWebViewRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnMessagesRequestSimpleWebView(f func(ctx context.Context, request *MessagesRequestSimpleWebViewRequest) (*SimpleWebViewResultURL, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesRequestSimpleWebViewRequest + 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[MessagesRequestSimpleWebViewRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnMessagesSendWebViewResultMessage(f func(ctx context.Context, request *MessagesSendWebViewResultMessageRequest) (*WebViewMessageSent, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesSendWebViewResultMessageRequest + 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[MessagesSendWebViewResultMessageRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnMessagesSendWebViewData(f func(ctx context.Context, request *MessagesSendWebViewDataRequest) (UpdatesClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request MessagesSendWebViewDataRequest + 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[MessagesSendWebViewDataRequestTypeID] = handler +} + func (s *ServerDispatcher) OnUpdatesGetState(f func(ctx context.Context) (*UpdatesState, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request UpdatesGetStateRequest @@ -6182,7 +6377,7 @@ func (s *ServerDispatcher) OnChannelsReadMessageContents(f func(ctx context.Cont s.handlers[ChannelsReadMessageContentsRequestTypeID] = handler } -func (s *ServerDispatcher) OnChannelsDeleteHistory(f func(ctx context.Context, request *ChannelsDeleteHistoryRequest) (bool, error)) { +func (s *ServerDispatcher) OnChannelsDeleteHistory(f func(ctx context.Context, request *ChannelsDeleteHistoryRequest) (UpdatesClass, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request ChannelsDeleteHistoryRequest if err := request.Decode(b); err != nil { @@ -6193,11 +6388,7 @@ func (s *ServerDispatcher) OnChannelsDeleteHistory(f func(ctx context.Context, r if err != nil { return nil, err } - if response { - return &BoolBox{Bool: &BoolTrue{}}, nil - } - - return &BoolBox{Bool: &BoolFalse{}}, nil + return &UpdatesBox{Updates: response}, nil } s.handlers[ChannelsDeleteHistoryRequestTypeID] = handler @@ -6533,6 +6724,86 @@ func (s *ServerDispatcher) OnBotsGetBotCommands(f func(ctx context.Context, requ s.handlers[BotsGetBotCommandsRequestTypeID] = handler } +func (s *ServerDispatcher) OnBotsSetBotMenuButton(f func(ctx context.Context, request *BotsSetBotMenuButtonRequest) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request BotsSetBotMenuButtonRequest + 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[BotsSetBotMenuButtonRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnBotsGetBotMenuButton(f func(ctx context.Context, userid InputUserClass) (BotMenuButtonClass, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request BotsGetBotMenuButtonRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, request.UserID) + if err != nil { + return nil, err + } + return &BotMenuButtonBox{BotMenuButton: response}, nil + } + + s.handlers[BotsGetBotMenuButtonRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnBotsSetBotBroadcastDefaultAdminRights(f func(ctx context.Context, adminrights ChatAdminRights) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request BotsSetBotBroadcastDefaultAdminRightsRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, request.AdminRights) + if err != nil { + return nil, err + } + if response { + return &BoolBox{Bool: &BoolTrue{}}, nil + } + + return &BoolBox{Bool: &BoolFalse{}}, nil + } + + s.handlers[BotsSetBotBroadcastDefaultAdminRightsRequestTypeID] = handler +} + +func (s *ServerDispatcher) OnBotsSetBotGroupDefaultAdminRights(f func(ctx context.Context, adminrights ChatAdminRights) (bool, error)) { + handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { + var request BotsSetBotGroupDefaultAdminRightsRequest + if err := request.Decode(b); err != nil { + return nil, err + } + + response, err := f(ctx, request.AdminRights) + if err != nil { + return nil, err + } + if response { + return &BoolBox{Bool: &BoolTrue{}}, nil + } + + return &BoolBox{Bool: &BoolFalse{}}, nil + } + + s.handlers[BotsSetBotGroupDefaultAdminRightsRequestTypeID] = handler +} + func (s *ServerDispatcher) OnPaymentsGetPaymentForm(f func(ctx context.Context, request *PaymentsGetPaymentFormRequest) (*PaymentsPaymentForm, error)) { handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) { var request PaymentsGetPaymentFormRequest diff --git a/tg/tl_simple_web_view_result_url_gen.go b/tg/tl_simple_web_view_result_url_gen.go new file mode 100644 index 0000000000..0c975351cc --- /dev/null +++ b/tg/tl_simple_web_view_result_url_gen.go @@ -0,0 +1,161 @@ +// 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{} +) + +// SimpleWebViewResultURL represents TL type `simpleWebViewResultUrl#882f76bb`. +// +// See https://core.telegram.org/constructor/simpleWebViewResultUrl for reference. +type SimpleWebViewResultURL struct { + // URL field of SimpleWebViewResultURL. + URL string +} + +// SimpleWebViewResultURLTypeID is TL type id of SimpleWebViewResultURL. +const SimpleWebViewResultURLTypeID = 0x882f76bb + +// Ensuring interfaces in compile-time for SimpleWebViewResultURL. +var ( + _ bin.Encoder = &SimpleWebViewResultURL{} + _ bin.Decoder = &SimpleWebViewResultURL{} + _ bin.BareEncoder = &SimpleWebViewResultURL{} + _ bin.BareDecoder = &SimpleWebViewResultURL{} +) + +func (s *SimpleWebViewResultURL) Zero() bool { + if s == nil { + return true + } + if !(s.URL == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *SimpleWebViewResultURL) String() string { + if s == nil { + return "SimpleWebViewResultURL(nil)" + } + type Alias SimpleWebViewResultURL + return fmt.Sprintf("SimpleWebViewResultURL%+v", Alias(*s)) +} + +// FillFrom fills SimpleWebViewResultURL from given interface. +func (s *SimpleWebViewResultURL) FillFrom(from interface { + GetURL() (value string) +}) { + s.URL = from.GetURL() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*SimpleWebViewResultURL) TypeID() uint32 { + return SimpleWebViewResultURLTypeID +} + +// TypeName returns name of type in TL schema. +func (*SimpleWebViewResultURL) TypeName() string { + return "simpleWebViewResultUrl" +} + +// TypeInfo returns info about TL type. +func (s *SimpleWebViewResultURL) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "simpleWebViewResultUrl", + ID: SimpleWebViewResultURLTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "URL", + SchemaName: "url", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *SimpleWebViewResultURL) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode simpleWebViewResultUrl#882f76bb as nil") + } + b.PutID(SimpleWebViewResultURLTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *SimpleWebViewResultURL) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode simpleWebViewResultUrl#882f76bb as nil") + } + b.PutString(s.URL) + return nil +} + +// Decode implements bin.Decoder. +func (s *SimpleWebViewResultURL) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode simpleWebViewResultUrl#882f76bb to nil") + } + if err := b.ConsumeID(SimpleWebViewResultURLTypeID); err != nil { + return fmt.Errorf("unable to decode simpleWebViewResultUrl#882f76bb: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *SimpleWebViewResultURL) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode simpleWebViewResultUrl#882f76bb to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode simpleWebViewResultUrl#882f76bb: field url: %w", err) + } + s.URL = value + } + return nil +} + +// GetURL returns value of URL field. +func (s *SimpleWebViewResultURL) GetURL() (value string) { + if s == nil { + return + } + return s.URL +} diff --git a/tg/tl_simple_web_view_result_url_slices_gen.go b/tg/tl_simple_web_view_result_url_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_simple_web_view_result_url_slices_gen.go @@ -0,0 +1,35 @@ +//go:build !no_gotd_slices +// +build !no_gotd_slices + +// Code generated by gotdgen, DO NOT EDIT. + +package tg + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) diff --git a/tg/tl_update_gen.go b/tg/tl_update_gen.go index f97b141a1e..2f7357bdfe 100644 --- a/tg/tl_update_gen.go +++ b/tg/tl_update_gen.go @@ -19385,6 +19385,508 @@ func (u *UpdateMessageReactions) GetReactions() (value MessageReactions) { return u.Reactions } +// UpdateAttachMenuBots represents TL type `updateAttachMenuBots#17b7a20b`. +// +// See https://core.telegram.org/constructor/updateAttachMenuBots for reference. +type UpdateAttachMenuBots struct { +} + +// UpdateAttachMenuBotsTypeID is TL type id of UpdateAttachMenuBots. +const UpdateAttachMenuBotsTypeID = 0x17b7a20b + +// construct implements constructor of UpdateClass. +func (u UpdateAttachMenuBots) construct() UpdateClass { return &u } + +// Ensuring interfaces in compile-time for UpdateAttachMenuBots. +var ( + _ bin.Encoder = &UpdateAttachMenuBots{} + _ bin.Decoder = &UpdateAttachMenuBots{} + _ bin.BareEncoder = &UpdateAttachMenuBots{} + _ bin.BareDecoder = &UpdateAttachMenuBots{} + + _ UpdateClass = &UpdateAttachMenuBots{} +) + +func (u *UpdateAttachMenuBots) Zero() bool { + if u == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (u *UpdateAttachMenuBots) String() string { + if u == nil { + return "UpdateAttachMenuBots(nil)" + } + type Alias UpdateAttachMenuBots + return fmt.Sprintf("UpdateAttachMenuBots%+v", Alias(*u)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*UpdateAttachMenuBots) TypeID() uint32 { + return UpdateAttachMenuBotsTypeID +} + +// TypeName returns name of type in TL schema. +func (*UpdateAttachMenuBots) TypeName() string { + return "updateAttachMenuBots" +} + +// TypeInfo returns info about TL type. +func (u *UpdateAttachMenuBots) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "updateAttachMenuBots", + ID: UpdateAttachMenuBotsTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (u *UpdateAttachMenuBots) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateAttachMenuBots#17b7a20b as nil") + } + b.PutID(UpdateAttachMenuBotsTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *UpdateAttachMenuBots) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateAttachMenuBots#17b7a20b as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (u *UpdateAttachMenuBots) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateAttachMenuBots#17b7a20b to nil") + } + if err := b.ConsumeID(UpdateAttachMenuBotsTypeID); err != nil { + return fmt.Errorf("unable to decode updateAttachMenuBots#17b7a20b: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *UpdateAttachMenuBots) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateAttachMenuBots#17b7a20b to nil") + } + return nil +} + +// UpdateWebViewResultSent represents TL type `updateWebViewResultSent#1592b79d`. +// +// See https://core.telegram.org/constructor/updateWebViewResultSent for reference. +type UpdateWebViewResultSent struct { + // QueryID field of UpdateWebViewResultSent. + QueryID int64 +} + +// UpdateWebViewResultSentTypeID is TL type id of UpdateWebViewResultSent. +const UpdateWebViewResultSentTypeID = 0x1592b79d + +// construct implements constructor of UpdateClass. +func (u UpdateWebViewResultSent) construct() UpdateClass { return &u } + +// Ensuring interfaces in compile-time for UpdateWebViewResultSent. +var ( + _ bin.Encoder = &UpdateWebViewResultSent{} + _ bin.Decoder = &UpdateWebViewResultSent{} + _ bin.BareEncoder = &UpdateWebViewResultSent{} + _ bin.BareDecoder = &UpdateWebViewResultSent{} + + _ UpdateClass = &UpdateWebViewResultSent{} +) + +func (u *UpdateWebViewResultSent) Zero() bool { + if u == nil { + return true + } + if !(u.QueryID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *UpdateWebViewResultSent) String() string { + if u == nil { + return "UpdateWebViewResultSent(nil)" + } + type Alias UpdateWebViewResultSent + return fmt.Sprintf("UpdateWebViewResultSent%+v", Alias(*u)) +} + +// FillFrom fills UpdateWebViewResultSent from given interface. +func (u *UpdateWebViewResultSent) FillFrom(from interface { + GetQueryID() (value int64) +}) { + u.QueryID = from.GetQueryID() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*UpdateWebViewResultSent) TypeID() uint32 { + return UpdateWebViewResultSentTypeID +} + +// TypeName returns name of type in TL schema. +func (*UpdateWebViewResultSent) TypeName() string { + return "updateWebViewResultSent" +} + +// TypeInfo returns info about TL type. +func (u *UpdateWebViewResultSent) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "updateWebViewResultSent", + ID: UpdateWebViewResultSentTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "QueryID", + SchemaName: "query_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (u *UpdateWebViewResultSent) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateWebViewResultSent#1592b79d as nil") + } + b.PutID(UpdateWebViewResultSentTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *UpdateWebViewResultSent) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateWebViewResultSent#1592b79d as nil") + } + b.PutLong(u.QueryID) + return nil +} + +// Decode implements bin.Decoder. +func (u *UpdateWebViewResultSent) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateWebViewResultSent#1592b79d to nil") + } + if err := b.ConsumeID(UpdateWebViewResultSentTypeID); err != nil { + return fmt.Errorf("unable to decode updateWebViewResultSent#1592b79d: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *UpdateWebViewResultSent) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateWebViewResultSent#1592b79d to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode updateWebViewResultSent#1592b79d: field query_id: %w", err) + } + u.QueryID = value + } + return nil +} + +// GetQueryID returns value of QueryID field. +func (u *UpdateWebViewResultSent) GetQueryID() (value int64) { + if u == nil { + return + } + return u.QueryID +} + +// UpdateBotMenuButton represents TL type `updateBotMenuButton#14b85813`. +// +// See https://core.telegram.org/constructor/updateBotMenuButton for reference. +type UpdateBotMenuButton struct { + // BotID field of UpdateBotMenuButton. + BotID int64 + // Button field of UpdateBotMenuButton. + Button BotMenuButtonClass +} + +// UpdateBotMenuButtonTypeID is TL type id of UpdateBotMenuButton. +const UpdateBotMenuButtonTypeID = 0x14b85813 + +// construct implements constructor of UpdateClass. +func (u UpdateBotMenuButton) construct() UpdateClass { return &u } + +// Ensuring interfaces in compile-time for UpdateBotMenuButton. +var ( + _ bin.Encoder = &UpdateBotMenuButton{} + _ bin.Decoder = &UpdateBotMenuButton{} + _ bin.BareEncoder = &UpdateBotMenuButton{} + _ bin.BareDecoder = &UpdateBotMenuButton{} + + _ UpdateClass = &UpdateBotMenuButton{} +) + +func (u *UpdateBotMenuButton) Zero() bool { + if u == nil { + return true + } + if !(u.BotID == 0) { + return false + } + if !(u.Button == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *UpdateBotMenuButton) String() string { + if u == nil { + return "UpdateBotMenuButton(nil)" + } + type Alias UpdateBotMenuButton + return fmt.Sprintf("UpdateBotMenuButton%+v", Alias(*u)) +} + +// FillFrom fills UpdateBotMenuButton from given interface. +func (u *UpdateBotMenuButton) FillFrom(from interface { + GetBotID() (value int64) + GetButton() (value BotMenuButtonClass) +}) { + u.BotID = from.GetBotID() + u.Button = from.GetButton() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*UpdateBotMenuButton) TypeID() uint32 { + return UpdateBotMenuButtonTypeID +} + +// TypeName returns name of type in TL schema. +func (*UpdateBotMenuButton) TypeName() string { + return "updateBotMenuButton" +} + +// TypeInfo returns info about TL type. +func (u *UpdateBotMenuButton) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "updateBotMenuButton", + ID: UpdateBotMenuButtonTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "BotID", + SchemaName: "bot_id", + }, + { + Name: "Button", + SchemaName: "button", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (u *UpdateBotMenuButton) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateBotMenuButton#14b85813 as nil") + } + b.PutID(UpdateBotMenuButtonTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *UpdateBotMenuButton) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateBotMenuButton#14b85813 as nil") + } + b.PutLong(u.BotID) + if u.Button == nil { + return fmt.Errorf("unable to encode updateBotMenuButton#14b85813: field button is nil") + } + if err := u.Button.Encode(b); err != nil { + return fmt.Errorf("unable to encode updateBotMenuButton#14b85813: field button: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (u *UpdateBotMenuButton) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateBotMenuButton#14b85813 to nil") + } + if err := b.ConsumeID(UpdateBotMenuButtonTypeID); err != nil { + return fmt.Errorf("unable to decode updateBotMenuButton#14b85813: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *UpdateBotMenuButton) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateBotMenuButton#14b85813 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode updateBotMenuButton#14b85813: field bot_id: %w", err) + } + u.BotID = value + } + { + value, err := DecodeBotMenuButton(b) + if err != nil { + return fmt.Errorf("unable to decode updateBotMenuButton#14b85813: field button: %w", err) + } + u.Button = value + } + return nil +} + +// GetBotID returns value of BotID field. +func (u *UpdateBotMenuButton) GetBotID() (value int64) { + if u == nil { + return + } + return u.BotID +} + +// GetButton returns value of Button field. +func (u *UpdateBotMenuButton) GetButton() (value BotMenuButtonClass) { + if u == nil { + return + } + return u.Button +} + +// UpdateSavedRingtones represents TL type `updateSavedRingtones#74d8be99`. +// +// See https://core.telegram.org/constructor/updateSavedRingtones for reference. +type UpdateSavedRingtones struct { +} + +// UpdateSavedRingtonesTypeID is TL type id of UpdateSavedRingtones. +const UpdateSavedRingtonesTypeID = 0x74d8be99 + +// construct implements constructor of UpdateClass. +func (u UpdateSavedRingtones) construct() UpdateClass { return &u } + +// Ensuring interfaces in compile-time for UpdateSavedRingtones. +var ( + _ bin.Encoder = &UpdateSavedRingtones{} + _ bin.Decoder = &UpdateSavedRingtones{} + _ bin.BareEncoder = &UpdateSavedRingtones{} + _ bin.BareDecoder = &UpdateSavedRingtones{} + + _ UpdateClass = &UpdateSavedRingtones{} +) + +func (u *UpdateSavedRingtones) Zero() bool { + if u == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (u *UpdateSavedRingtones) String() string { + if u == nil { + return "UpdateSavedRingtones(nil)" + } + type Alias UpdateSavedRingtones + return fmt.Sprintf("UpdateSavedRingtones%+v", Alias(*u)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*UpdateSavedRingtones) TypeID() uint32 { + return UpdateSavedRingtonesTypeID +} + +// TypeName returns name of type in TL schema. +func (*UpdateSavedRingtones) TypeName() string { + return "updateSavedRingtones" +} + +// TypeInfo returns info about TL type. +func (u *UpdateSavedRingtones) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "updateSavedRingtones", + ID: UpdateSavedRingtonesTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (u *UpdateSavedRingtones) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateSavedRingtones#74d8be99 as nil") + } + b.PutID(UpdateSavedRingtonesTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *UpdateSavedRingtones) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateSavedRingtones#74d8be99 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (u *UpdateSavedRingtones) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateSavedRingtones#74d8be99 to nil") + } + if err := b.ConsumeID(UpdateSavedRingtonesTypeID); err != nil { + return fmt.Errorf("unable to decode updateSavedRingtones#74d8be99: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *UpdateSavedRingtones) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateSavedRingtones#74d8be99 to nil") + } + return nil +} + // UpdateClassName is schema name of UpdateClass. const UpdateClassName = "Update" @@ -19494,6 +19996,10 @@ const UpdateClassName = "Update" // case *tg.UpdatePendingJoinRequests: // updatePendingJoinRequests#7063c3db // case *tg.UpdateBotChatInviteRequester: // updateBotChatInviteRequester#11dfa986 // case *tg.UpdateMessageReactions: // updateMessageReactions#154798c3 +// case *tg.UpdateAttachMenuBots: // updateAttachMenuBots#17b7a20b +// case *tg.UpdateWebViewResultSent: // updateWebViewResultSent#1592b79d +// case *tg.UpdateBotMenuButton: // updateBotMenuButton#14b85813 +// case *tg.UpdateSavedRingtones: // updateSavedRingtones#74d8be99 // default: panic(v) // } type UpdateClass interface { @@ -20194,6 +20700,34 @@ func DecodeUpdate(buf *bin.Buffer) (UpdateClass, error) { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) } return &v, nil + case UpdateAttachMenuBotsTypeID: + // Decoding updateAttachMenuBots#17b7a20b. + v := UpdateAttachMenuBots{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) + } + return &v, nil + case UpdateWebViewResultSentTypeID: + // Decoding updateWebViewResultSent#1592b79d. + v := UpdateWebViewResultSent{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) + } + return &v, nil + case UpdateBotMenuButtonTypeID: + // Decoding updateBotMenuButton#14b85813. + v := UpdateBotMenuButton{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) + } + return &v, nil + case UpdateSavedRingtonesTypeID: + // Decoding updateSavedRingtones#74d8be99. + v := UpdateSavedRingtones{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode UpdateClass: %w", bin.NewUnexpectedID(id)) } diff --git a/tg/tl_update_slices_gen.go b/tg/tl_update_slices_gen.go index 6f9dd40496..200b851464 100644 --- a/tg/tl_update_slices_gen.go +++ b/tg/tl_update_slices_gen.go @@ -1234,6 +1234,32 @@ func (s UpdateClassArray) AsUpdateMessageReactions() (to UpdateMessageReactionsA return to } +// AsUpdateWebViewResultSent returns copy with only UpdateWebViewResultSent constructors. +func (s UpdateClassArray) AsUpdateWebViewResultSent() (to UpdateWebViewResultSentArray) { + for _, elem := range s { + value, ok := elem.(*UpdateWebViewResultSent) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + +// AsUpdateBotMenuButton returns copy with only UpdateBotMenuButton constructors. +func (s UpdateClassArray) AsUpdateBotMenuButton() (to UpdateBotMenuButtonArray) { + for _, elem := range s { + value, ok := elem.(*UpdateBotMenuButton) + if !ok { + continue + } + to = append(to, *value) + } + + return to +} + // UpdateNewMessageArray is adapter for slice of UpdateNewMessage. type UpdateNewMessageArray []UpdateNewMessage @@ -8509,3 +8535,167 @@ func (s *UpdateMessageReactionsArray) Pop() (v UpdateMessageReactions, ok bool) return v, true } + +// UpdateWebViewResultSentArray is adapter for slice of UpdateWebViewResultSent. +type UpdateWebViewResultSentArray []UpdateWebViewResultSent + +// Sort sorts slice of UpdateWebViewResultSent. +func (s UpdateWebViewResultSentArray) Sort(less func(a, b UpdateWebViewResultSent) bool) UpdateWebViewResultSentArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of UpdateWebViewResultSent. +func (s UpdateWebViewResultSentArray) SortStable(less func(a, b UpdateWebViewResultSent) bool) UpdateWebViewResultSentArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of UpdateWebViewResultSent. +func (s UpdateWebViewResultSentArray) Retain(keep func(x UpdateWebViewResultSent) bool) UpdateWebViewResultSentArray { + 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 UpdateWebViewResultSentArray) First() (v UpdateWebViewResultSent, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s UpdateWebViewResultSentArray) Last() (v UpdateWebViewResultSent, 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 *UpdateWebViewResultSentArray) PopFirst() (v UpdateWebViewResultSent, 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 UpdateWebViewResultSent + 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 *UpdateWebViewResultSentArray) Pop() (v UpdateWebViewResultSent, 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 +} + +// UpdateBotMenuButtonArray is adapter for slice of UpdateBotMenuButton. +type UpdateBotMenuButtonArray []UpdateBotMenuButton + +// Sort sorts slice of UpdateBotMenuButton. +func (s UpdateBotMenuButtonArray) Sort(less func(a, b UpdateBotMenuButton) bool) UpdateBotMenuButtonArray { + sort.Slice(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// SortStable sorts slice of UpdateBotMenuButton. +func (s UpdateBotMenuButtonArray) SortStable(less func(a, b UpdateBotMenuButton) bool) UpdateBotMenuButtonArray { + sort.SliceStable(s, func(i, j int) bool { + return less(s[i], s[j]) + }) + return s +} + +// Retain filters in-place slice of UpdateBotMenuButton. +func (s UpdateBotMenuButtonArray) Retain(keep func(x UpdateBotMenuButton) bool) UpdateBotMenuButtonArray { + 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 UpdateBotMenuButtonArray) First() (v UpdateBotMenuButton, ok bool) { + if len(s) < 1 { + return + } + return s[0], true +} + +// Last returns last element of slice (if exists). +func (s UpdateBotMenuButtonArray) Last() (v UpdateBotMenuButton, 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 *UpdateBotMenuButtonArray) PopFirst() (v UpdateBotMenuButton, 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 UpdateBotMenuButton + 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 *UpdateBotMenuButtonArray) Pop() (v UpdateBotMenuButton, ok bool) { + if s == nil || len(*s) < 1 { + return + } + + a := *s + v = a[len(a)-1] + a = a[:len(a)-1] + *s = a + + return v, true +} diff --git a/tg/tl_user_full_gen.go b/tg/tl_user_full_gen.go index ca552a7a52..dcf38e3382 100644 --- a/tg/tl_user_full_gen.go +++ b/tg/tl_user_full_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// UserFull represents TL type `userFull#cf366521`. +// UserFull represents TL type `userFull#8c72ea81`. // Extended user info // // See https://core.telegram.org/constructor/userFull for reference. @@ -104,10 +104,18 @@ type UserFull struct { // // Use SetPrivateForwardName and GetPrivateForwardName helpers. PrivateForwardName string + // BotGroupAdminRights field of UserFull. + // + // Use SetBotGroupAdminRights and GetBotGroupAdminRights helpers. + BotGroupAdminRights ChatAdminRights + // BotBroadcastAdminRights field of UserFull. + // + // Use SetBotBroadcastAdminRights and GetBotBroadcastAdminRights helpers. + BotBroadcastAdminRights ChatAdminRights } // UserFullTypeID is TL type id of UserFull. -const UserFullTypeID = 0xcf366521 +const UserFullTypeID = 0x8c72ea81 // Ensuring interfaces in compile-time for UserFull. var ( @@ -178,6 +186,12 @@ func (u *UserFull) Zero() bool { if !(u.PrivateForwardName == "") { return false } + if !(u.BotGroupAdminRights.Zero()) { + return false + } + if !(u.BotBroadcastAdminRights.Zero()) { + return false + } return true } @@ -211,6 +225,8 @@ func (u *UserFull) FillFrom(from interface { GetTTLPeriod() (value int, ok bool) GetThemeEmoticon() (value string, ok bool) GetPrivateForwardName() (value string, ok bool) + GetBotGroupAdminRights() (value ChatAdminRights, ok bool) + GetBotBroadcastAdminRights() (value ChatAdminRights, ok bool) }) { u.Blocked = from.GetBlocked() u.PhoneCallsAvailable = from.GetPhoneCallsAvailable() @@ -254,6 +270,14 @@ func (u *UserFull) FillFrom(from interface { u.PrivateForwardName = val } + if val, ok := from.GetBotGroupAdminRights(); ok { + u.BotGroupAdminRights = val + } + + if val, ok := from.GetBotBroadcastAdminRights(); ok { + u.BotBroadcastAdminRights = val + } + } // TypeID returns type id in TL schema. @@ -365,6 +389,16 @@ func (u *UserFull) TypeInfo() tdp.Type { SchemaName: "private_forward_name", Null: !u.Flags.Has(16), }, + { + Name: "BotGroupAdminRights", + SchemaName: "bot_group_admin_rights", + Null: !u.Flags.Has(17), + }, + { + Name: "BotBroadcastAdminRights", + SchemaName: "bot_broadcast_admin_rights", + Null: !u.Flags.Has(18), + }, } return typ } @@ -413,12 +447,18 @@ func (u *UserFull) SetFlags() { if !(u.PrivateForwardName == "") { u.Flags.Set(16) } + if !(u.BotGroupAdminRights.Zero()) { + u.Flags.Set(17) + } + if !(u.BotBroadcastAdminRights.Zero()) { + u.Flags.Set(18) + } } // Encode implements bin.Encoder. func (u *UserFull) Encode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode userFull#cf366521 as nil") + return fmt.Errorf("can't encode userFull#8c72ea81 as nil") } b.PutID(UserFullTypeID) return u.EncodeBare(b) @@ -427,33 +467,33 @@ func (u *UserFull) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (u *UserFull) EncodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode userFull#cf366521 as nil") + return fmt.Errorf("can't encode userFull#8c72ea81 as nil") } u.SetFlags() if err := u.Flags.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cf366521: field flags: %w", err) + return fmt.Errorf("unable to encode userFull#8c72ea81: field flags: %w", err) } b.PutLong(u.ID) if u.Flags.Has(1) { b.PutString(u.About) } if err := u.Settings.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cf366521: field settings: %w", err) + return fmt.Errorf("unable to encode userFull#8c72ea81: field settings: %w", err) } if u.Flags.Has(2) { if u.ProfilePhoto == nil { - return fmt.Errorf("unable to encode userFull#cf366521: field profile_photo is nil") + return fmt.Errorf("unable to encode userFull#8c72ea81: field profile_photo is nil") } if err := u.ProfilePhoto.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cf366521: field profile_photo: %w", err) + return fmt.Errorf("unable to encode userFull#8c72ea81: field profile_photo: %w", err) } } if err := u.NotifySettings.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cf366521: field notify_settings: %w", err) + return fmt.Errorf("unable to encode userFull#8c72ea81: field notify_settings: %w", err) } if u.Flags.Has(3) { if err := u.BotInfo.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFull#cf366521: field bot_info: %w", err) + return fmt.Errorf("unable to encode userFull#8c72ea81: field bot_info: %w", err) } } if u.Flags.Has(6) { @@ -472,16 +512,26 @@ func (u *UserFull) EncodeBare(b *bin.Buffer) error { if u.Flags.Has(16) { b.PutString(u.PrivateForwardName) } + if u.Flags.Has(17) { + if err := u.BotGroupAdminRights.Encode(b); err != nil { + return fmt.Errorf("unable to encode userFull#8c72ea81: field bot_group_admin_rights: %w", err) + } + } + if u.Flags.Has(18) { + if err := u.BotBroadcastAdminRights.Encode(b); err != nil { + return fmt.Errorf("unable to encode userFull#8c72ea81: field bot_broadcast_admin_rights: %w", err) + } + } return nil } // Decode implements bin.Decoder. func (u *UserFull) Decode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode userFull#cf366521 to nil") + return fmt.Errorf("can't decode userFull#8c72ea81 to nil") } if err := b.ConsumeID(UserFullTypeID); err != nil { - return fmt.Errorf("unable to decode userFull#cf366521: %w", err) + return fmt.Errorf("unable to decode userFull#8c72ea81: %w", err) } return u.DecodeBare(b) } @@ -489,11 +539,11 @@ func (u *UserFull) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (u *UserFull) DecodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode userFull#cf366521 to nil") + return fmt.Errorf("can't decode userFull#8c72ea81 to nil") } { if err := u.Flags.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#cf366521: field flags: %w", err) + return fmt.Errorf("unable to decode userFull#8c72ea81: field flags: %w", err) } } u.Blocked = u.Flags.Has(0) @@ -505,81 +555,91 @@ func (u *UserFull) DecodeBare(b *bin.Buffer) error { { value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode userFull#cf366521: field id: %w", err) + return fmt.Errorf("unable to decode userFull#8c72ea81: field id: %w", err) } u.ID = value } if u.Flags.Has(1) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode userFull#cf366521: field about: %w", err) + return fmt.Errorf("unable to decode userFull#8c72ea81: field about: %w", err) } u.About = value } { if err := u.Settings.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#cf366521: field settings: %w", err) + return fmt.Errorf("unable to decode userFull#8c72ea81: field settings: %w", err) } } if u.Flags.Has(2) { value, err := DecodePhoto(b) if err != nil { - return fmt.Errorf("unable to decode userFull#cf366521: field profile_photo: %w", err) + return fmt.Errorf("unable to decode userFull#8c72ea81: field profile_photo: %w", err) } u.ProfilePhoto = value } { if err := u.NotifySettings.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#cf366521: field notify_settings: %w", err) + return fmt.Errorf("unable to decode userFull#8c72ea81: field notify_settings: %w", err) } } if u.Flags.Has(3) { if err := u.BotInfo.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFull#cf366521: field bot_info: %w", err) + return fmt.Errorf("unable to decode userFull#8c72ea81: field bot_info: %w", err) } } if u.Flags.Has(6) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode userFull#cf366521: field pinned_msg_id: %w", err) + return fmt.Errorf("unable to decode userFull#8c72ea81: field pinned_msg_id: %w", err) } u.PinnedMsgID = value } { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode userFull#cf366521: field common_chats_count: %w", err) + return fmt.Errorf("unable to decode userFull#8c72ea81: field common_chats_count: %w", err) } u.CommonChatsCount = value } if u.Flags.Has(11) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode userFull#cf366521: field folder_id: %w", err) + return fmt.Errorf("unable to decode userFull#8c72ea81: field folder_id: %w", err) } u.FolderID = value } if u.Flags.Has(14) { value, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode userFull#cf366521: field ttl_period: %w", err) + return fmt.Errorf("unable to decode userFull#8c72ea81: field ttl_period: %w", err) } u.TTLPeriod = value } if u.Flags.Has(15) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode userFull#cf366521: field theme_emoticon: %w", err) + return fmt.Errorf("unable to decode userFull#8c72ea81: field theme_emoticon: %w", err) } u.ThemeEmoticon = value } if u.Flags.Has(16) { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode userFull#cf366521: field private_forward_name: %w", err) + return fmt.Errorf("unable to decode userFull#8c72ea81: field private_forward_name: %w", err) } u.PrivateForwardName = value } + if u.Flags.Has(17) { + if err := u.BotGroupAdminRights.Decode(b); err != nil { + return fmt.Errorf("unable to decode userFull#8c72ea81: field bot_group_admin_rights: %w", err) + } + } + if u.Flags.Has(18) { + if err := u.BotBroadcastAdminRights.Decode(b); err != nil { + return fmt.Errorf("unable to decode userFull#8c72ea81: field bot_broadcast_admin_rights: %w", err) + } + } return nil } @@ -873,6 +933,42 @@ func (u *UserFull) GetPrivateForwardName() (value string, ok bool) { return u.PrivateForwardName, true } +// SetBotGroupAdminRights sets value of BotGroupAdminRights conditional field. +func (u *UserFull) SetBotGroupAdminRights(value ChatAdminRights) { + u.Flags.Set(17) + u.BotGroupAdminRights = value +} + +// GetBotGroupAdminRights returns value of BotGroupAdminRights conditional field and +// boolean which is true if field was set. +func (u *UserFull) GetBotGroupAdminRights() (value ChatAdminRights, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(17) { + return value, false + } + return u.BotGroupAdminRights, true +} + +// SetBotBroadcastAdminRights sets value of BotBroadcastAdminRights conditional field. +func (u *UserFull) SetBotBroadcastAdminRights(value ChatAdminRights) { + u.Flags.Set(18) + u.BotBroadcastAdminRights = value +} + +// GetBotBroadcastAdminRights returns value of BotBroadcastAdminRights conditional field and +// boolean which is true if field was set. +func (u *UserFull) GetBotBroadcastAdminRights() (value ChatAdminRights, ok bool) { + if u == nil { + return + } + if !u.Flags.Has(18) { + return value, false + } + return u.BotBroadcastAdminRights, true +} + // GetProfilePhotoAsNotEmpty returns mapped value of ProfilePhoto conditional field and // boolean which is true if field was set. func (u *UserFull) GetProfilePhotoAsNotEmpty() (*Photo, bool) { diff --git a/tg/tl_user_gen.go b/tg/tl_user_gen.go index 4fcc3497bb..9518b3df61 100644 --- a/tg/tl_user_gen.go +++ b/tg/tl_user_gen.go @@ -210,6 +210,8 @@ type User struct { // If set, this user was reported by many users as a fake or scam user: be careful when // interacting with them. Fake bool + // BotAttachMenu field of User. + BotAttachMenu bool // ID of the user ID int64 // Access hash of the user @@ -329,6 +331,9 @@ func (u *User) Zero() bool { if !(u.Fake == false) { return false } + if !(u.BotAttachMenu == false) { + return false + } if !(u.ID == 0) { return false } @@ -395,6 +400,7 @@ func (u *User) FillFrom(from interface { GetScam() (value bool) GetApplyMinPhoto() (value bool) GetFake() (value bool) + GetBotAttachMenu() (value bool) GetID() (value int64) GetAccessHash() (value int64, ok bool) GetFirstName() (value string, ok bool) @@ -423,6 +429,7 @@ func (u *User) FillFrom(from interface { u.Scam = from.GetScam() u.ApplyMinPhoto = from.GetApplyMinPhoto() u.Fake = from.GetFake() + u.BotAttachMenu = from.GetBotAttachMenu() u.ID = from.GetID() if val, ok := from.GetAccessHash(); ok { u.AccessHash = val @@ -568,6 +575,11 @@ func (u *User) TypeInfo() tdp.Type { SchemaName: "fake", Null: !u.Flags.Has(26), }, + { + Name: "BotAttachMenu", + SchemaName: "bot_attach_menu", + Null: !u.Flags.Has(27), + }, { Name: "ID", SchemaName: "id", @@ -678,6 +690,9 @@ func (u *User) SetFlags() { if !(u.Fake == false) { u.Flags.Set(26) } + if !(u.BotAttachMenu == false) { + u.Flags.Set(27) + } if !(u.AccessHash == 0) { u.Flags.Set(0) } @@ -819,6 +834,7 @@ func (u *User) DecodeBare(b *bin.Buffer) error { u.Scam = u.Flags.Has(24) u.ApplyMinPhoto = u.Flags.Has(25) u.Fake = u.Flags.Has(26) + u.BotAttachMenu = u.Flags.Has(27) { value, err := b.Long() if err != nil { @@ -1201,6 +1217,25 @@ func (u *User) GetFake() (value bool) { return u.Flags.Has(26) } +// SetBotAttachMenu sets value of BotAttachMenu conditional field. +func (u *User) SetBotAttachMenu(value bool) { + if value { + u.Flags.Set(27) + u.BotAttachMenu = true + } else { + u.Flags.Unset(27) + u.BotAttachMenu = false + } +} + +// GetBotAttachMenu returns value of BotAttachMenu conditional field. +func (u *User) GetBotAttachMenu() (value bool) { + if u == nil { + return + } + return u.Flags.Has(27) +} + // GetID returns value of ID field. func (u *User) GetID() (value int64) { if u == nil { diff --git a/tg/tl_web_view_message_sent_gen.go b/tg/tl_web_view_message_sent_gen.go new file mode 100644 index 0000000000..c9815a4380 --- /dev/null +++ b/tg/tl_web_view_message_sent_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{} +) + +// WebViewMessageSent represents TL type `webViewMessageSent#c94511c`. +// +// See https://core.telegram.org/constructor/webViewMessageSent for reference. +type WebViewMessageSent struct { + // Flags field of WebViewMessageSent. + Flags bin.Fields + // MsgID field of WebViewMessageSent. + // + // Use SetMsgID and GetMsgID helpers. + MsgID InputBotInlineMessageIDClass +} + +// WebViewMessageSentTypeID is TL type id of WebViewMessageSent. +const WebViewMessageSentTypeID = 0xc94511c + +// Ensuring interfaces in compile-time for WebViewMessageSent. +var ( + _ bin.Encoder = &WebViewMessageSent{} + _ bin.Decoder = &WebViewMessageSent{} + _ bin.BareEncoder = &WebViewMessageSent{} + _ bin.BareDecoder = &WebViewMessageSent{} +) + +func (w *WebViewMessageSent) Zero() bool { + if w == nil { + return true + } + if !(w.Flags.Zero()) { + return false + } + if !(w.MsgID == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (w *WebViewMessageSent) String() string { + if w == nil { + return "WebViewMessageSent(nil)" + } + type Alias WebViewMessageSent + return fmt.Sprintf("WebViewMessageSent%+v", Alias(*w)) +} + +// FillFrom fills WebViewMessageSent from given interface. +func (w *WebViewMessageSent) FillFrom(from interface { + GetMsgID() (value InputBotInlineMessageIDClass, ok bool) +}) { + if val, ok := from.GetMsgID(); ok { + w.MsgID = val + } + +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*WebViewMessageSent) TypeID() uint32 { + return WebViewMessageSentTypeID +} + +// TypeName returns name of type in TL schema. +func (*WebViewMessageSent) TypeName() string { + return "webViewMessageSent" +} + +// TypeInfo returns info about TL type. +func (w *WebViewMessageSent) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "webViewMessageSent", + ID: WebViewMessageSentTypeID, + } + if w == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "MsgID", + SchemaName: "msg_id", + Null: !w.Flags.Has(0), + }, + } + return typ +} + +// SetFlags sets flags for non-zero fields. +func (w *WebViewMessageSent) SetFlags() { + if !(w.MsgID == nil) { + w.Flags.Set(0) + } +} + +// Encode implements bin.Encoder. +func (w *WebViewMessageSent) Encode(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't encode webViewMessageSent#c94511c as nil") + } + b.PutID(WebViewMessageSentTypeID) + return w.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (w *WebViewMessageSent) EncodeBare(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't encode webViewMessageSent#c94511c as nil") + } + w.SetFlags() + if err := w.Flags.Encode(b); err != nil { + return fmt.Errorf("unable to encode webViewMessageSent#c94511c: field flags: %w", err) + } + if w.Flags.Has(0) { + if w.MsgID == nil { + return fmt.Errorf("unable to encode webViewMessageSent#c94511c: field msg_id is nil") + } + if err := w.MsgID.Encode(b); err != nil { + return fmt.Errorf("unable to encode webViewMessageSent#c94511c: field msg_id: %w", err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (w *WebViewMessageSent) Decode(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't decode webViewMessageSent#c94511c to nil") + } + if err := b.ConsumeID(WebViewMessageSentTypeID); err != nil { + return fmt.Errorf("unable to decode webViewMessageSent#c94511c: %w", err) + } + return w.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (w *WebViewMessageSent) DecodeBare(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't decode webViewMessageSent#c94511c to nil") + } + { + if err := w.Flags.Decode(b); err != nil { + return fmt.Errorf("unable to decode webViewMessageSent#c94511c: field flags: %w", err) + } + } + if w.Flags.Has(0) { + value, err := DecodeInputBotInlineMessageID(b) + if err != nil { + return fmt.Errorf("unable to decode webViewMessageSent#c94511c: field msg_id: %w", err) + } + w.MsgID = value + } + return nil +} + +// SetMsgID sets value of MsgID conditional field. +func (w *WebViewMessageSent) SetMsgID(value InputBotInlineMessageIDClass) { + w.Flags.Set(0) + w.MsgID = value +} + +// GetMsgID returns value of MsgID conditional field and +// boolean which is true if field was set. +func (w *WebViewMessageSent) GetMsgID() (value InputBotInlineMessageIDClass, ok bool) { + if w == nil { + return + } + if !w.Flags.Has(0) { + return value, false + } + return w.MsgID, true +} diff --git a/tg/tl_web_view_message_sent_slices_gen.go b/tg/tl_web_view_message_sent_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_web_view_message_sent_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_web_view_result_url_gen.go b/tg/tl_web_view_result_url_gen.go new file mode 100644 index 0000000000..5c32dec9eb --- /dev/null +++ b/tg/tl_web_view_result_url_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{} +) + +// WebViewResultURL represents TL type `webViewResultUrl#c14557c`. +// +// See https://core.telegram.org/constructor/webViewResultUrl for reference. +type WebViewResultURL struct { + // QueryID field of WebViewResultURL. + QueryID int64 + // URL field of WebViewResultURL. + URL string +} + +// WebViewResultURLTypeID is TL type id of WebViewResultURL. +const WebViewResultURLTypeID = 0xc14557c + +// Ensuring interfaces in compile-time for WebViewResultURL. +var ( + _ bin.Encoder = &WebViewResultURL{} + _ bin.Decoder = &WebViewResultURL{} + _ bin.BareEncoder = &WebViewResultURL{} + _ bin.BareDecoder = &WebViewResultURL{} +) + +func (w *WebViewResultURL) Zero() bool { + if w == nil { + return true + } + if !(w.QueryID == 0) { + return false + } + if !(w.URL == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (w *WebViewResultURL) String() string { + if w == nil { + return "WebViewResultURL(nil)" + } + type Alias WebViewResultURL + return fmt.Sprintf("WebViewResultURL%+v", Alias(*w)) +} + +// FillFrom fills WebViewResultURL from given interface. +func (w *WebViewResultURL) FillFrom(from interface { + GetQueryID() (value int64) + GetURL() (value string) +}) { + w.QueryID = from.GetQueryID() + w.URL = from.GetURL() +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*WebViewResultURL) TypeID() uint32 { + return WebViewResultURLTypeID +} + +// TypeName returns name of type in TL schema. +func (*WebViewResultURL) TypeName() string { + return "webViewResultUrl" +} + +// TypeInfo returns info about TL type. +func (w *WebViewResultURL) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "webViewResultUrl", + ID: WebViewResultURLTypeID, + } + if w == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "QueryID", + SchemaName: "query_id", + }, + { + Name: "URL", + SchemaName: "url", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (w *WebViewResultURL) Encode(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't encode webViewResultUrl#c14557c as nil") + } + b.PutID(WebViewResultURLTypeID) + return w.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (w *WebViewResultURL) EncodeBare(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't encode webViewResultUrl#c14557c as nil") + } + b.PutLong(w.QueryID) + b.PutString(w.URL) + return nil +} + +// Decode implements bin.Decoder. +func (w *WebViewResultURL) Decode(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't decode webViewResultUrl#c14557c to nil") + } + if err := b.ConsumeID(WebViewResultURLTypeID); err != nil { + return fmt.Errorf("unable to decode webViewResultUrl#c14557c: %w", err) + } + return w.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (w *WebViewResultURL) DecodeBare(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't decode webViewResultUrl#c14557c to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode webViewResultUrl#c14557c: field query_id: %w", err) + } + w.QueryID = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode webViewResultUrl#c14557c: field url: %w", err) + } + w.URL = value + } + return nil +} + +// GetQueryID returns value of QueryID field. +func (w *WebViewResultURL) GetQueryID() (value int64) { + if w == nil { + return + } + return w.QueryID +} + +// GetURL returns value of URL field. +func (w *WebViewResultURL) GetURL() (value string) { + if w == nil { + return + } + return w.URL +} diff --git a/tg/tl_web_view_result_url_slices_gen.go b/tg/tl_web_view_result_url_slices_gen.go new file mode 100644 index 0000000000..fe21471a4c --- /dev/null +++ b/tg/tl_web_view_result_url_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{} +)