diff --git a/_schema/tdapi.tl b/_schema/tdapi.tl index b684d07bbe..6e6a0846a0 100644 --- a/_schema/tdapi.tl +++ b/_schema/tdapi.tl @@ -1,7 +1,7 @@ // Code generated by ./cmd/dltl, DO NOT EDIT. // // Source: https://raw.githubusercontent.com/tdlib/td/master/td/generate/scheme/td_api.tl -// SHA256: f8442005f91b925bb51f9fbcea29a1e27a03455df6d99eff4ee7d8c040422eae +// SHA256: a9a7c0661179383525d56df0fd8e3658ee83c0fea81c0857600b370a5aa4a5e8 double#2210c154 ? = Double; @@ -468,7 +468,8 @@ userTypeDeleted#94403d24 = UserType; //@is_inline True, if the bot supports inline queries //@inline_query_placeholder Placeholder for inline queries (displayed on the application input field) //@need_location True, if the location of the user is expected to be sent with every inline query to this bot -userTypeBot#4b3e8235 can_join_groups:Bool can_read_all_group_messages:Bool is_inline:Bool inline_query_placeholder:string need_location:Bool = UserType; +//@can_be_added_to_attachment_menu True, if the bot can be added to attachment menu +userTypeBot#c6256f88 can_join_groups:Bool can_read_all_group_messages:Bool is_inline:Bool inline_query_placeholder:string need_location:Bool can_be_added_to_attachment_menu:Bool = UserType; //@description No information on the user besides the user identifier is available, yet this user has not been deleted. This object is extremely rare and must be handled like a deleted user. It is not possible to perform any actions on users of this type userTypeUnknown#d4d0613d = UserType; @@ -483,6 +484,11 @@ botCommand#c27ac8c7 command:string description:string = BotCommand; //@commands List of bot commands botCommands#4f9aa2c5 bot_user_id:int53 commands:vector = BotCommands; +//@description Describes a button to be shown instead of bot commands menu button +//@text Text of the button +//@url URL to be passed to openWebApp +botMenuButton#c7b57ce6 text:string url:string = BotMenuButton; + //@description Represents a location to which a chat is connected //@location The location //@address Location address; 1-64 characters, as defined by the chat owner @@ -522,6 +528,31 @@ inputChatPhotoStatic#75f7e2b3 photo:InputFile = InputChatPhoto; //@main_frame_timestamp Timestamp of the frame, which will be used as static chat photo inputChatPhotoAnimation#56a3422 animation:InputFile main_frame_timestamp:double = InputChatPhoto; +//@description Describes actions that a user is allowed to take in a chat +//@can_send_messages True, if the user can send text messages, contacts, locations, and venues +//@can_send_media_messages True, if the user can send audio files, documents, photos, videos, video notes, and voice notes. Implies can_send_messages permissions +//@can_send_polls True, if the user can send polls. Implies can_send_messages permissions +//@can_send_other_messages True, if the user can send animations, games, stickers, and dice and use inline bots. Implies can_send_messages permissions +//@can_add_web_page_previews True, if the user may add a web page preview to their messages. Implies can_send_messages permissions +//@can_change_info True, if the user can change the chat title, photo, and other settings +//@can_invite_users True, if the user can invite new users to the chat +//@can_pin_messages True, if the user can pin messages +chatPermissions#5e73d8df can_send_messages:Bool can_send_media_messages:Bool can_send_polls:Bool can_send_other_messages:Bool can_add_web_page_previews:Bool can_change_info:Bool can_invite_users:Bool can_pin_messages:Bool = ChatPermissions; + +//@description Describes rights of the administrator +//@can_manage_chat True, if the administrator can get chat event log, get chat statistics, get message statistics in channels, get channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other privilege; applicable to supergroups and channels only +//@can_change_info True, if the administrator can change the chat title, photo, and other settings +//@can_post_messages True, if the administrator can create channel posts; applicable to channels only +//@can_edit_messages True, if the administrator can edit messages of other users and pin messages; applicable to channels only +//@can_delete_messages True, if the administrator can delete messages of other users +//@can_invite_users True, if the administrator can invite new users to the chat +//@can_restrict_members True, if the administrator can restrict, ban, or unban chat members; always true for channels +//@can_pin_messages True, if the administrator can pin messages; applicable to basic groups and supergroups only +//@can_promote_members True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that were directly or indirectly promoted by them +//@can_manage_video_chats True, if the administrator can manage video chats +//@is_anonymous True, if the administrator isn't shown in the chat member list and sends messages anonymously; applicable to supergroups only +chatAdministratorRights#6ffd893e can_manage_chat:Bool can_change_info:Bool can_post_messages:Bool can_edit_messages:Bool can_delete_messages:Bool can_invite_users:Bool can_restrict_members:Bool can_pin_messages:Bool can_promote_members:Bool can_manage_video_chats:Bool is_anonymous:Bool = ChatAdministratorRights; + //@description Represents a user //@id User identifier //@first_name First name of the user @@ -542,6 +573,15 @@ inputChatPhotoAnimation#56a3422 animation:InputFile main_frame_timestamp:double //@language_code IETF language tag of the user's language; only available to bots user#dff1de69 id:int53 first_name:string last_name:string username:string phone_number:string status:UserStatus profile_photo:profilePhoto is_contact:Bool is_mutual_contact:Bool is_verified:Bool is_support:Bool restriction_reason:string is_scam:Bool is_fake:Bool have_access:Bool type:UserType language_code:string = User; +//@description Contains information about a bot +//@share_text The text that is shown on the bot's profile page and is sent together with the link when users share the bot +//@param_description The text shown in the chat with the bot if the chat is empty +//@menu_button Information about a button to show instead of the bot commands menu button; may be null if ordinary bot commands menu must be shown +//@commands List of the bot commands +//@default_group_administrator_rights Default administrator rights for adding the bot to basic group and supergroup chats; may be null +//@default_channel_administrator_rights Default administrator rights for adding the bot to channels; may be null +botInfo#729c7b7e share_text:string description:string menu_button:botMenuButton commands:vector default_group_administrator_rights:chatAdministratorRights default_channel_administrator_rights:chatAdministratorRights = BotInfo; + //@description Contains full information about a user //@photo User profile photo; may be null //@is_blocked True, if the user is blocked by the current user @@ -551,11 +591,9 @@ user#dff1de69 id:int53 first_name:string last_name:string username:string phone_ //@has_private_forwards True, if the user can't be linked in forwarded messages due to their privacy settings //@need_phone_number_privacy_exception True, if the current user needs to explicitly allow to share their phone number with the user when the method addContact is used //@bio A short user bio -//@share_text For bots, the text that is shown on the bot's profile page and is sent together with the link when users share the bot -//@param_description For bots, the text shown in the chat with the bot if the chat is empty //@group_in_common_count Number of group chats where both the other user and the current user are a member; 0 for the current user -//@commands For bots, list of the bot commands -userFullInfo#bbb225cf photo:chatPhoto is_blocked:Bool can_be_called:Bool supports_video_calls:Bool has_private_calls:Bool has_private_forwards:Bool need_phone_number_privacy_exception:Bool bio:string share_text:string description:string group_in_common_count:int32 commands:vector = UserFullInfo; +//@bot_info For bots, information about the bot; may be null +userFullInfo#b2090391 photo:chatPhoto is_blocked:Bool can_be_called:Bool supports_video_calls:Bool has_private_calls:Bool has_private_forwards:Bool need_phone_number_privacy_exception:Bool bio:string group_in_common_count:int32 bot_info:botInfo = UserFullInfo; //@description Represents a list of users //@total_count Approximate total number of users found @@ -572,17 +610,6 @@ chatAdministrator#7277bd2c user_id:int53 custom_title:string is_owner:Bool = Cha //@administrators A list of chat administrators chatAdministrators#5141ca21 administrators:vector = ChatAdministrators; -//@description Describes actions that a user is allowed to take in a chat -//@can_send_messages True, if the user can send text messages, contacts, locations, and venues -//@can_send_media_messages True, if the user can send audio files, documents, photos, videos, video notes, and voice notes. Implies can_send_messages permissions -//@can_send_polls True, if the user can send polls. Implies can_send_messages permissions -//@can_send_other_messages True, if the user can send animations, games, stickers, and dice and use inline bots. Implies can_send_messages permissions -//@can_add_web_page_previews True, if the user may add a web page preview to their messages. Implies can_send_messages permissions -//@can_change_info True, if the user can change the chat title, photo, and other settings -//@can_invite_users True, if the user can invite new users to the chat -//@can_pin_messages True, if the user can pin messages -chatPermissions#5e73d8df can_send_messages:Bool can_send_media_messages:Bool can_send_polls:Bool can_send_other_messages:Bool can_add_web_page_previews:Bool can_change_info:Bool can_invite_users:Bool can_pin_messages:Bool = ChatPermissions; - //@class ChatMemberStatus @description Provides information about the status of a member in a chat //@description The user is the owner of the chat and has all the administrator privileges @@ -594,18 +621,8 @@ chatMemberStatusCreator#f6764afe custom_title:string is_anonymous:Bool is_member //@description The user is a member of the chat and has some additional privileges. In basic groups, administrators can edit and delete messages sent by others, add new members, ban unprivileged members, and manage video chats. In supergroups and channels, there are more detailed options for administrator privileges //@custom_title A custom title of the administrator; 0-16 characters without emojis; applicable to supergroups only //@can_be_edited True, if the current user can edit the administrator privileges for the called user -//@can_manage_chat True, if the administrator can get chat event log, get chat statistics, get message statistics in channels, get channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other privilege; applicable to supergroups and channels only -//@can_change_info True, if the administrator can change the chat title, photo, and other settings -//@can_post_messages True, if the administrator can create channel posts; applicable to channels only -//@can_edit_messages True, if the administrator can edit messages of other users and pin messages; applicable to channels only -//@can_delete_messages True, if the administrator can delete messages of other users -//@can_invite_users True, if the administrator can invite new users to the chat -//@can_restrict_members True, if the administrator can restrict, ban, or unban chat members; always true for channels -//@can_pin_messages True, if the administrator can pin messages; applicable to basic groups and supergroups only -//@can_promote_members True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that were directly or indirectly promoted by them -//@can_manage_video_chats True, if the administrator can manage video chats -//@is_anonymous True, if the administrator isn't shown in the chat member list and sends messages anonymously; applicable to supergroups only -chatMemberStatusAdministrator#4e6efea custom_title:string can_be_edited:Bool can_manage_chat:Bool can_change_info:Bool can_post_messages:Bool can_edit_messages:Bool can_delete_messages:Bool can_invite_users:Bool can_restrict_members:Bool can_pin_messages:Bool can_promote_members:Bool can_manage_video_chats:Bool is_anonymous:Bool = ChatMemberStatus; +//@rights Rights of the administrator +chatMemberStatusAdministrator#fbd3841d custom_title:string can_be_edited:Bool rights:chatAdministratorRights = ChatMemberStatus; //@description The user is a member of the chat, without any additional privileges or restrictions chatMemberStatusMember#32597455 = ChatMemberStatus; @@ -900,7 +917,7 @@ messageReplyInfo#69240cb9 reply_count:int32 recent_replier_ids:vector = MessageReaction; //@description Contains information about interactions with a message @@ -1004,7 +1021,7 @@ messageCalendar#2582bbd7 total_count:int32 days:vector = Mes //@message_id Message identifier; unique for the chat to which the sponsored message belongs among both ordinary and sponsored messages //@sponsor_chat_id Sponsor chat identifier; 0 if the sponsor chat is accessible through an invite link //@sponsor_chat_info Information about the sponsor chat; may be null unless sponsor_chat_id == 0 -//@link An internal link to be opened when the sponsored message is clicked; may be null. If null, the sponsor chat needs to be opened instead +//@link An internal link to be opened when the sponsored message is clicked; may be null if the sponsor chat needs to be opened instead //@content Content of the message. Currently, can be only of the type messageText sponsoredMessage#ad7c99d8 message_id:int53 sponsor_chat_id:int53 sponsor_chat_info:chatInviteLinkInfo link:InternalLinkType content:MessageContent = SponsoredMessage; @@ -1033,35 +1050,35 @@ foundFileDownloads#c7db4128 total_counts:downloadedFileCounts files:vector caption:pageBlockCapti //@description A link to a chat //@title Chat title //@photo Chat photo; may be null -//@username Chat username, by which all other information about the chat can be resolved +//@username Chat username by which all other information about the chat can be resolved pageBlockChatLink#f3f4550b title:string photo:chatPhotoInfo username:string = PageBlock; //@description A table @@ -1705,6 +1735,15 @@ bankCardInfo#2bc7da9f title:string actions:vector = BankC //@postal_code Address postal code address#86304f3a country_code:string state:string city:string street_line1:string street_line2:string postal_code:string = Address; +//@description Contains parameters of the app theme +//@background_color A color of the background in the RGB24 format +//@text_color A color of text in the RGB24 format +//@hint_color A color of hints in the RGB24 format +//@link_color A color of links in the RGB24 format +//@button_color A color of the buttons in the RGB24 format +//@button_text_color A color of text on the buttons in the RGB24 format +themeParameters#8d6f03d4 background_color:int32 text_color:int32 hint_color:int32 link_color:int32 button_color:int32 button_text_color:int32 = ThemeParameters; + //@description Portion of the price of a product (e.g., "delivery cost", "tax amount") //@label Label for this portion of the product price //@amount Currency amount in the smallest units of the currency @@ -1769,15 +1808,6 @@ inputCredentialsGooglePay#32544764 data:string = InputCredentials; //@need_cardholder_name True, if the cardholder name must be provided paymentsProviderStripe#41042678 publishable_key:string need_country:Bool need_postal_code:Bool need_cardholder_name:Bool = PaymentsProviderStripe; -//@description Theme colors for a payment form -//@background_color A color of the payment form background in the RGB24 format -//@text_color A color of text in the RGB24 format -//@hint_color A color of hints in the RGB24 format -//@link_color A color of links in the RGB24 format -//@button_color A color of the buttons in the RGB24 format -//@button_text_color A color of text on the buttons in the RGB24 format -paymentFormTheme#97180f8f background_color:int32 text_color:int32 hint_color:int32 link_color:int32 button_color:int32 button_text_color:int32 = PaymentFormTheme; - //@description Contains information about an invoice payment form //@id The payment form identifier //@invoice Full information of the invoice @@ -2365,7 +2395,16 @@ messageContactRegistered#a678fcff = MessageContent; //@domain_name Domain name of the connected website messageWebsiteConnected#bff3a408 domain_name:string = MessageContent; -//@description Telegram Passport data has been sent +//@description Data from a web app has been sent to a bot +//@button_text Text of the keyboardButtonTypeWebApp button, which opened the web app +messageWebAppDataSent#fb033912 button_text:string = MessageContent; + +//@description Data from a web app has been received; for bots only +//@button_text Text of the keyboardButtonTypeWebApp button, which opened the web app +//@data Received data +messageWebAppDataReceived#ff7d1a15 button_text:string data:string = MessageContent; + +//@description Telegram Passport data has been sent to a bot //@types List of Telegram Passport element types sent messagePassportDataSent#26c5ed6b types:vector = MessageContent; @@ -3048,6 +3087,27 @@ diceStickersSlotMachine#e9a28cac background:sticker lever:sticker left_reel:stic //@importer_count The number of users that imported the corresponding contact; 0 for already registered users or if unavailable importedContacts#1119a03e user_ids:vector importer_count:vector = ImportedContacts; +//@description Describes a color to highlight a bot added to attachment menu +//@light_color Color in the RGB24 format for light themes +//@dark_color Color in the RGB24 format for dark themes +attachmentMenuBotColor#64235ebc light_color:int32 dark_color:int32 = AttachmentMenuBotColor; + +//@description Represents a bot added to attachment menu +//@bot_user_id User identifier of the bot added to attachment menu +//@name Name for the bot in attachment menu +//@name_color Color to highlight selected name of the bot if appropriate; may be null +//@default_icon Default attachment menu icon for the bot in SVG format; may be null +//@ios_static_icon Attachment menu icon for the bot in SVG format for the official iOS app; may be null +//@ios_animated_icon Attachment menu icon for the bot in TGS format for the official iOS app; may be null +//@android_icon Attachment menu icon for the bot in TGS format for the official Android app; may be null +//@macos_icon Attachment menu icon for the bot in TGS format for the official native macOS app; may be null +//@icon_color Color to highlight selected icon of the bot if appropriate; may be null +attachmentMenuBot#5e82be30 bot_user_id:int53 name:string name_color:attachmentMenuBotColor default_icon:file ios_static_icon:file ios_animated_icon:file android_icon:file macos_icon:file icon_color:attachmentMenuBotColor = AttachmentMenuBot; + +//@description Information about the message sent by answerWebAppQuery +//@inline_message_id Identifier of the sent inline message, if known +sentWebAppMessage#4a24eec0 inline_message_id:string = SentWebAppMessage; + //@description Contains an HTTP URL //@url The URL httpUrl#87b775a6 url:string = HttpUrl; @@ -3917,12 +3977,25 @@ notificationGroupTypeSecretChat#52e54e34 = NotificationGroupType; //@description A group containing notifications of type notificationTypeNewCall notificationGroupTypeCalls#5233c152 = NotificationGroupType; +//@description Describes a notification sound in MP3 format +//@id Unique identifier of the notification sound +//@duration Duration of the sound, in seconds +//@date Point in time (Unix timestamp) when the sound was created +//@title Title of the notification sound +//@data Arbitrary data, defined while the sound was uploaded +//@sound File containing the sound +notificationSound#f4ef6137 id:int64 duration:int32 date:int32 title:string data:string sound:file = NotificationSound; + +//@description Contains a list of notification sounds +//@notification_sounds A list of notification sounds +notificationSounds#7ba3c849 notification_sounds:vector = NotificationSounds; + //@description Contains information about a notification //@id Unique persistent identifier of this notification //@date Notification date -//@is_silent True, if the notification was initially silent +//@sound_id Identifier of the notification sound to be played; 0 if sound is disabled //@type Notification type -notification#2f0343d0 id:int32 date:int32 is_silent:Bool type:NotificationType = Notification; +notification#81fa1b96 id:int32 date:int32 sound_id:int64 type:NotificationType = Notification; //@description Describes a group of notifications //@id Unique persistent auto-incremented from 1 identifier of the notification group @@ -4077,7 +4150,7 @@ sessions#997833aa sessions:vector inactive_session_ttl_days:int32 = Ses //@log_in_date Point in time (Unix timestamp) when the user was logged in //@last_active_date Point in time (Unix timestamp) when obtained authorization was last used //@ip IP address from which the user was logged in, in human-readable format -//@location Human-readable description of a country and a region, from which the user was logged in, based on the IP address +//@location Human-readable description of a country and a region from which the user was logged in, based on the IP address connectedWebsite#324ea36d id:int64 domain_name:string bot_user_id:int53 browser:string platform:string log_in_date:int32 last_active_date:int32 ip:string location:string = ConnectedWebsite; //@description Contains a list of websites the current user is logged in with Telegram @@ -4121,6 +4194,12 @@ chatReportReasonCustom#4cd37316 = ChatReportReason; //@description The link is a link to the active sessions section of the app. Use getActiveSessions to handle the link internalLinkTypeActiveSessions#706bbbad = InternalLinkType; +//@description The link is a link to an attachment menu bot to be opened in the specified chat. Process given chat_link to open corresponding chat. +//@chat_link An internal link pointing to a chat; may be null if the current chat needs to be kept +//@bot_username Username of the bot +//@url URL to be passed to openWebApp +internalLinkTypeAttachmentMenuBot#63932054 chat_link:InternalLinkType bot_username:string url:string = InternalLinkType; + //@description The link contains an authentication code. Call checkAuthenticationCode with the code if the current authorization state is authorizationStateWaitCode //@code The authentication code internalLinkTypeAuthenticationCode#f3874ff2 code:string = InternalLinkType; @@ -4137,7 +4216,13 @@ internalLinkTypeBotStart#b812d93d bot_username:string start_parameter:string = I //@description The link is a link to a Telegram bot, which is supposed to be added to a group chat. Call searchPublicChat with the given bot username, check that the user is a bot and can be added to groups, //@bot_username Username of the bot //@start_parameter The parameter to be passed to sendBotStartMessage -internalLinkTypeBotStartInGroup#c201649c bot_username:string start_parameter:string = InternalLinkType; +//@administrator_rights Expected administrator rights for the bot; may be null +internalLinkTypeBotStartInGroup#ca0d8cce bot_username:string start_parameter:string administrator_rights:chatAdministratorRights = InternalLinkType; + +//@description The link is a link to a Telegram bot, which is supposed to be added to a channel chat as an administrator. Call searchPublicChat with the given bot username and check that the user is a bot, +//@bot_username Username of the bot +//@administrator_rights Expected administrator rights for the bot +internalLinkTypeBotAddToChannel#538ac2c0 bot_username:string administrator_rights:chatAdministratorRights = InternalLinkType; //@description The link is a link to the change phone number section of the app internalLinkTypeChangePhoneNumber#f0275b01 = InternalLinkType; @@ -4262,6 +4347,9 @@ fileTypeAudio#d5bbcea0 = FileType; //@description The file is a document fileTypeDocument#de57030f = FileType; +//@description The file is a notification sound +fileTypeNotificationSound#c32f9f09 = FileType; + //@description The file is a photo fileTypePhoto#998b71a5 = FileType; @@ -4898,11 +4986,11 @@ updateNotification#8ee67ed4 notification_group_id:int32 notification:notificatio //@type New type of the notification group //@chat_id Identifier of a chat to which all notifications in the group belong //@notification_settings_chat_id Chat identifier, which notification settings must be applied to the added notifications -//@is_silent True, if the notifications must be shown without sound +//@notification_sound_id Identifier of the notification sound to be played; 0 if sound is disabled //@total_count Total number of unread notifications in the group, can be bigger than number of active notifications //@added_notifications List of added group notifications, sorted by notification ID //@removed_notification_ids Identifiers of removed group notifications, sorted by notification ID -updateNotificationGroup#2ec53c49 notification_group_id:int32 type:NotificationGroupType chat_id:int53 notification_settings_chat_id:int53 is_silent:Bool total_count:int32 added_notifications:vector removed_notification_ids:vector = Update; +updateNotificationGroup#96cd9e06 notification_group_id:int32 type:NotificationGroupType chat_id:int53 notification_settings_chat_id:int53 notification_sound_id:int64 total_count:int32 added_notifications:vector removed_notification_ids:vector = Update; //@description Contains active notifications that was shown on previous application launches. This update is sent only if the message database is used. In that case it comes once before any updateNotification and updateNotificationGroup update //@groups Lists of active notification groups @@ -5075,6 +5163,10 @@ updateFavoriteStickers#113f2b6a sticker_ids:vector = Update; //@animation_ids The new list of file identifiers of saved animations updateSavedAnimations#1084a1c8 animation_ids:vector = Update; +//@description The list of saved notifications sounds was updated. This update may not be sent until information about a notification sound was requested for the first time +//@notification_sound_ids The new list of identifiers of saved notification sounds +updateSavedNotificationSounds#5a6653b4 notification_sound_ids:vector = Update; + //@description The selected background has changed //@for_dark_theme True, if background for dark theme has changed //@background The new selected background; may be null @@ -5103,6 +5195,14 @@ updateTermsOfService#b23cc55e terms_of_service_id:string terms_of_service:termsO //@users_nearby The new list of users nearby updateUsersNearby#97c8ab5 users_nearby:vector = Update; +//@description The list of bots added to attachment menu has changed +//@bots The new list of bots added to attachment menu. The bots must be shown in attachment menu only in private chats. The bots must not be shown on scheduled messages screen +updateAttachmentMenuBots#b6b910c bots:vector = Update; + +//@description A message was sent by an opened web app, so the web app needs to be closed +//@web_app_launch_id Identifier of web app launch +updateWebAppMessageSent#58431229 web_app_launch_id:int64 = Update; + //@description The list of supported reactions has changed //@reactions The new list of supported reactions updateReactions#e769e4e7 reactions:vector = Update; @@ -5131,7 +5231,7 @@ updateSuggestedActions#c2e5cccb added_actions:vector removed_ac //@id Unique query identifier //@sender_user_id Identifier of the user who sent the query //@user_location User location; may be null -//@chat_type The type of the chat, from which the query originated; may be null if unknown +//@chat_type The type of the chat from which the query originated; may be null if unknown //@query Text of the query //@offset Offset of the first entry to return updateNewInlineQuery#7171bf34 id:int64 sender_user_id:int53 user_location:location chat_type:ChatType query:string offset:string = Update; @@ -5148,7 +5248,7 @@ updateNewChosenInlineResult#cb4c4f5d sender_user_id:int53 user_location:location //@id Unique query identifier //@sender_user_id Identifier of the user who sent the query //@chat_id Identifier of the chat where the query was sent -//@message_id Identifier of the message, from which the query originated +//@message_id Identifier of the message from which the query originated //@chat_instance Identifier that uniquely corresponds to the chat to which the message was sent //@payload Query payload updateNewCallbackQuery#8964d05e id:int64 sender_user_id:int53 chat_id:int53 message_id:int53 chat_instance:int64 payload:CallbackQueryPayload = Update; @@ -5156,7 +5256,7 @@ updateNewCallbackQuery#8964d05e id:int64 sender_user_id:int53 chat_id:int53 mess //@description A new incoming callback query from a message sent via a bot; for bots only //@id Unique query identifier //@sender_user_id Identifier of the user who sent the query -//@inline_message_id Identifier of the inline message, from which the query originated +//@inline_message_id Identifier of the inline message from which the query originated //@chat_instance An identifier uniquely corresponding to the chat a message was sent to //@payload Query payload updateNewInlineCallbackQuery#ecf934ba id:int64 sender_user_id:int53 inline_message_id:string chat_instance:int64 payload:CallbackQueryPayload = Update; @@ -5582,7 +5682,7 @@ getMessageThreadHistory#9435d428 chat_id:int53 message_id:int53 from_message_id: //@revoke Pass true to delete chat history for all users deleteChatHistory#a841d09f chat_id:int53 remove_from_chat_list:Bool revoke:Bool = Ok; -//@description Deletes a chat along with all messages in the corresponding chat for all chat members; requires owner privileges. For group chats this will release the username and remove all members. Chats with more than 1000 members can't be deleted using this method +//@description Deletes a chat along with all messages in the corresponding chat for all chat members. For group chats this will release the username and remove all members. Use the field chat.can_be_deleted_for_all_users to find whether the method can be applied to the chat //@chat_id Chat identifier deleteChat#f5cae05e chat_id:int53 = Ok; @@ -5725,7 +5825,7 @@ setChatMessageSender#ab456b7e chat_id:int53 message_sender_id:MessageSender = Ok //@description Sends a message. Returns the sent message //@chat_id Target chat //@message_thread_id If not 0, a message thread identifier in which the message will be sent -//@reply_to_message_id Identifier of the message to reply to or 0 +//@reply_to_message_id Identifier of the replied message; 0 if none //@options Options to be used to send the message; pass null to use default options //@reply_markup Markup for replying to the message; pass null if none; for bots only //@input_message_content The content of the message to be sent @@ -5734,7 +5834,7 @@ sendMessage#393f599d chat_id:int53 message_thread_id:int53 reply_to_message_id:i //@description Sends 2-10 messages grouped together into an album. Currently, only audio, document, photo and video messages can be grouped into an album. Documents and audio files can be only grouped in an album with messages of the same type. Returns sent messages //@chat_id Target chat //@message_thread_id If not 0, a message thread identifier in which the messages will be sent -//@reply_to_message_id Identifier of a message to reply to or 0 +//@reply_to_message_id Identifier of a replied message; 0 if none //@options Options to be used to send the messages; pass null to use default options //@input_message_contents Contents of messages to be sent. At most 10 messages can be added to an album //@only_preview Pass true to get fake messages instead of actually sending them @@ -5749,7 +5849,7 @@ sendBotStartMessage#aa6a3eee bot_user_id:int53 chat_id:int53 parameter:string = //@description Sends the result of an inline query as a message. Returns the sent message. Always clears a chat draft message //@chat_id Target chat //@message_thread_id If not 0, a message thread identifier in which the message will be sent -//@reply_to_message_id Identifier of a message to reply to or 0 +//@reply_to_message_id Identifier of a replied message; 0 if none //@options Options to be used to send the message; pass null to use default options //@query_id Identifier of the inline query //@result_id Identifier of the inline result @@ -5778,7 +5878,7 @@ sendChatScreenshotTakenNotification#1aba0861 chat_id:int53 = Ok; //@description Adds a local message to a chat. The message is persistent across application restarts only if the message database is used. Returns the added message //@chat_id Target chat //@sender_id Identifier of the sender of the message -//@reply_to_message_id Identifier of the message to reply to or 0 +//@reply_to_message_id Identifier of the replied message; 0 if none //@disable_notification Pass true to disable notification for the message //@input_message_content The content of the message to be added addLocalMessage#88db87fb chat_id:int53 sender_id:MessageSender reply_to_message_id:int53 disable_notification:Bool input_message_content:InputMessageContent = Message; @@ -5938,6 +6038,10 @@ getJsonValue#92fa5a05 json:string = JsonValue; //@json_value The JsonValue object getJsonString#278b9421 json_value:JsonValue = Text; +//@description Converts a themeParameters object to corresponding JSON-serialized string. Can be called synchronously +//@theme Theme parameters to convert to JSON +getThemeParametersJsonString#91b905f8 theme:themeParameters = Text; + //@description Changes the user answer to a poll. A poll in quiz mode can be answered only once //@chat_id Identifier of the chat to which the poll belongs //@message_id Identifier of the message containing the poll @@ -5993,6 +6097,35 @@ getInlineQueryResults#79dcf86c bot_user_id:int53 chat_id:int53 user_location:loc //@switch_pm_parameter The parameter for the bot start message answerInlineQuery#18ec5846 inline_query_id:int64 is_personal:Bool results:vector cache_time:int32 next_offset:string switch_pm_text:string switch_pm_parameter:string = Ok; +//@description Returns an HTTPS URL of a web app to open after keyboardButtonTypeWebApp button is pressed +//@bot_user_id Identifier of the target bot +//@url The URL from the keyboardButtonTypeWebApp button +//@theme Preferred web app theme; pass null to use the default theme +getWebAppUrl#5f689ab3 bot_user_id:int53 url:string theme:themeParameters = HttpUrl; + +//@description Sends data received from a keyboardButtonTypeWebApp web app to a bot +//@bot_user_id Identifier of the target bot +//@button_text Text of the keyboardButtonTypeWebApp button, which opened the web app +//@data Received data +sendWebAppData#ab1fce0c bot_user_id:int53 button_text:string data:string = Ok; + +//@description Informs TDLib that a web app is being opened from attachment menu, a botMenuButton button, an internalLinkTypeAttachmentMenuBot link, or an inlineKeyboardButtonTypeWebApp button. +//@chat_id Identifier of the chat in which the web app is opened. Web apps can be opened only in private chats for now +//@bot_user_id Identifier of the bot, providing the web app +//@url The URL from an inlineKeyboardButtonTypeWebApp button, a botMenuButton button, or an internalLinkTypeAttachmentMenuBot link, or an empty string otherwise +//@theme Preferred web app theme; pass null to use the default theme +//@reply_to_message_id Identifier of the replied message for the message sent by the web app; 0 if none +openWebApp#914ac418 chat_id:int53 bot_user_id:int53 url:string theme:themeParameters reply_to_message_id:int53 = WebAppInfo; + +//@description Informs TDLib that a previously opened web app was closed +//@web_app_launch_id Identifier of web app launch, received from openWebApp +closeWebApp#68a124c6 web_app_launch_id:int64 = Ok; + +//@description Sets the result of interaction with a web app and sends corresponding message on behalf of the user to the chat from which the query originated; for bots only +//@web_app_query_id Identifier of the web app query +//@result The result of the query +answerWebAppQuery#a0b49cf1 web_app_query_id:string result:InputInlineQueryResult = SentWebAppMessage; + //@description Sends a callback query to a bot and returns an answer. Returns an error with code 502 if the bot fails to answer the query before the query timeout expires //@chat_id Identifier of the chat with the message //@message_id Identifier of the message from which the query originated @@ -6192,7 +6325,7 @@ setChatPhoto#e97b8d03 chat_id:int53 photo:InputChatPhoto = Ok; //@description Changes the message TTL in a chat. Requires can_delete_messages administrator right in basic groups, supergroups and channels //@chat_id Chat identifier -//@ttl New TTL value, in seconds; must be one of 0, 86400, 7 * 86400, or 31 * 86400 unless the chat is secret +//@ttl New TTL value, in seconds; unless the chat is secret, it must be from 0 up to 365 * 86400 and be divisible by 86400 setChatMessageTtl#a1eb6e79 chat_id:int53 ttl:int32 = Ok; //@description Changes the chat members permissions. Supported only for basic groups and supergroups. Requires can_restrict_members administrator right @@ -6338,6 +6471,21 @@ getChatAdministrators#5c0eb6bb chat_id:int53 = ChatAdministrators; //@exclude_secret_chats Pass true to keep local message drafts in secret chats clearAllDraftMessages#fd3c74db exclude_secret_chats:Bool = Ok; +//@description Returns saved notification sound by its identifier. Returns a 404 error if there is no saved notification sound with the specified identifier +//@notification_sound_id Identifier of the notification sound +getSavedNotificationSound#1b647917 notification_sound_id:int64 = NotificationSounds; + +//@description Returns list of saved notification sounds. If a sound isn't in the list, then default sound needs to be used +getSavedNotificationSounds#c0346fa8 = NotificationSounds; + +//@description Adds a new notification sound to the list of saved notification sounds. The new notification sound is added to the top of the list. If it is already in the list, it is position isn't changed +//@sound Notification sound file to add +addSavedNotificationSound#3e3984ef sound:InputFile = NotificationSound; + +//@description Removes a notification sound from the list of saved notification sounds +//@notification_sound_id Identifier of the notification sound +removeSavedNotificationSound#e363474e notification_sound_id:int64 = Ok; + //@description Returns list of chats with non-default notification settings //@scope If specified, only chats from the scope will be returned; pass null to return chats from all scopes //@compare_sound Pass true to include in the response chats with only non-default sound @@ -6352,7 +6500,7 @@ getScopeNotificationSettings#c4a8254f scope:NotificationSettingsScope = ScopeNot //@notification_settings The new notification settings for the given scope setScopeNotificationSettings#85cfb63a scope:NotificationSettingsScope notification_settings:scopeNotificationSettings = Ok; -//@description Resets all notification settings to their default values. By default, all chats are unmuted, the sound is set to "default" and message previews are shown +//@description Resets all notification settings to their default values. By default, all chats are unmuted and message previews are shown resetAllNotificationSettings#f5a0a8f9 = Ok; //@description Changes the pinned state of a chat. There can be up to GetOption("pinned_chat_count_max")/GetOption("pinned_archived_chat_count_max") pinned non-secret chats and the same number of secret chats in the main/archive chat list @@ -6366,6 +6514,15 @@ toggleChatIsPinned#a776263e chat_list:ChatList chat_id:int53 is_pinned:Bool = Ok //@chat_ids The new list of pinned chats setPinnedChats#c6c6edf1 chat_list:ChatList chat_ids:vector = Ok; +//@description Returns information about a bot that can be added to attachment menu +//@bot_user_id Bot's user identifier +getAttachmentMenuBot#3da561fb bot_user_id:int53 = AttachmentMenuBot; + +//@description Adds or removes a bot to attachment menu. Bot can be added to attachment menu, only if userTypeBot.can_be_added_to_attachment_menu == true +//@bot_user_id Bot's user identifier +//@is_added Pass true to add the bot to attachment menu; pass false to remove the bot from attachment menu +toggleBotIsAddedToAttachmentMenu#b56763e2 bot_user_id:int53 is_added:Bool = Ok; + //@description Downloads a file from the cloud. Download progress and completion of the download will be notified through updateFile updates //@file_id Identifier of the file to download //@priority Priority of the download (1-32). The higher the priority, the earlier the file will be downloaded. If the priorities of two files are equal, then the last one for which downloadFile/addFileToDownloads was called will be downloaded first @@ -6610,7 +6767,7 @@ getVideoChatAvailableParticipants#c45da305 chat_id:int53 = MessageSenders; setVideoChatDefaultParticipant#f1a672b3 chat_id:int53 default_participant_id:MessageSender = Ok; //@description Creates a video chat (a group call bound to a chat). Available only for basic groups, supergroups and channels; requires can_manage_video_chats rights -//@chat_id Chat identifier, in which the video chat will be created +//@chat_id Identifier of a chat in which the video chat will be created //@title Group call title; if empty, chat title will be used //@start_date Point in time (Unix timestamp) when the group call is supposed to be started by an administrator; 0 to start the video chat immediately. The date must be at least 10 seconds and at most 8 days in the future //@is_rtmp_stream Pass true to create an RTMP stream instead of an ordinary video chat; requires creator privileges @@ -7011,6 +7168,23 @@ deleteCommands#3bc47c2a scope:BotCommandScope language_code:string = Ok; //@language_code A two-letter ISO 639-1 language code or an empty string getCommands#58ba8ff7 scope:BotCommandScope language_code:string = BotCommands; +//@description Sets menu button for the given user or for all users; for bots only +//@user_id Identifier of the user or 0 to set menu button for all users +//@menu_button New menu button +setMenuButton#b44fc141 user_id:int53 menu_button:botMenuButton = Ok; + +//@description Returns menu button set by the bot for the given user; for bots only +//@user_id Identifier of the user or 0 to get the default menu button +getMenuButton#e5eef440 user_id:int53 = BotMenuButton; + +//@description Sets default administrator rights for adding the bot to basic group and supergroup chats; for bots only +//@default_group_administrator_rights Default administrator rights for adding the bot to basic group and supergroup chats; may be null +setDefaultGroupAdministratorRights#65577768 default_group_administrator_rights:chatAdministratorRights = Ok; + +//@description Sets default administrator rights for adding the bot to channel chats; for bots only +//@default_channel_administrator_rights Default administrator rights for adding the bot to channels; may be null +setDefaultChannelAdministratorRights#f20d5e19 default_channel_administrator_rights:chatAdministratorRights = Ok; + //@description Returns all active sessions of the current user getActiveSessions#42bd6d3e = Sessions; @@ -7098,7 +7272,7 @@ getChatEventLog#f47b0a9b chat_id:int53 query:string from_event_id:int64 limit:in //@chat_id Chat identifier of the Invoice message //@message_id Message identifier //@theme Preferred payment form theme; pass null to use the default theme -getPaymentForm#96e6319 chat_id:int53 message_id:int53 theme:paymentFormTheme = PaymentForm; +getPaymentForm#90411057 chat_id:int53 message_id:int53 theme:themeParameters = PaymentForm; //@description Validates the order information provided by a user and returns the available shipping options for a flexible invoice //@chat_id Chat identifier of the Invoice message @@ -7461,7 +7635,7 @@ removeStickerFromSet#61e1eea4 sticker:InputFile = Ok; //@width Map width in pixels before applying scale; 16-1024 //@height Map height in pixels before applying scale; 16-1024 //@scale Map scale; 1-3 -//@chat_id Identifier of a chat, in which the thumbnail will be shown. Use 0 if unknown +//@chat_id Identifier of a chat in which the thumbnail will be shown. Use 0 if unknown getMapThumbnailFile#f6e6979a location:location zoom:int32 width:int32 height:int32 scale:int32 chat_id:int53 = File; //@description Accepts Telegram terms of services @@ -7619,7 +7793,7 @@ testNetwork#afe4344b = Ok; //@server Proxy server IP address //@port Proxy server port //@type Proxy type -//@dc_id Identifier of a datacenter, with which to test connection +//@dc_id Identifier of a datacenter with which to test connection //@timeout The maximum overall timeout for the request testProxy#b8a1a29e server:string port:int32 type:ProxyType dc_id:int32 timeout:double = Ok; diff --git a/tdapi/tl_add_local_message_gen.go b/tdapi/tl_add_local_message_gen.go index 79493c2c4f..4fb73f1818 100644 --- a/tdapi/tl_add_local_message_gen.go +++ b/tdapi/tl_add_local_message_gen.go @@ -37,7 +37,7 @@ type AddLocalMessageRequest struct { ChatID int64 // Identifier of the sender of the message SenderID MessageSenderClass - // Identifier of the message to reply to or 0 + // Identifier of the replied message; 0 if none ReplyToMessageID int64 // Pass true to disable notification for the message DisableNotification bool diff --git a/tdapi/tl_add_saved_notification_sound_gen.go b/tdapi/tl_add_saved_notification_sound_gen.go new file mode 100644 index 0000000000..7584082d35 --- /dev/null +++ b/tdapi/tl_add_saved_notification_sound_gen.go @@ -0,0 +1,216 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// AddSavedNotificationSoundRequest represents TL type `addSavedNotificationSound#3e3984ef`. +type AddSavedNotificationSoundRequest struct { + // Notification sound file to add + Sound InputFileClass +} + +// AddSavedNotificationSoundRequestTypeID is TL type id of AddSavedNotificationSoundRequest. +const AddSavedNotificationSoundRequestTypeID = 0x3e3984ef + +// Ensuring interfaces in compile-time for AddSavedNotificationSoundRequest. +var ( + _ bin.Encoder = &AddSavedNotificationSoundRequest{} + _ bin.Decoder = &AddSavedNotificationSoundRequest{} + _ bin.BareEncoder = &AddSavedNotificationSoundRequest{} + _ bin.BareDecoder = &AddSavedNotificationSoundRequest{} +) + +func (a *AddSavedNotificationSoundRequest) Zero() bool { + if a == nil { + return true + } + if !(a.Sound == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (a *AddSavedNotificationSoundRequest) String() string { + if a == nil { + return "AddSavedNotificationSoundRequest(nil)" + } + type Alias AddSavedNotificationSoundRequest + return fmt.Sprintf("AddSavedNotificationSoundRequest%+v", Alias(*a)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AddSavedNotificationSoundRequest) TypeID() uint32 { + return AddSavedNotificationSoundRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*AddSavedNotificationSoundRequest) TypeName() string { + return "addSavedNotificationSound" +} + +// TypeInfo returns info about TL type. +func (a *AddSavedNotificationSoundRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "addSavedNotificationSound", + ID: AddSavedNotificationSoundRequestTypeID, + } + if a == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Sound", + SchemaName: "sound", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (a *AddSavedNotificationSoundRequest) Encode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode addSavedNotificationSound#3e3984ef as nil") + } + b.PutID(AddSavedNotificationSoundRequestTypeID) + return a.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (a *AddSavedNotificationSoundRequest) EncodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode addSavedNotificationSound#3e3984ef as nil") + } + if a.Sound == nil { + return fmt.Errorf("unable to encode addSavedNotificationSound#3e3984ef: field sound is nil") + } + if err := a.Sound.Encode(b); err != nil { + return fmt.Errorf("unable to encode addSavedNotificationSound#3e3984ef: field sound: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (a *AddSavedNotificationSoundRequest) Decode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode addSavedNotificationSound#3e3984ef to nil") + } + if err := b.ConsumeID(AddSavedNotificationSoundRequestTypeID); err != nil { + return fmt.Errorf("unable to decode addSavedNotificationSound#3e3984ef: %w", err) + } + return a.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (a *AddSavedNotificationSoundRequest) DecodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode addSavedNotificationSound#3e3984ef to nil") + } + { + value, err := DecodeInputFile(b) + if err != nil { + return fmt.Errorf("unable to decode addSavedNotificationSound#3e3984ef: field sound: %w", err) + } + a.Sound = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (a *AddSavedNotificationSoundRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if a == nil { + return fmt.Errorf("can't encode addSavedNotificationSound#3e3984ef as nil") + } + b.ObjStart() + b.PutID("addSavedNotificationSound") + b.Comma() + b.FieldStart("sound") + if a.Sound == nil { + return fmt.Errorf("unable to encode addSavedNotificationSound#3e3984ef: field sound is nil") + } + if err := a.Sound.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode addSavedNotificationSound#3e3984ef: field sound: %w", err) + } + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (a *AddSavedNotificationSoundRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if a == nil { + return fmt.Errorf("can't decode addSavedNotificationSound#3e3984ef to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("addSavedNotificationSound"); err != nil { + return fmt.Errorf("unable to decode addSavedNotificationSound#3e3984ef: %w", err) + } + case "sound": + value, err := DecodeTDLibJSONInputFile(b) + if err != nil { + return fmt.Errorf("unable to decode addSavedNotificationSound#3e3984ef: field sound: %w", err) + } + a.Sound = value + default: + return b.Skip() + } + return nil + }) +} + +// GetSound returns value of Sound field. +func (a *AddSavedNotificationSoundRequest) GetSound() (value InputFileClass) { + if a == nil { + return + } + return a.Sound +} + +// AddSavedNotificationSound invokes method addSavedNotificationSound#3e3984ef returning error if any. +func (c *Client) AddSavedNotificationSound(ctx context.Context, sound InputFileClass) (*NotificationSound, error) { + var result NotificationSound + + request := &AddSavedNotificationSoundRequest{ + Sound: sound, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tdapi/tl_answer_web_app_query_gen.go b/tdapi/tl_answer_web_app_query_gen.go new file mode 100644 index 0000000000..934cdf80fc --- /dev/null +++ b/tdapi/tl_answer_web_app_query_gen.go @@ -0,0 +1,247 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// AnswerWebAppQueryRequest represents TL type `answerWebAppQuery#a0b49cf1`. +type AnswerWebAppQueryRequest struct { + // Identifier of the web app query + WebAppQueryID string + // The result of the query + Result InputInlineQueryResultClass +} + +// AnswerWebAppQueryRequestTypeID is TL type id of AnswerWebAppQueryRequest. +const AnswerWebAppQueryRequestTypeID = 0xa0b49cf1 + +// Ensuring interfaces in compile-time for AnswerWebAppQueryRequest. +var ( + _ bin.Encoder = &AnswerWebAppQueryRequest{} + _ bin.Decoder = &AnswerWebAppQueryRequest{} + _ bin.BareEncoder = &AnswerWebAppQueryRequest{} + _ bin.BareDecoder = &AnswerWebAppQueryRequest{} +) + +func (a *AnswerWebAppQueryRequest) Zero() bool { + if a == nil { + return true + } + if !(a.WebAppQueryID == "") { + return false + } + if !(a.Result == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (a *AnswerWebAppQueryRequest) String() string { + if a == nil { + return "AnswerWebAppQueryRequest(nil)" + } + type Alias AnswerWebAppQueryRequest + return fmt.Sprintf("AnswerWebAppQueryRequest%+v", Alias(*a)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AnswerWebAppQueryRequest) TypeID() uint32 { + return AnswerWebAppQueryRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*AnswerWebAppQueryRequest) TypeName() string { + return "answerWebAppQuery" +} + +// TypeInfo returns info about TL type. +func (a *AnswerWebAppQueryRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "answerWebAppQuery", + ID: AnswerWebAppQueryRequestTypeID, + } + if a == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "WebAppQueryID", + SchemaName: "web_app_query_id", + }, + { + Name: "Result", + SchemaName: "result", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (a *AnswerWebAppQueryRequest) Encode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode answerWebAppQuery#a0b49cf1 as nil") + } + b.PutID(AnswerWebAppQueryRequestTypeID) + return a.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (a *AnswerWebAppQueryRequest) EncodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode answerWebAppQuery#a0b49cf1 as nil") + } + b.PutString(a.WebAppQueryID) + if a.Result == nil { + return fmt.Errorf("unable to encode answerWebAppQuery#a0b49cf1: field result is nil") + } + if err := a.Result.Encode(b); err != nil { + return fmt.Errorf("unable to encode answerWebAppQuery#a0b49cf1: field result: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (a *AnswerWebAppQueryRequest) Decode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode answerWebAppQuery#a0b49cf1 to nil") + } + if err := b.ConsumeID(AnswerWebAppQueryRequestTypeID); err != nil { + return fmt.Errorf("unable to decode answerWebAppQuery#a0b49cf1: %w", err) + } + return a.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (a *AnswerWebAppQueryRequest) DecodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode answerWebAppQuery#a0b49cf1 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode answerWebAppQuery#a0b49cf1: field web_app_query_id: %w", err) + } + a.WebAppQueryID = value + } + { + value, err := DecodeInputInlineQueryResult(b) + if err != nil { + return fmt.Errorf("unable to decode answerWebAppQuery#a0b49cf1: field result: %w", err) + } + a.Result = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (a *AnswerWebAppQueryRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if a == nil { + return fmt.Errorf("can't encode answerWebAppQuery#a0b49cf1 as nil") + } + b.ObjStart() + b.PutID("answerWebAppQuery") + b.Comma() + b.FieldStart("web_app_query_id") + b.PutString(a.WebAppQueryID) + b.Comma() + b.FieldStart("result") + if a.Result == nil { + return fmt.Errorf("unable to encode answerWebAppQuery#a0b49cf1: field result is nil") + } + if err := a.Result.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode answerWebAppQuery#a0b49cf1: field result: %w", err) + } + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (a *AnswerWebAppQueryRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if a == nil { + return fmt.Errorf("can't decode answerWebAppQuery#a0b49cf1 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("answerWebAppQuery"); err != nil { + return fmt.Errorf("unable to decode answerWebAppQuery#a0b49cf1: %w", err) + } + case "web_app_query_id": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode answerWebAppQuery#a0b49cf1: field web_app_query_id: %w", err) + } + a.WebAppQueryID = value + case "result": + value, err := DecodeTDLibJSONInputInlineQueryResult(b) + if err != nil { + return fmt.Errorf("unable to decode answerWebAppQuery#a0b49cf1: field result: %w", err) + } + a.Result = value + default: + return b.Skip() + } + return nil + }) +} + +// GetWebAppQueryID returns value of WebAppQueryID field. +func (a *AnswerWebAppQueryRequest) GetWebAppQueryID() (value string) { + if a == nil { + return + } + return a.WebAppQueryID +} + +// GetResult returns value of Result field. +func (a *AnswerWebAppQueryRequest) GetResult() (value InputInlineQueryResultClass) { + if a == nil { + return + } + return a.Result +} + +// AnswerWebAppQuery invokes method answerWebAppQuery#a0b49cf1 returning error if any. +func (c *Client) AnswerWebAppQuery(ctx context.Context, request *AnswerWebAppQueryRequest) (*SentWebAppMessage, error) { + var result SentWebAppMessage + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tdapi/tl_attachment_menu_bot_color_gen.go b/tdapi/tl_attachment_menu_bot_color_gen.go new file mode 100644 index 0000000000..c070c34d3a --- /dev/null +++ b/tdapi/tl_attachment_menu_bot_color_gen.go @@ -0,0 +1,227 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// AttachmentMenuBotColor represents TL type `attachmentMenuBotColor#64235ebc`. +type AttachmentMenuBotColor struct { + // Color in the RGB24 format for light themes + LightColor int32 + // Color in the RGB24 format for dark themes + DarkColor int32 +} + +// AttachmentMenuBotColorTypeID is TL type id of AttachmentMenuBotColor. +const AttachmentMenuBotColorTypeID = 0x64235ebc + +// Ensuring interfaces in compile-time for AttachmentMenuBotColor. +var ( + _ bin.Encoder = &AttachmentMenuBotColor{} + _ bin.Decoder = &AttachmentMenuBotColor{} + _ bin.BareEncoder = &AttachmentMenuBotColor{} + _ bin.BareDecoder = &AttachmentMenuBotColor{} +) + +func (a *AttachmentMenuBotColor) Zero() bool { + if a == nil { + return true + } + if !(a.LightColor == 0) { + return false + } + if !(a.DarkColor == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (a *AttachmentMenuBotColor) String() string { + if a == nil { + return "AttachmentMenuBotColor(nil)" + } + type Alias AttachmentMenuBotColor + return fmt.Sprintf("AttachmentMenuBotColor%+v", Alias(*a)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AttachmentMenuBotColor) TypeID() uint32 { + return AttachmentMenuBotColorTypeID +} + +// TypeName returns name of type in TL schema. +func (*AttachmentMenuBotColor) TypeName() string { + return "attachmentMenuBotColor" +} + +// TypeInfo returns info about TL type. +func (a *AttachmentMenuBotColor) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "attachmentMenuBotColor", + ID: AttachmentMenuBotColorTypeID, + } + if a == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "LightColor", + SchemaName: "light_color", + }, + { + Name: "DarkColor", + SchemaName: "dark_color", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (a *AttachmentMenuBotColor) Encode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode attachmentMenuBotColor#64235ebc as nil") + } + b.PutID(AttachmentMenuBotColorTypeID) + return a.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (a *AttachmentMenuBotColor) EncodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode attachmentMenuBotColor#64235ebc as nil") + } + b.PutInt32(a.LightColor) + b.PutInt32(a.DarkColor) + return nil +} + +// Decode implements bin.Decoder. +func (a *AttachmentMenuBotColor) Decode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode attachmentMenuBotColor#64235ebc to nil") + } + if err := b.ConsumeID(AttachmentMenuBotColorTypeID); err != nil { + return fmt.Errorf("unable to decode attachmentMenuBotColor#64235ebc: %w", err) + } + return a.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (a *AttachmentMenuBotColor) DecodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode attachmentMenuBotColor#64235ebc to nil") + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode attachmentMenuBotColor#64235ebc: field light_color: %w", err) + } + a.LightColor = value + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode attachmentMenuBotColor#64235ebc: field dark_color: %w", err) + } + a.DarkColor = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (a *AttachmentMenuBotColor) EncodeTDLibJSON(b tdjson.Encoder) error { + if a == nil { + return fmt.Errorf("can't encode attachmentMenuBotColor#64235ebc as nil") + } + b.ObjStart() + b.PutID("attachmentMenuBotColor") + b.Comma() + b.FieldStart("light_color") + b.PutInt32(a.LightColor) + b.Comma() + b.FieldStart("dark_color") + b.PutInt32(a.DarkColor) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (a *AttachmentMenuBotColor) DecodeTDLibJSON(b tdjson.Decoder) error { + if a == nil { + return fmt.Errorf("can't decode attachmentMenuBotColor#64235ebc to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("attachmentMenuBotColor"); err != nil { + return fmt.Errorf("unable to decode attachmentMenuBotColor#64235ebc: %w", err) + } + case "light_color": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode attachmentMenuBotColor#64235ebc: field light_color: %w", err) + } + a.LightColor = value + case "dark_color": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode attachmentMenuBotColor#64235ebc: field dark_color: %w", err) + } + a.DarkColor = value + default: + return b.Skip() + } + return nil + }) +} + +// GetLightColor returns value of LightColor field. +func (a *AttachmentMenuBotColor) GetLightColor() (value int32) { + if a == nil { + return + } + return a.LightColor +} + +// GetDarkColor returns value of DarkColor field. +func (a *AttachmentMenuBotColor) GetDarkColor() (value int32) { + if a == nil { + return + } + return a.DarkColor +} diff --git a/tdapi/tl_attachment_menu_bot_gen.go b/tdapi/tl_attachment_menu_bot_gen.go new file mode 100644 index 0000000000..35af87a8ed --- /dev/null +++ b/tdapi/tl_attachment_menu_bot_gen.go @@ -0,0 +1,467 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// AttachmentMenuBot represents TL type `attachmentMenuBot#5e82be30`. +type AttachmentMenuBot struct { + // User identifier of the bot added to attachment menu + BotUserID int64 + // Name for the bot in attachment menu + Name string + // Color to highlight selected name of the bot if appropriate; may be null + NameColor AttachmentMenuBotColor + // Default attachment menu icon for the bot in SVG format; may be null + DefaultIcon File + // Attachment menu icon for the bot in SVG format for the official iOS app; may be null + IosStaticIcon File + // Attachment menu icon for the bot in TGS format for the official iOS app; may be null + IosAnimatedIcon File + // Attachment menu icon for the bot in TGS format for the official Android app; may be + // null + AndroidIcon File + // Attachment menu icon for the bot in TGS format for the official native macOS app; may + // be null + MacosIcon File + // Color to highlight selected icon of the bot if appropriate; may be null + IconColor AttachmentMenuBotColor +} + +// AttachmentMenuBotTypeID is TL type id of AttachmentMenuBot. +const AttachmentMenuBotTypeID = 0x5e82be30 + +// Ensuring interfaces in compile-time for AttachmentMenuBot. +var ( + _ bin.Encoder = &AttachmentMenuBot{} + _ bin.Decoder = &AttachmentMenuBot{} + _ bin.BareEncoder = &AttachmentMenuBot{} + _ bin.BareDecoder = &AttachmentMenuBot{} +) + +func (a *AttachmentMenuBot) Zero() bool { + if a == nil { + return true + } + if !(a.BotUserID == 0) { + return false + } + if !(a.Name == "") { + return false + } + if !(a.NameColor.Zero()) { + return false + } + if !(a.DefaultIcon.Zero()) { + return false + } + if !(a.IosStaticIcon.Zero()) { + return false + } + if !(a.IosAnimatedIcon.Zero()) { + return false + } + if !(a.AndroidIcon.Zero()) { + return false + } + if !(a.MacosIcon.Zero()) { + return false + } + if !(a.IconColor.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (a *AttachmentMenuBot) String() string { + if a == nil { + return "AttachmentMenuBot(nil)" + } + type Alias AttachmentMenuBot + return fmt.Sprintf("AttachmentMenuBot%+v", Alias(*a)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AttachmentMenuBot) TypeID() uint32 { + return AttachmentMenuBotTypeID +} + +// TypeName returns name of type in TL schema. +func (*AttachmentMenuBot) TypeName() string { + return "attachmentMenuBot" +} + +// TypeInfo returns info about TL type. +func (a *AttachmentMenuBot) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "attachmentMenuBot", + ID: AttachmentMenuBotTypeID, + } + if a == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "BotUserID", + SchemaName: "bot_user_id", + }, + { + Name: "Name", + SchemaName: "name", + }, + { + Name: "NameColor", + SchemaName: "name_color", + }, + { + Name: "DefaultIcon", + SchemaName: "default_icon", + }, + { + Name: "IosStaticIcon", + SchemaName: "ios_static_icon", + }, + { + Name: "IosAnimatedIcon", + SchemaName: "ios_animated_icon", + }, + { + Name: "AndroidIcon", + SchemaName: "android_icon", + }, + { + Name: "MacosIcon", + SchemaName: "macos_icon", + }, + { + Name: "IconColor", + SchemaName: "icon_color", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (a *AttachmentMenuBot) Encode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode attachmentMenuBot#5e82be30 as nil") + } + b.PutID(AttachmentMenuBotTypeID) + return a.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (a *AttachmentMenuBot) EncodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode attachmentMenuBot#5e82be30 as nil") + } + b.PutInt53(a.BotUserID) + b.PutString(a.Name) + if err := a.NameColor.Encode(b); err != nil { + return fmt.Errorf("unable to encode attachmentMenuBot#5e82be30: field name_color: %w", err) + } + if err := a.DefaultIcon.Encode(b); err != nil { + return fmt.Errorf("unable to encode attachmentMenuBot#5e82be30: field default_icon: %w", err) + } + if err := a.IosStaticIcon.Encode(b); err != nil { + return fmt.Errorf("unable to encode attachmentMenuBot#5e82be30: field ios_static_icon: %w", err) + } + if err := a.IosAnimatedIcon.Encode(b); err != nil { + return fmt.Errorf("unable to encode attachmentMenuBot#5e82be30: field ios_animated_icon: %w", err) + } + if err := a.AndroidIcon.Encode(b); err != nil { + return fmt.Errorf("unable to encode attachmentMenuBot#5e82be30: field android_icon: %w", err) + } + if err := a.MacosIcon.Encode(b); err != nil { + return fmt.Errorf("unable to encode attachmentMenuBot#5e82be30: field macos_icon: %w", err) + } + if err := a.IconColor.Encode(b); err != nil { + return fmt.Errorf("unable to encode attachmentMenuBot#5e82be30: field icon_color: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (a *AttachmentMenuBot) Decode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode attachmentMenuBot#5e82be30 to nil") + } + if err := b.ConsumeID(AttachmentMenuBotTypeID); err != nil { + return fmt.Errorf("unable to decode attachmentMenuBot#5e82be30: %w", err) + } + return a.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (a *AttachmentMenuBot) DecodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode attachmentMenuBot#5e82be30 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode attachmentMenuBot#5e82be30: field bot_user_id: %w", err) + } + a.BotUserID = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode attachmentMenuBot#5e82be30: field name: %w", err) + } + a.Name = value + } + { + if err := a.NameColor.Decode(b); err != nil { + return fmt.Errorf("unable to decode attachmentMenuBot#5e82be30: field name_color: %w", err) + } + } + { + if err := a.DefaultIcon.Decode(b); err != nil { + return fmt.Errorf("unable to decode attachmentMenuBot#5e82be30: field default_icon: %w", err) + } + } + { + if err := a.IosStaticIcon.Decode(b); err != nil { + return fmt.Errorf("unable to decode attachmentMenuBot#5e82be30: field ios_static_icon: %w", err) + } + } + { + if err := a.IosAnimatedIcon.Decode(b); err != nil { + return fmt.Errorf("unable to decode attachmentMenuBot#5e82be30: field ios_animated_icon: %w", err) + } + } + { + if err := a.AndroidIcon.Decode(b); err != nil { + return fmt.Errorf("unable to decode attachmentMenuBot#5e82be30: field android_icon: %w", err) + } + } + { + if err := a.MacosIcon.Decode(b); err != nil { + return fmt.Errorf("unable to decode attachmentMenuBot#5e82be30: field macos_icon: %w", err) + } + } + { + if err := a.IconColor.Decode(b); err != nil { + return fmt.Errorf("unable to decode attachmentMenuBot#5e82be30: field icon_color: %w", err) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (a *AttachmentMenuBot) EncodeTDLibJSON(b tdjson.Encoder) error { + if a == nil { + return fmt.Errorf("can't encode attachmentMenuBot#5e82be30 as nil") + } + b.ObjStart() + b.PutID("attachmentMenuBot") + b.Comma() + b.FieldStart("bot_user_id") + b.PutInt53(a.BotUserID) + b.Comma() + b.FieldStart("name") + b.PutString(a.Name) + b.Comma() + b.FieldStart("name_color") + if err := a.NameColor.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode attachmentMenuBot#5e82be30: field name_color: %w", err) + } + b.Comma() + b.FieldStart("default_icon") + if err := a.DefaultIcon.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode attachmentMenuBot#5e82be30: field default_icon: %w", err) + } + b.Comma() + b.FieldStart("ios_static_icon") + if err := a.IosStaticIcon.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode attachmentMenuBot#5e82be30: field ios_static_icon: %w", err) + } + b.Comma() + b.FieldStart("ios_animated_icon") + if err := a.IosAnimatedIcon.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode attachmentMenuBot#5e82be30: field ios_animated_icon: %w", err) + } + b.Comma() + b.FieldStart("android_icon") + if err := a.AndroidIcon.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode attachmentMenuBot#5e82be30: field android_icon: %w", err) + } + b.Comma() + b.FieldStart("macos_icon") + if err := a.MacosIcon.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode attachmentMenuBot#5e82be30: field macos_icon: %w", err) + } + b.Comma() + b.FieldStart("icon_color") + if err := a.IconColor.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode attachmentMenuBot#5e82be30: field icon_color: %w", err) + } + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (a *AttachmentMenuBot) DecodeTDLibJSON(b tdjson.Decoder) error { + if a == nil { + return fmt.Errorf("can't decode attachmentMenuBot#5e82be30 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("attachmentMenuBot"); err != nil { + return fmt.Errorf("unable to decode attachmentMenuBot#5e82be30: %w", err) + } + case "bot_user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode attachmentMenuBot#5e82be30: field bot_user_id: %w", err) + } + a.BotUserID = value + case "name": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode attachmentMenuBot#5e82be30: field name: %w", err) + } + a.Name = value + case "name_color": + if err := a.NameColor.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode attachmentMenuBot#5e82be30: field name_color: %w", err) + } + case "default_icon": + if err := a.DefaultIcon.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode attachmentMenuBot#5e82be30: field default_icon: %w", err) + } + case "ios_static_icon": + if err := a.IosStaticIcon.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode attachmentMenuBot#5e82be30: field ios_static_icon: %w", err) + } + case "ios_animated_icon": + if err := a.IosAnimatedIcon.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode attachmentMenuBot#5e82be30: field ios_animated_icon: %w", err) + } + case "android_icon": + if err := a.AndroidIcon.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode attachmentMenuBot#5e82be30: field android_icon: %w", err) + } + case "macos_icon": + if err := a.MacosIcon.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode attachmentMenuBot#5e82be30: field macos_icon: %w", err) + } + case "icon_color": + if err := a.IconColor.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode attachmentMenuBot#5e82be30: field icon_color: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetBotUserID returns value of BotUserID field. +func (a *AttachmentMenuBot) GetBotUserID() (value int64) { + if a == nil { + return + } + return a.BotUserID +} + +// GetName returns value of Name field. +func (a *AttachmentMenuBot) GetName() (value string) { + if a == nil { + return + } + return a.Name +} + +// GetNameColor returns value of NameColor field. +func (a *AttachmentMenuBot) GetNameColor() (value AttachmentMenuBotColor) { + if a == nil { + return + } + return a.NameColor +} + +// GetDefaultIcon returns value of DefaultIcon field. +func (a *AttachmentMenuBot) GetDefaultIcon() (value File) { + if a == nil { + return + } + return a.DefaultIcon +} + +// GetIosStaticIcon returns value of IosStaticIcon field. +func (a *AttachmentMenuBot) GetIosStaticIcon() (value File) { + if a == nil { + return + } + return a.IosStaticIcon +} + +// GetIosAnimatedIcon returns value of IosAnimatedIcon field. +func (a *AttachmentMenuBot) GetIosAnimatedIcon() (value File) { + if a == nil { + return + } + return a.IosAnimatedIcon +} + +// GetAndroidIcon returns value of AndroidIcon field. +func (a *AttachmentMenuBot) GetAndroidIcon() (value File) { + if a == nil { + return + } + return a.AndroidIcon +} + +// GetMacosIcon returns value of MacosIcon field. +func (a *AttachmentMenuBot) GetMacosIcon() (value File) { + if a == nil { + return + } + return a.MacosIcon +} + +// GetIconColor returns value of IconColor field. +func (a *AttachmentMenuBot) GetIconColor() (value AttachmentMenuBotColor) { + if a == nil { + return + } + return a.IconColor +} diff --git a/tdapi/tl_bot_info_gen.go b/tdapi/tl_bot_info_gen.go new file mode 100644 index 0000000000..05a0418ffb --- /dev/null +++ b/tdapi/tl_bot_info_gen.go @@ -0,0 +1,394 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// BotInfo represents TL type `botInfo#729c7b7e`. +type BotInfo struct { + // The text that is shown on the bot's profile page and is sent together with the link + // when users share the bot + ShareText string + // Contains information about a bot + Description string + // Information about a button to show instead of the bot commands menu button; may be + // null if ordinary bot commands menu must be shown + MenuButton BotMenuButton + // List of the bot commands + Commands []BotCommand + // Default administrator rights for adding the bot to basic group and supergroup chats; + // may be null + DefaultGroupAdministratorRights ChatAdministratorRights + // Default administrator rights for adding the bot to channels; may be null + DefaultChannelAdministratorRights ChatAdministratorRights +} + +// BotInfoTypeID is TL type id of BotInfo. +const BotInfoTypeID = 0x729c7b7e + +// Ensuring interfaces in compile-time for BotInfo. +var ( + _ bin.Encoder = &BotInfo{} + _ bin.Decoder = &BotInfo{} + _ bin.BareEncoder = &BotInfo{} + _ bin.BareDecoder = &BotInfo{} +) + +func (b *BotInfo) Zero() bool { + if b == nil { + return true + } + if !(b.ShareText == "") { + return false + } + if !(b.Description == "") { + return false + } + if !(b.MenuButton.Zero()) { + return false + } + if !(b.Commands == nil) { + return false + } + if !(b.DefaultGroupAdministratorRights.Zero()) { + return false + } + if !(b.DefaultChannelAdministratorRights.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (b *BotInfo) String() string { + if b == nil { + return "BotInfo(nil)" + } + type Alias BotInfo + return fmt.Sprintf("BotInfo%+v", Alias(*b)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*BotInfo) TypeID() uint32 { + return BotInfoTypeID +} + +// TypeName returns name of type in TL schema. +func (*BotInfo) TypeName() string { + return "botInfo" +} + +// TypeInfo returns info about TL type. +func (b *BotInfo) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "botInfo", + ID: BotInfoTypeID, + } + if b == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ShareText", + SchemaName: "share_text", + }, + { + Name: "Description", + SchemaName: "description", + }, + { + Name: "MenuButton", + SchemaName: "menu_button", + }, + { + Name: "Commands", + SchemaName: "commands", + }, + { + Name: "DefaultGroupAdministratorRights", + SchemaName: "default_group_administrator_rights", + }, + { + Name: "DefaultChannelAdministratorRights", + SchemaName: "default_channel_administrator_rights", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (b *BotInfo) Encode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode botInfo#729c7b7e as nil") + } + buf.PutID(BotInfoTypeID) + return b.EncodeBare(buf) +} + +// EncodeBare implements bin.BareEncoder. +func (b *BotInfo) EncodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't encode botInfo#729c7b7e as nil") + } + buf.PutString(b.ShareText) + buf.PutString(b.Description) + if err := b.MenuButton.Encode(buf); err != nil { + return fmt.Errorf("unable to encode botInfo#729c7b7e: field menu_button: %w", err) + } + buf.PutInt(len(b.Commands)) + for idx, v := range b.Commands { + if err := v.EncodeBare(buf); err != nil { + return fmt.Errorf("unable to encode bare botInfo#729c7b7e: field commands element with index %d: %w", idx, err) + } + } + if err := b.DefaultGroupAdministratorRights.Encode(buf); err != nil { + return fmt.Errorf("unable to encode botInfo#729c7b7e: field default_group_administrator_rights: %w", err) + } + if err := b.DefaultChannelAdministratorRights.Encode(buf); err != nil { + return fmt.Errorf("unable to encode botInfo#729c7b7e: field default_channel_administrator_rights: %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#729c7b7e to nil") + } + if err := buf.ConsumeID(BotInfoTypeID); err != nil { + return fmt.Errorf("unable to decode botInfo#729c7b7e: %w", err) + } + return b.DecodeBare(buf) +} + +// DecodeBare implements bin.BareDecoder. +func (b *BotInfo) DecodeBare(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("can't decode botInfo#729c7b7e to nil") + } + { + value, err := buf.String() + if err != nil { + return fmt.Errorf("unable to decode botInfo#729c7b7e: field share_text: %w", err) + } + b.ShareText = value + } + { + value, err := buf.String() + if err != nil { + return fmt.Errorf("unable to decode botInfo#729c7b7e: field description: %w", err) + } + b.Description = value + } + { + if err := b.MenuButton.Decode(buf); err != nil { + return fmt.Errorf("unable to decode botInfo#729c7b7e: field menu_button: %w", err) + } + } + { + headerLen, err := buf.Int() + if err != nil { + return fmt.Errorf("unable to decode botInfo#729c7b7e: field commands: %w", err) + } + + if headerLen > 0 { + b.Commands = make([]BotCommand, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value BotCommand + if err := value.DecodeBare(buf); err != nil { + return fmt.Errorf("unable to decode bare botInfo#729c7b7e: field commands: %w", err) + } + b.Commands = append(b.Commands, value) + } + } + { + if err := b.DefaultGroupAdministratorRights.Decode(buf); err != nil { + return fmt.Errorf("unable to decode botInfo#729c7b7e: field default_group_administrator_rights: %w", err) + } + } + { + if err := b.DefaultChannelAdministratorRights.Decode(buf); err != nil { + return fmt.Errorf("unable to decode botInfo#729c7b7e: field default_channel_administrator_rights: %w", err) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (b *BotInfo) EncodeTDLibJSON(buf tdjson.Encoder) error { + if b == nil { + return fmt.Errorf("can't encode botInfo#729c7b7e as nil") + } + buf.ObjStart() + buf.PutID("botInfo") + buf.Comma() + buf.FieldStart("share_text") + buf.PutString(b.ShareText) + buf.Comma() + buf.FieldStart("description") + buf.PutString(b.Description) + buf.Comma() + buf.FieldStart("menu_button") + if err := b.MenuButton.EncodeTDLibJSON(buf); err != nil { + return fmt.Errorf("unable to encode botInfo#729c7b7e: field menu_button: %w", err) + } + buf.Comma() + buf.FieldStart("commands") + buf.ArrStart() + for idx, v := range b.Commands { + if err := v.EncodeTDLibJSON(buf); err != nil { + return fmt.Errorf("unable to encode botInfo#729c7b7e: field commands element with index %d: %w", idx, err) + } + buf.Comma() + } + buf.StripComma() + buf.ArrEnd() + buf.Comma() + buf.FieldStart("default_group_administrator_rights") + if err := b.DefaultGroupAdministratorRights.EncodeTDLibJSON(buf); err != nil { + return fmt.Errorf("unable to encode botInfo#729c7b7e: field default_group_administrator_rights: %w", err) + } + buf.Comma() + buf.FieldStart("default_channel_administrator_rights") + if err := b.DefaultChannelAdministratorRights.EncodeTDLibJSON(buf); err != nil { + return fmt.Errorf("unable to encode botInfo#729c7b7e: field default_channel_administrator_rights: %w", err) + } + buf.Comma() + buf.StripComma() + buf.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (b *BotInfo) DecodeTDLibJSON(buf tdjson.Decoder) error { + if b == nil { + return fmt.Errorf("can't decode botInfo#729c7b7e to nil") + } + + return buf.Obj(func(buf tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := buf.ConsumeID("botInfo"); err != nil { + return fmt.Errorf("unable to decode botInfo#729c7b7e: %w", err) + } + case "share_text": + value, err := buf.String() + if err != nil { + return fmt.Errorf("unable to decode botInfo#729c7b7e: field share_text: %w", err) + } + b.ShareText = value + case "description": + value, err := buf.String() + if err != nil { + return fmt.Errorf("unable to decode botInfo#729c7b7e: field description: %w", err) + } + b.Description = value + case "menu_button": + if err := b.MenuButton.DecodeTDLibJSON(buf); err != nil { + return fmt.Errorf("unable to decode botInfo#729c7b7e: field menu_button: %w", err) + } + case "commands": + if err := buf.Arr(func(buf tdjson.Decoder) error { + var value BotCommand + if err := value.DecodeTDLibJSON(buf); err != nil { + return fmt.Errorf("unable to decode botInfo#729c7b7e: field commands: %w", err) + } + b.Commands = append(b.Commands, value) + return nil + }); err != nil { + return fmt.Errorf("unable to decode botInfo#729c7b7e: field commands: %w", err) + } + case "default_group_administrator_rights": + if err := b.DefaultGroupAdministratorRights.DecodeTDLibJSON(buf); err != nil { + return fmt.Errorf("unable to decode botInfo#729c7b7e: field default_group_administrator_rights: %w", err) + } + case "default_channel_administrator_rights": + if err := b.DefaultChannelAdministratorRights.DecodeTDLibJSON(buf); err != nil { + return fmt.Errorf("unable to decode botInfo#729c7b7e: field default_channel_administrator_rights: %w", err) + } + default: + return buf.Skip() + } + return nil + }) +} + +// GetShareText returns value of ShareText field. +func (b *BotInfo) GetShareText() (value string) { + if b == nil { + return + } + return b.ShareText +} + +// GetDescription returns value of Description field. +func (b *BotInfo) GetDescription() (value string) { + if b == nil { + return + } + return b.Description +} + +// GetMenuButton returns value of MenuButton field. +func (b *BotInfo) GetMenuButton() (value BotMenuButton) { + if b == nil { + return + } + return b.MenuButton +} + +// GetCommands returns value of Commands field. +func (b *BotInfo) GetCommands() (value []BotCommand) { + if b == nil { + return + } + return b.Commands +} + +// GetDefaultGroupAdministratorRights returns value of DefaultGroupAdministratorRights field. +func (b *BotInfo) GetDefaultGroupAdministratorRights() (value ChatAdministratorRights) { + if b == nil { + return + } + return b.DefaultGroupAdministratorRights +} + +// GetDefaultChannelAdministratorRights returns value of DefaultChannelAdministratorRights field. +func (b *BotInfo) GetDefaultChannelAdministratorRights() (value ChatAdministratorRights) { + if b == nil { + return + } + return b.DefaultChannelAdministratorRights +} diff --git a/tdapi/tl_bot_menu_button_gen.go b/tdapi/tl_bot_menu_button_gen.go new file mode 100644 index 0000000000..4c98cfbf68 --- /dev/null +++ b/tdapi/tl_bot_menu_button_gen.go @@ -0,0 +1,227 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// BotMenuButton represents TL type `botMenuButton#c7b57ce6`. +type BotMenuButton struct { + // Text of the button + Text string + // URL to be passed to openWebApp + URL string +} + +// BotMenuButtonTypeID is TL type id of BotMenuButton. +const BotMenuButtonTypeID = 0xc7b57ce6 + +// Ensuring interfaces in compile-time for BotMenuButton. +var ( + _ bin.Encoder = &BotMenuButton{} + _ bin.Decoder = &BotMenuButton{} + _ bin.BareEncoder = &BotMenuButton{} + _ bin.BareDecoder = &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)) +} + +// 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 +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (b *BotMenuButton) EncodeTDLibJSON(buf tdjson.Encoder) error { + if b == nil { + return fmt.Errorf("can't encode botMenuButton#c7b57ce6 as nil") + } + buf.ObjStart() + buf.PutID("botMenuButton") + buf.Comma() + buf.FieldStart("text") + buf.PutString(b.Text) + buf.Comma() + buf.FieldStart("url") + buf.PutString(b.URL) + buf.Comma() + buf.StripComma() + buf.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (b *BotMenuButton) DecodeTDLibJSON(buf tdjson.Decoder) error { + if b == nil { + return fmt.Errorf("can't decode botMenuButton#c7b57ce6 to nil") + } + + return buf.Obj(func(buf tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := buf.ConsumeID("botMenuButton"); err != nil { + return fmt.Errorf("unable to decode botMenuButton#c7b57ce6: %w", err) + } + case "text": + value, err := buf.String() + if err != nil { + return fmt.Errorf("unable to decode botMenuButton#c7b57ce6: field text: %w", err) + } + b.Text = value + case "url": + value, err := buf.String() + if err != nil { + return fmt.Errorf("unable to decode botMenuButton#c7b57ce6: field url: %w", err) + } + b.URL = value + default: + return buf.Skip() + } + 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 +} diff --git a/tdapi/tl_chat_administrator_rights_gen.go b/tdapi/tl_chat_administrator_rights_gen.go new file mode 100644 index 0000000000..c93596ddf1 --- /dev/null +++ b/tdapi/tl_chat_administrator_rights_gen.go @@ -0,0 +1,541 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// ChatAdministratorRights represents TL type `chatAdministratorRights#6ffd893e`. +type ChatAdministratorRights struct { + // True, if the administrator can get chat event log, get chat statistics, get message + // statistics in channels, get channel members, see anonymous administrators in + // supergroups and ignore slow mode. Implied by any other privilege; applicable to + // supergroups and channels only + CanManageChat bool + // True, if the administrator can change the chat title, photo, and other settings + CanChangeInfo bool + // True, if the administrator can create channel posts; applicable to channels only + CanPostMessages bool + // True, if the administrator can edit messages of other users and pin messages; + // applicable to channels only + CanEditMessages bool + // True, if the administrator can delete messages of other users + CanDeleteMessages bool + // True, if the administrator can invite new users to the chat + CanInviteUsers bool + // True, if the administrator can restrict, ban, or unban chat members; always true for + // channels + CanRestrictMembers bool + // True, if the administrator can pin messages; applicable to basic groups and + // supergroups only + CanPinMessages bool + // True, if the administrator can add new administrators with a subset of their own + // privileges or demote administrators that were directly or indirectly promoted by them + CanPromoteMembers bool + // True, if the administrator can manage video chats + CanManageVideoChats bool + // True, if the administrator isn't shown in the chat member list and sends messages + // anonymously; applicable to supergroups only + IsAnonymous bool +} + +// ChatAdministratorRightsTypeID is TL type id of ChatAdministratorRights. +const ChatAdministratorRightsTypeID = 0x6ffd893e + +// Ensuring interfaces in compile-time for ChatAdministratorRights. +var ( + _ bin.Encoder = &ChatAdministratorRights{} + _ bin.Decoder = &ChatAdministratorRights{} + _ bin.BareEncoder = &ChatAdministratorRights{} + _ bin.BareDecoder = &ChatAdministratorRights{} +) + +func (c *ChatAdministratorRights) Zero() bool { + if c == nil { + return true + } + if !(c.CanManageChat == false) { + return false + } + if !(c.CanChangeInfo == false) { + return false + } + if !(c.CanPostMessages == false) { + return false + } + if !(c.CanEditMessages == false) { + return false + } + if !(c.CanDeleteMessages == false) { + return false + } + if !(c.CanInviteUsers == false) { + return false + } + if !(c.CanRestrictMembers == false) { + return false + } + if !(c.CanPinMessages == false) { + return false + } + if !(c.CanPromoteMembers == false) { + return false + } + if !(c.CanManageVideoChats == false) { + return false + } + if !(c.IsAnonymous == false) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (c *ChatAdministratorRights) String() string { + if c == nil { + return "ChatAdministratorRights(nil)" + } + type Alias ChatAdministratorRights + return fmt.Sprintf("ChatAdministratorRights%+v", Alias(*c)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChatAdministratorRights) TypeID() uint32 { + return ChatAdministratorRightsTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChatAdministratorRights) TypeName() string { + return "chatAdministratorRights" +} + +// TypeInfo returns info about TL type. +func (c *ChatAdministratorRights) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "chatAdministratorRights", + ID: ChatAdministratorRightsTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "CanManageChat", + SchemaName: "can_manage_chat", + }, + { + Name: "CanChangeInfo", + SchemaName: "can_change_info", + }, + { + Name: "CanPostMessages", + SchemaName: "can_post_messages", + }, + { + Name: "CanEditMessages", + SchemaName: "can_edit_messages", + }, + { + Name: "CanDeleteMessages", + SchemaName: "can_delete_messages", + }, + { + Name: "CanInviteUsers", + SchemaName: "can_invite_users", + }, + { + Name: "CanRestrictMembers", + SchemaName: "can_restrict_members", + }, + { + Name: "CanPinMessages", + SchemaName: "can_pin_messages", + }, + { + Name: "CanPromoteMembers", + SchemaName: "can_promote_members", + }, + { + Name: "CanManageVideoChats", + SchemaName: "can_manage_video_chats", + }, + { + Name: "IsAnonymous", + SchemaName: "is_anonymous", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (c *ChatAdministratorRights) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode chatAdministratorRights#6ffd893e as nil") + } + b.PutID(ChatAdministratorRightsTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *ChatAdministratorRights) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode chatAdministratorRights#6ffd893e as nil") + } + b.PutBool(c.CanManageChat) + b.PutBool(c.CanChangeInfo) + b.PutBool(c.CanPostMessages) + b.PutBool(c.CanEditMessages) + b.PutBool(c.CanDeleteMessages) + b.PutBool(c.CanInviteUsers) + b.PutBool(c.CanRestrictMembers) + b.PutBool(c.CanPinMessages) + b.PutBool(c.CanPromoteMembers) + b.PutBool(c.CanManageVideoChats) + b.PutBool(c.IsAnonymous) + return nil +} + +// Decode implements bin.Decoder. +func (c *ChatAdministratorRights) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode chatAdministratorRights#6ffd893e to nil") + } + if err := b.ConsumeID(ChatAdministratorRightsTypeID); err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *ChatAdministratorRights) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode chatAdministratorRights#6ffd893e to nil") + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: field can_manage_chat: %w", err) + } + c.CanManageChat = value + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: field can_change_info: %w", err) + } + c.CanChangeInfo = value + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: field can_post_messages: %w", err) + } + c.CanPostMessages = value + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: field can_edit_messages: %w", err) + } + c.CanEditMessages = value + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: field can_delete_messages: %w", err) + } + c.CanDeleteMessages = value + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: field can_invite_users: %w", err) + } + c.CanInviteUsers = value + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: field can_restrict_members: %w", err) + } + c.CanRestrictMembers = value + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: field can_pin_messages: %w", err) + } + c.CanPinMessages = value + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: field can_promote_members: %w", err) + } + c.CanPromoteMembers = value + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: field can_manage_video_chats: %w", err) + } + c.CanManageVideoChats = value + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: field is_anonymous: %w", err) + } + c.IsAnonymous = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (c *ChatAdministratorRights) EncodeTDLibJSON(b tdjson.Encoder) error { + if c == nil { + return fmt.Errorf("can't encode chatAdministratorRights#6ffd893e as nil") + } + b.ObjStart() + b.PutID("chatAdministratorRights") + b.Comma() + b.FieldStart("can_manage_chat") + b.PutBool(c.CanManageChat) + b.Comma() + b.FieldStart("can_change_info") + b.PutBool(c.CanChangeInfo) + b.Comma() + b.FieldStart("can_post_messages") + b.PutBool(c.CanPostMessages) + b.Comma() + b.FieldStart("can_edit_messages") + b.PutBool(c.CanEditMessages) + b.Comma() + b.FieldStart("can_delete_messages") + b.PutBool(c.CanDeleteMessages) + b.Comma() + b.FieldStart("can_invite_users") + b.PutBool(c.CanInviteUsers) + b.Comma() + b.FieldStart("can_restrict_members") + b.PutBool(c.CanRestrictMembers) + b.Comma() + b.FieldStart("can_pin_messages") + b.PutBool(c.CanPinMessages) + b.Comma() + b.FieldStart("can_promote_members") + b.PutBool(c.CanPromoteMembers) + b.Comma() + b.FieldStart("can_manage_video_chats") + b.PutBool(c.CanManageVideoChats) + b.Comma() + b.FieldStart("is_anonymous") + b.PutBool(c.IsAnonymous) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (c *ChatAdministratorRights) DecodeTDLibJSON(b tdjson.Decoder) error { + if c == nil { + return fmt.Errorf("can't decode chatAdministratorRights#6ffd893e to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("chatAdministratorRights"); err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: %w", err) + } + case "can_manage_chat": + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: field can_manage_chat: %w", err) + } + c.CanManageChat = value + case "can_change_info": + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: field can_change_info: %w", err) + } + c.CanChangeInfo = value + case "can_post_messages": + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: field can_post_messages: %w", err) + } + c.CanPostMessages = value + case "can_edit_messages": + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: field can_edit_messages: %w", err) + } + c.CanEditMessages = value + case "can_delete_messages": + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: field can_delete_messages: %w", err) + } + c.CanDeleteMessages = value + case "can_invite_users": + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: field can_invite_users: %w", err) + } + c.CanInviteUsers = value + case "can_restrict_members": + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: field can_restrict_members: %w", err) + } + c.CanRestrictMembers = value + case "can_pin_messages": + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: field can_pin_messages: %w", err) + } + c.CanPinMessages = value + case "can_promote_members": + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: field can_promote_members: %w", err) + } + c.CanPromoteMembers = value + case "can_manage_video_chats": + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: field can_manage_video_chats: %w", err) + } + c.CanManageVideoChats = value + case "is_anonymous": + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAdministratorRights#6ffd893e: field is_anonymous: %w", err) + } + c.IsAnonymous = value + default: + return b.Skip() + } + return nil + }) +} + +// GetCanManageChat returns value of CanManageChat field. +func (c *ChatAdministratorRights) GetCanManageChat() (value bool) { + if c == nil { + return + } + return c.CanManageChat +} + +// GetCanChangeInfo returns value of CanChangeInfo field. +func (c *ChatAdministratorRights) GetCanChangeInfo() (value bool) { + if c == nil { + return + } + return c.CanChangeInfo +} + +// GetCanPostMessages returns value of CanPostMessages field. +func (c *ChatAdministratorRights) GetCanPostMessages() (value bool) { + if c == nil { + return + } + return c.CanPostMessages +} + +// GetCanEditMessages returns value of CanEditMessages field. +func (c *ChatAdministratorRights) GetCanEditMessages() (value bool) { + if c == nil { + return + } + return c.CanEditMessages +} + +// GetCanDeleteMessages returns value of CanDeleteMessages field. +func (c *ChatAdministratorRights) GetCanDeleteMessages() (value bool) { + if c == nil { + return + } + return c.CanDeleteMessages +} + +// GetCanInviteUsers returns value of CanInviteUsers field. +func (c *ChatAdministratorRights) GetCanInviteUsers() (value bool) { + if c == nil { + return + } + return c.CanInviteUsers +} + +// GetCanRestrictMembers returns value of CanRestrictMembers field. +func (c *ChatAdministratorRights) GetCanRestrictMembers() (value bool) { + if c == nil { + return + } + return c.CanRestrictMembers +} + +// GetCanPinMessages returns value of CanPinMessages field. +func (c *ChatAdministratorRights) GetCanPinMessages() (value bool) { + if c == nil { + return + } + return c.CanPinMessages +} + +// GetCanPromoteMembers returns value of CanPromoteMembers field. +func (c *ChatAdministratorRights) GetCanPromoteMembers() (value bool) { + if c == nil { + return + } + return c.CanPromoteMembers +} + +// GetCanManageVideoChats returns value of CanManageVideoChats field. +func (c *ChatAdministratorRights) GetCanManageVideoChats() (value bool) { + if c == nil { + return + } + return c.CanManageVideoChats +} + +// GetIsAnonymous returns value of IsAnonymous field. +func (c *ChatAdministratorRights) GetIsAnonymous() (value bool) { + if c == nil { + return + } + return c.IsAnonymous +} diff --git a/tdapi/tl_chat_member_status_gen.go b/tdapi/tl_chat_member_status_gen.go index de159c00ea..e8808010b0 100644 --- a/tdapi/tl_chat_member_status_gen.go +++ b/tdapi/tl_chat_member_status_gen.go @@ -267,47 +267,19 @@ func (c *ChatMemberStatusCreator) GetIsMember() (value bool) { return c.IsMember } -// ChatMemberStatusAdministrator represents TL type `chatMemberStatusAdministrator#4e6efea`. +// ChatMemberStatusAdministrator represents TL type `chatMemberStatusAdministrator#fbd3841d`. type ChatMemberStatusAdministrator struct { // A custom title of the administrator; 0-16 characters without emojis; applicable to // supergroups only CustomTitle string // True, if the current user can edit the administrator privileges for the called user CanBeEdited bool - // True, if the administrator can get chat event log, get chat statistics, get message - // statistics in channels, get channel members, see anonymous administrators in - // supergroups and ignore slow mode. Implied by any other privilege; applicable to - // supergroups and channels only - CanManageChat bool - // True, if the administrator can change the chat title, photo, and other settings - CanChangeInfo bool - // True, if the administrator can create channel posts; applicable to channels only - CanPostMessages bool - // True, if the administrator can edit messages of other users and pin messages; - // applicable to channels only - CanEditMessages bool - // True, if the administrator can delete messages of other users - CanDeleteMessages bool - // True, if the administrator can invite new users to the chat - CanInviteUsers bool - // True, if the administrator can restrict, ban, or unban chat members; always true for - // channels - CanRestrictMembers bool - // True, if the administrator can pin messages; applicable to basic groups and - // supergroups only - CanPinMessages bool - // True, if the administrator can add new administrators with a subset of their own - // privileges or demote administrators that were directly or indirectly promoted by them - CanPromoteMembers bool - // True, if the administrator can manage video chats - CanManageVideoChats bool - // True, if the administrator isn't shown in the chat member list and sends messages - // anonymously; applicable to supergroups only - IsAnonymous bool + // Rights of the administrator + Rights ChatAdministratorRights } // ChatMemberStatusAdministratorTypeID is TL type id of ChatMemberStatusAdministrator. -const ChatMemberStatusAdministratorTypeID = 0x4e6efea +const ChatMemberStatusAdministratorTypeID = 0xfbd3841d // construct implements constructor of ChatMemberStatusClass. func (c ChatMemberStatusAdministrator) construct() ChatMemberStatusClass { return &c } @@ -332,37 +304,7 @@ func (c *ChatMemberStatusAdministrator) Zero() bool { if !(c.CanBeEdited == false) { return false } - if !(c.CanManageChat == false) { - return false - } - if !(c.CanChangeInfo == false) { - return false - } - if !(c.CanPostMessages == false) { - return false - } - if !(c.CanEditMessages == false) { - return false - } - if !(c.CanDeleteMessages == false) { - return false - } - if !(c.CanInviteUsers == false) { - return false - } - if !(c.CanRestrictMembers == false) { - return false - } - if !(c.CanPinMessages == false) { - return false - } - if !(c.CanPromoteMembers == false) { - return false - } - if !(c.CanManageVideoChats == false) { - return false - } - if !(c.IsAnonymous == false) { + if !(c.Rights.Zero()) { return false } @@ -410,48 +352,8 @@ func (c *ChatMemberStatusAdministrator) TypeInfo() tdp.Type { SchemaName: "can_be_edited", }, { - Name: "CanManageChat", - SchemaName: "can_manage_chat", - }, - { - Name: "CanChangeInfo", - SchemaName: "can_change_info", - }, - { - Name: "CanPostMessages", - SchemaName: "can_post_messages", - }, - { - Name: "CanEditMessages", - SchemaName: "can_edit_messages", - }, - { - Name: "CanDeleteMessages", - SchemaName: "can_delete_messages", - }, - { - Name: "CanInviteUsers", - SchemaName: "can_invite_users", - }, - { - Name: "CanRestrictMembers", - SchemaName: "can_restrict_members", - }, - { - Name: "CanPinMessages", - SchemaName: "can_pin_messages", - }, - { - Name: "CanPromoteMembers", - SchemaName: "can_promote_members", - }, - { - Name: "CanManageVideoChats", - SchemaName: "can_manage_video_chats", - }, - { - Name: "IsAnonymous", - SchemaName: "is_anonymous", + Name: "Rights", + SchemaName: "rights", }, } return typ @@ -460,7 +362,7 @@ func (c *ChatMemberStatusAdministrator) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (c *ChatMemberStatusAdministrator) Encode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode chatMemberStatusAdministrator#4e6efea as nil") + return fmt.Errorf("can't encode chatMemberStatusAdministrator#fbd3841d as nil") } b.PutID(ChatMemberStatusAdministratorTypeID) return c.EncodeBare(b) @@ -469,31 +371,23 @@ func (c *ChatMemberStatusAdministrator) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (c *ChatMemberStatusAdministrator) EncodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode chatMemberStatusAdministrator#4e6efea as nil") + return fmt.Errorf("can't encode chatMemberStatusAdministrator#fbd3841d as nil") } b.PutString(c.CustomTitle) b.PutBool(c.CanBeEdited) - b.PutBool(c.CanManageChat) - b.PutBool(c.CanChangeInfo) - b.PutBool(c.CanPostMessages) - b.PutBool(c.CanEditMessages) - b.PutBool(c.CanDeleteMessages) - b.PutBool(c.CanInviteUsers) - b.PutBool(c.CanRestrictMembers) - b.PutBool(c.CanPinMessages) - b.PutBool(c.CanPromoteMembers) - b.PutBool(c.CanManageVideoChats) - b.PutBool(c.IsAnonymous) + if err := c.Rights.Encode(b); err != nil { + return fmt.Errorf("unable to encode chatMemberStatusAdministrator#fbd3841d: field rights: %w", err) + } return nil } // Decode implements bin.Decoder. func (c *ChatMemberStatusAdministrator) Decode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode chatMemberStatusAdministrator#4e6efea to nil") + return fmt.Errorf("can't decode chatMemberStatusAdministrator#fbd3841d to nil") } if err := b.ConsumeID(ChatMemberStatusAdministratorTypeID); err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: %w", err) + return fmt.Errorf("unable to decode chatMemberStatusAdministrator#fbd3841d: %w", err) } return c.DecodeBare(b) } @@ -501,98 +395,26 @@ func (c *ChatMemberStatusAdministrator) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (c *ChatMemberStatusAdministrator) DecodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode chatMemberStatusAdministrator#4e6efea to nil") + return fmt.Errorf("can't decode chatMemberStatusAdministrator#fbd3841d to nil") } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field custom_title: %w", err) + return fmt.Errorf("unable to decode chatMemberStatusAdministrator#fbd3841d: field custom_title: %w", err) } c.CustomTitle = value } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field can_be_edited: %w", err) + return fmt.Errorf("unable to decode chatMemberStatusAdministrator#fbd3841d: field can_be_edited: %w", err) } c.CanBeEdited = value } { - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field can_manage_chat: %w", err) - } - c.CanManageChat = value - } - { - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field can_change_info: %w", err) - } - c.CanChangeInfo = value - } - { - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field can_post_messages: %w", err) - } - c.CanPostMessages = value - } - { - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field can_edit_messages: %w", err) - } - c.CanEditMessages = value - } - { - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field can_delete_messages: %w", err) - } - c.CanDeleteMessages = value - } - { - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field can_invite_users: %w", err) - } - c.CanInviteUsers = value - } - { - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field can_restrict_members: %w", err) - } - c.CanRestrictMembers = value - } - { - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field can_pin_messages: %w", err) - } - c.CanPinMessages = value - } - { - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field can_promote_members: %w", err) - } - c.CanPromoteMembers = value - } - { - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field can_manage_video_chats: %w", err) - } - c.CanManageVideoChats = value - } - { - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field is_anonymous: %w", err) + if err := c.Rights.Decode(b); err != nil { + return fmt.Errorf("unable to decode chatMemberStatusAdministrator#fbd3841d: field rights: %w", err) } - c.IsAnonymous = value } return nil } @@ -600,7 +422,7 @@ func (c *ChatMemberStatusAdministrator) DecodeBare(b *bin.Buffer) error { // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (c *ChatMemberStatusAdministrator) EncodeTDLibJSON(b tdjson.Encoder) error { if c == nil { - return fmt.Errorf("can't encode chatMemberStatusAdministrator#4e6efea as nil") + return fmt.Errorf("can't encode chatMemberStatusAdministrator#fbd3841d as nil") } b.ObjStart() b.PutID("chatMemberStatusAdministrator") @@ -611,38 +433,10 @@ func (c *ChatMemberStatusAdministrator) EncodeTDLibJSON(b tdjson.Encoder) error b.FieldStart("can_be_edited") b.PutBool(c.CanBeEdited) b.Comma() - b.FieldStart("can_manage_chat") - b.PutBool(c.CanManageChat) - b.Comma() - b.FieldStart("can_change_info") - b.PutBool(c.CanChangeInfo) - b.Comma() - b.FieldStart("can_post_messages") - b.PutBool(c.CanPostMessages) - b.Comma() - b.FieldStart("can_edit_messages") - b.PutBool(c.CanEditMessages) - b.Comma() - b.FieldStart("can_delete_messages") - b.PutBool(c.CanDeleteMessages) - b.Comma() - b.FieldStart("can_invite_users") - b.PutBool(c.CanInviteUsers) - b.Comma() - b.FieldStart("can_restrict_members") - b.PutBool(c.CanRestrictMembers) - b.Comma() - b.FieldStart("can_pin_messages") - b.PutBool(c.CanPinMessages) - b.Comma() - b.FieldStart("can_promote_members") - b.PutBool(c.CanPromoteMembers) - b.Comma() - b.FieldStart("can_manage_video_chats") - b.PutBool(c.CanManageVideoChats) - b.Comma() - b.FieldStart("is_anonymous") - b.PutBool(c.IsAnonymous) + b.FieldStart("rights") + if err := c.Rights.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode chatMemberStatusAdministrator#fbd3841d: field rights: %w", err) + } b.Comma() b.StripComma() b.ObjEnd() @@ -652,93 +446,31 @@ func (c *ChatMemberStatusAdministrator) EncodeTDLibJSON(b tdjson.Encoder) error // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (c *ChatMemberStatusAdministrator) DecodeTDLibJSON(b tdjson.Decoder) error { if c == nil { - return fmt.Errorf("can't decode chatMemberStatusAdministrator#4e6efea to nil") + return fmt.Errorf("can't decode chatMemberStatusAdministrator#fbd3841d to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("chatMemberStatusAdministrator"); err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: %w", err) + return fmt.Errorf("unable to decode chatMemberStatusAdministrator#fbd3841d: %w", err) } case "custom_title": value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field custom_title: %w", err) + return fmt.Errorf("unable to decode chatMemberStatusAdministrator#fbd3841d: field custom_title: %w", err) } c.CustomTitle = value case "can_be_edited": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field can_be_edited: %w", err) + return fmt.Errorf("unable to decode chatMemberStatusAdministrator#fbd3841d: field can_be_edited: %w", err) } c.CanBeEdited = value - case "can_manage_chat": - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field can_manage_chat: %w", err) - } - c.CanManageChat = value - case "can_change_info": - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field can_change_info: %w", err) - } - c.CanChangeInfo = value - case "can_post_messages": - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field can_post_messages: %w", err) - } - c.CanPostMessages = value - case "can_edit_messages": - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field can_edit_messages: %w", err) + case "rights": + if err := c.Rights.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode chatMemberStatusAdministrator#fbd3841d: field rights: %w", err) } - c.CanEditMessages = value - case "can_delete_messages": - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field can_delete_messages: %w", err) - } - c.CanDeleteMessages = value - case "can_invite_users": - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field can_invite_users: %w", err) - } - c.CanInviteUsers = value - case "can_restrict_members": - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field can_restrict_members: %w", err) - } - c.CanRestrictMembers = value - case "can_pin_messages": - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field can_pin_messages: %w", err) - } - c.CanPinMessages = value - case "can_promote_members": - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field can_promote_members: %w", err) - } - c.CanPromoteMembers = value - case "can_manage_video_chats": - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field can_manage_video_chats: %w", err) - } - c.CanManageVideoChats = value - case "is_anonymous": - value, err := b.Bool() - if err != nil { - return fmt.Errorf("unable to decode chatMemberStatusAdministrator#4e6efea: field is_anonymous: %w", err) - } - c.IsAnonymous = value default: return b.Skip() } @@ -762,92 +494,12 @@ func (c *ChatMemberStatusAdministrator) GetCanBeEdited() (value bool) { return c.CanBeEdited } -// GetCanManageChat returns value of CanManageChat field. -func (c *ChatMemberStatusAdministrator) GetCanManageChat() (value bool) { - if c == nil { - return - } - return c.CanManageChat -} - -// GetCanChangeInfo returns value of CanChangeInfo field. -func (c *ChatMemberStatusAdministrator) GetCanChangeInfo() (value bool) { - if c == nil { - return - } - return c.CanChangeInfo -} - -// GetCanPostMessages returns value of CanPostMessages field. -func (c *ChatMemberStatusAdministrator) GetCanPostMessages() (value bool) { - if c == nil { - return - } - return c.CanPostMessages -} - -// GetCanEditMessages returns value of CanEditMessages field. -func (c *ChatMemberStatusAdministrator) GetCanEditMessages() (value bool) { - if c == nil { - return - } - return c.CanEditMessages -} - -// GetCanDeleteMessages returns value of CanDeleteMessages field. -func (c *ChatMemberStatusAdministrator) GetCanDeleteMessages() (value bool) { - if c == nil { - return - } - return c.CanDeleteMessages -} - -// GetCanInviteUsers returns value of CanInviteUsers field. -func (c *ChatMemberStatusAdministrator) GetCanInviteUsers() (value bool) { - if c == nil { - return - } - return c.CanInviteUsers -} - -// GetCanRestrictMembers returns value of CanRestrictMembers field. -func (c *ChatMemberStatusAdministrator) GetCanRestrictMembers() (value bool) { - if c == nil { - return - } - return c.CanRestrictMembers -} - -// GetCanPinMessages returns value of CanPinMessages field. -func (c *ChatMemberStatusAdministrator) GetCanPinMessages() (value bool) { - if c == nil { - return - } - return c.CanPinMessages -} - -// GetCanPromoteMembers returns value of CanPromoteMembers field. -func (c *ChatMemberStatusAdministrator) GetCanPromoteMembers() (value bool) { +// GetRights returns value of Rights field. +func (c *ChatMemberStatusAdministrator) GetRights() (value ChatAdministratorRights) { if c == nil { return } - return c.CanPromoteMembers -} - -// GetCanManageVideoChats returns value of CanManageVideoChats field. -func (c *ChatMemberStatusAdministrator) GetCanManageVideoChats() (value bool) { - if c == nil { - return - } - return c.CanManageVideoChats -} - -// GetIsAnonymous returns value of IsAnonymous field. -func (c *ChatMemberStatusAdministrator) GetIsAnonymous() (value bool) { - if c == nil { - return - } - return c.IsAnonymous + return c.Rights } // ChatMemberStatusMember represents TL type `chatMemberStatusMember#32597455`. @@ -1528,7 +1180,7 @@ const ChatMemberStatusClassName = "ChatMemberStatus" // } // switch v := g.(type) { // case *tdapi.ChatMemberStatusCreator: // chatMemberStatusCreator#f6764afe -// case *tdapi.ChatMemberStatusAdministrator: // chatMemberStatusAdministrator#4e6efea +// case *tdapi.ChatMemberStatusAdministrator: // chatMemberStatusAdministrator#fbd3841d // case *tdapi.ChatMemberStatusMember: // chatMemberStatusMember#32597455 // case *tdapi.ChatMemberStatusRestricted: // chatMemberStatusRestricted#630774a6 // case *tdapi.ChatMemberStatusLeft: // chatMemberStatusLeft#ffa74425 @@ -1572,7 +1224,7 @@ func DecodeChatMemberStatus(buf *bin.Buffer) (ChatMemberStatusClass, error) { } return &v, nil case ChatMemberStatusAdministratorTypeID: - // Decoding chatMemberStatusAdministrator#4e6efea. + // Decoding chatMemberStatusAdministrator#fbd3841d. v := ChatMemberStatusAdministrator{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode ChatMemberStatusClass: %w", err) @@ -1626,7 +1278,7 @@ func DecodeTDLibJSONChatMemberStatus(buf tdjson.Decoder) (ChatMemberStatusClass, } return &v, nil case "chatMemberStatusAdministrator": - // Decoding chatMemberStatusAdministrator#4e6efea. + // Decoding chatMemberStatusAdministrator#fbd3841d. v := ChatMemberStatusAdministrator{} if err := v.DecodeTDLibJSON(buf); err != nil { return nil, fmt.Errorf("unable to decode ChatMemberStatusClass: %w", err) diff --git a/tdapi/tl_chat_notification_settings_gen.go b/tdapi/tl_chat_notification_settings_gen.go index 48e0691c40..c4308a8fca 100644 --- a/tdapi/tl_chat_notification_settings_gen.go +++ b/tdapi/tl_chat_notification_settings_gen.go @@ -31,18 +31,17 @@ var ( _ = tdjson.Encoder{} ) -// ChatNotificationSettings represents TL type `chatNotificationSettings#5998c172`. +// ChatNotificationSettings represents TL type `chatNotificationSettings#38493760`. type ChatNotificationSettings struct { // If true, mute_for is ignored and the value for the relevant type of chat is used // instead UseDefaultMuteFor bool // Time left before notifications will be unmuted, in seconds MuteFor int32 - // If true, sound is ignored and the value for the relevant type of chat is used instead + // If true, the value for the relevant type of chat is used instead of sound_id UseDefaultSound bool - // The name of an audio file to be used for notification sounds; only applies to iOS - // applications - Sound string + // Identifier of the notification sound to be played; 0 if sound is disabled + SoundID int64 // If true, show_preview is ignored and the value for the relevant type of chat is used // instead UseDefaultShowPreview bool @@ -63,7 +62,7 @@ type ChatNotificationSettings struct { } // ChatNotificationSettingsTypeID is TL type id of ChatNotificationSettings. -const ChatNotificationSettingsTypeID = 0x5998c172 +const ChatNotificationSettingsTypeID = 0x38493760 // Ensuring interfaces in compile-time for ChatNotificationSettings. var ( @@ -86,7 +85,7 @@ func (c *ChatNotificationSettings) Zero() bool { if !(c.UseDefaultSound == false) { return false } - if !(c.Sound == "") { + if !(c.SoundID == 0) { return false } if !(c.UseDefaultShowPreview == false) { @@ -156,8 +155,8 @@ func (c *ChatNotificationSettings) TypeInfo() tdp.Type { SchemaName: "use_default_sound", }, { - Name: "Sound", - SchemaName: "sound", + Name: "SoundID", + SchemaName: "sound_id", }, { Name: "UseDefaultShowPreview", @@ -190,7 +189,7 @@ func (c *ChatNotificationSettings) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (c *ChatNotificationSettings) Encode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode chatNotificationSettings#5998c172 as nil") + return fmt.Errorf("can't encode chatNotificationSettings#38493760 as nil") } b.PutID(ChatNotificationSettingsTypeID) return c.EncodeBare(b) @@ -199,12 +198,12 @@ func (c *ChatNotificationSettings) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (c *ChatNotificationSettings) EncodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't encode chatNotificationSettings#5998c172 as nil") + return fmt.Errorf("can't encode chatNotificationSettings#38493760 as nil") } b.PutBool(c.UseDefaultMuteFor) b.PutInt32(c.MuteFor) b.PutBool(c.UseDefaultSound) - b.PutString(c.Sound) + b.PutLong(c.SoundID) b.PutBool(c.UseDefaultShowPreview) b.PutBool(c.ShowPreview) b.PutBool(c.UseDefaultDisablePinnedMessageNotifications) @@ -217,10 +216,10 @@ func (c *ChatNotificationSettings) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (c *ChatNotificationSettings) Decode(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode chatNotificationSettings#5998c172 to nil") + return fmt.Errorf("can't decode chatNotificationSettings#38493760 to nil") } if err := b.ConsumeID(ChatNotificationSettingsTypeID); err != nil { - return fmt.Errorf("unable to decode chatNotificationSettings#5998c172: %w", err) + return fmt.Errorf("unable to decode chatNotificationSettings#38493760: %w", err) } return c.DecodeBare(b) } @@ -228,75 +227,75 @@ func (c *ChatNotificationSettings) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (c *ChatNotificationSettings) DecodeBare(b *bin.Buffer) error { if c == nil { - return fmt.Errorf("can't decode chatNotificationSettings#5998c172 to nil") + return fmt.Errorf("can't decode chatNotificationSettings#38493760 to nil") } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode chatNotificationSettings#5998c172: field use_default_mute_for: %w", err) + return fmt.Errorf("unable to decode chatNotificationSettings#38493760: field use_default_mute_for: %w", err) } c.UseDefaultMuteFor = value } { value, err := b.Int32() if err != nil { - return fmt.Errorf("unable to decode chatNotificationSettings#5998c172: field mute_for: %w", err) + return fmt.Errorf("unable to decode chatNotificationSettings#38493760: field mute_for: %w", err) } c.MuteFor = value } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode chatNotificationSettings#5998c172: field use_default_sound: %w", err) + return fmt.Errorf("unable to decode chatNotificationSettings#38493760: field use_default_sound: %w", err) } c.UseDefaultSound = value } { - value, err := b.String() + value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode chatNotificationSettings#5998c172: field sound: %w", err) + return fmt.Errorf("unable to decode chatNotificationSettings#38493760: field sound_id: %w", err) } - c.Sound = value + c.SoundID = value } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode chatNotificationSettings#5998c172: field use_default_show_preview: %w", err) + return fmt.Errorf("unable to decode chatNotificationSettings#38493760: field use_default_show_preview: %w", err) } c.UseDefaultShowPreview = value } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode chatNotificationSettings#5998c172: field show_preview: %w", err) + return fmt.Errorf("unable to decode chatNotificationSettings#38493760: field show_preview: %w", err) } c.ShowPreview = value } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode chatNotificationSettings#5998c172: field use_default_disable_pinned_message_notifications: %w", err) + return fmt.Errorf("unable to decode chatNotificationSettings#38493760: field use_default_disable_pinned_message_notifications: %w", err) } c.UseDefaultDisablePinnedMessageNotifications = value } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode chatNotificationSettings#5998c172: field disable_pinned_message_notifications: %w", err) + return fmt.Errorf("unable to decode chatNotificationSettings#38493760: field disable_pinned_message_notifications: %w", err) } c.DisablePinnedMessageNotifications = value } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode chatNotificationSettings#5998c172: field use_default_disable_mention_notifications: %w", err) + return fmt.Errorf("unable to decode chatNotificationSettings#38493760: field use_default_disable_mention_notifications: %w", err) } c.UseDefaultDisableMentionNotifications = value } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode chatNotificationSettings#5998c172: field disable_mention_notifications: %w", err) + return fmt.Errorf("unable to decode chatNotificationSettings#38493760: field disable_mention_notifications: %w", err) } c.DisableMentionNotifications = value } @@ -306,7 +305,7 @@ func (c *ChatNotificationSettings) DecodeBare(b *bin.Buffer) error { // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (c *ChatNotificationSettings) EncodeTDLibJSON(b tdjson.Encoder) error { if c == nil { - return fmt.Errorf("can't encode chatNotificationSettings#5998c172 as nil") + return fmt.Errorf("can't encode chatNotificationSettings#38493760 as nil") } b.ObjStart() b.PutID("chatNotificationSettings") @@ -320,8 +319,8 @@ func (c *ChatNotificationSettings) EncodeTDLibJSON(b tdjson.Encoder) error { b.FieldStart("use_default_sound") b.PutBool(c.UseDefaultSound) b.Comma() - b.FieldStart("sound") - b.PutString(c.Sound) + b.FieldStart("sound_id") + b.PutLong(c.SoundID) b.Comma() b.FieldStart("use_default_show_preview") b.PutBool(c.UseDefaultShowPreview) @@ -349,73 +348,73 @@ func (c *ChatNotificationSettings) EncodeTDLibJSON(b tdjson.Encoder) error { // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (c *ChatNotificationSettings) DecodeTDLibJSON(b tdjson.Decoder) error { if c == nil { - return fmt.Errorf("can't decode chatNotificationSettings#5998c172 to nil") + return fmt.Errorf("can't decode chatNotificationSettings#38493760 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("chatNotificationSettings"); err != nil { - return fmt.Errorf("unable to decode chatNotificationSettings#5998c172: %w", err) + return fmt.Errorf("unable to decode chatNotificationSettings#38493760: %w", err) } case "use_default_mute_for": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode chatNotificationSettings#5998c172: field use_default_mute_for: %w", err) + return fmt.Errorf("unable to decode chatNotificationSettings#38493760: field use_default_mute_for: %w", err) } c.UseDefaultMuteFor = value case "mute_for": value, err := b.Int32() if err != nil { - return fmt.Errorf("unable to decode chatNotificationSettings#5998c172: field mute_for: %w", err) + return fmt.Errorf("unable to decode chatNotificationSettings#38493760: field mute_for: %w", err) } c.MuteFor = value case "use_default_sound": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode chatNotificationSettings#5998c172: field use_default_sound: %w", err) + return fmt.Errorf("unable to decode chatNotificationSettings#38493760: field use_default_sound: %w", err) } c.UseDefaultSound = value - case "sound": - value, err := b.String() + case "sound_id": + value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode chatNotificationSettings#5998c172: field sound: %w", err) + return fmt.Errorf("unable to decode chatNotificationSettings#38493760: field sound_id: %w", err) } - c.Sound = value + c.SoundID = value case "use_default_show_preview": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode chatNotificationSettings#5998c172: field use_default_show_preview: %w", err) + return fmt.Errorf("unable to decode chatNotificationSettings#38493760: field use_default_show_preview: %w", err) } c.UseDefaultShowPreview = value case "show_preview": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode chatNotificationSettings#5998c172: field show_preview: %w", err) + return fmt.Errorf("unable to decode chatNotificationSettings#38493760: field show_preview: %w", err) } c.ShowPreview = value case "use_default_disable_pinned_message_notifications": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode chatNotificationSettings#5998c172: field use_default_disable_pinned_message_notifications: %w", err) + return fmt.Errorf("unable to decode chatNotificationSettings#38493760: field use_default_disable_pinned_message_notifications: %w", err) } c.UseDefaultDisablePinnedMessageNotifications = value case "disable_pinned_message_notifications": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode chatNotificationSettings#5998c172: field disable_pinned_message_notifications: %w", err) + return fmt.Errorf("unable to decode chatNotificationSettings#38493760: field disable_pinned_message_notifications: %w", err) } c.DisablePinnedMessageNotifications = value case "use_default_disable_mention_notifications": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode chatNotificationSettings#5998c172: field use_default_disable_mention_notifications: %w", err) + return fmt.Errorf("unable to decode chatNotificationSettings#38493760: field use_default_disable_mention_notifications: %w", err) } c.UseDefaultDisableMentionNotifications = value case "disable_mention_notifications": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode chatNotificationSettings#5998c172: field disable_mention_notifications: %w", err) + return fmt.Errorf("unable to decode chatNotificationSettings#38493760: field disable_mention_notifications: %w", err) } c.DisableMentionNotifications = value default: @@ -449,12 +448,12 @@ func (c *ChatNotificationSettings) GetUseDefaultSound() (value bool) { return c.UseDefaultSound } -// GetSound returns value of Sound field. -func (c *ChatNotificationSettings) GetSound() (value string) { +// GetSoundID returns value of SoundID field. +func (c *ChatNotificationSettings) GetSoundID() (value int64) { if c == nil { return } - return c.Sound + return c.SoundID } // GetUseDefaultShowPreview returns value of UseDefaultShowPreview field. diff --git a/tdapi/tl_close_web_app_gen.go b/tdapi/tl_close_web_app_gen.go new file mode 100644 index 0000000000..ab57ee3136 --- /dev/null +++ b/tdapi/tl_close_web_app_gen.go @@ -0,0 +1,206 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// CloseWebAppRequest represents TL type `closeWebApp#68a124c6`. +type CloseWebAppRequest struct { + // Identifier of web app launch, received from openWebApp + WebAppLaunchID int64 +} + +// CloseWebAppRequestTypeID is TL type id of CloseWebAppRequest. +const CloseWebAppRequestTypeID = 0x68a124c6 + +// Ensuring interfaces in compile-time for CloseWebAppRequest. +var ( + _ bin.Encoder = &CloseWebAppRequest{} + _ bin.Decoder = &CloseWebAppRequest{} + _ bin.BareEncoder = &CloseWebAppRequest{} + _ bin.BareDecoder = &CloseWebAppRequest{} +) + +func (c *CloseWebAppRequest) Zero() bool { + if c == nil { + return true + } + if !(c.WebAppLaunchID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (c *CloseWebAppRequest) String() string { + if c == nil { + return "CloseWebAppRequest(nil)" + } + type Alias CloseWebAppRequest + return fmt.Sprintf("CloseWebAppRequest%+v", Alias(*c)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*CloseWebAppRequest) TypeID() uint32 { + return CloseWebAppRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*CloseWebAppRequest) TypeName() string { + return "closeWebApp" +} + +// TypeInfo returns info about TL type. +func (c *CloseWebAppRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "closeWebApp", + ID: CloseWebAppRequestTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "WebAppLaunchID", + SchemaName: "web_app_launch_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (c *CloseWebAppRequest) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode closeWebApp#68a124c6 as nil") + } + b.PutID(CloseWebAppRequestTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *CloseWebAppRequest) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode closeWebApp#68a124c6 as nil") + } + b.PutLong(c.WebAppLaunchID) + return nil +} + +// Decode implements bin.Decoder. +func (c *CloseWebAppRequest) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode closeWebApp#68a124c6 to nil") + } + if err := b.ConsumeID(CloseWebAppRequestTypeID); err != nil { + return fmt.Errorf("unable to decode closeWebApp#68a124c6: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *CloseWebAppRequest) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode closeWebApp#68a124c6 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode closeWebApp#68a124c6: field web_app_launch_id: %w", err) + } + c.WebAppLaunchID = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (c *CloseWebAppRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if c == nil { + return fmt.Errorf("can't encode closeWebApp#68a124c6 as nil") + } + b.ObjStart() + b.PutID("closeWebApp") + b.Comma() + b.FieldStart("web_app_launch_id") + b.PutLong(c.WebAppLaunchID) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (c *CloseWebAppRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if c == nil { + return fmt.Errorf("can't decode closeWebApp#68a124c6 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("closeWebApp"); err != nil { + return fmt.Errorf("unable to decode closeWebApp#68a124c6: %w", err) + } + case "web_app_launch_id": + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode closeWebApp#68a124c6: field web_app_launch_id: %w", err) + } + c.WebAppLaunchID = value + default: + return b.Skip() + } + return nil + }) +} + +// GetWebAppLaunchID returns value of WebAppLaunchID field. +func (c *CloseWebAppRequest) GetWebAppLaunchID() (value int64) { + if c == nil { + return + } + return c.WebAppLaunchID +} + +// CloseWebApp invokes method closeWebApp#68a124c6 returning error if any. +func (c *Client) CloseWebApp(ctx context.Context, webapplaunchid int64) error { + var ok Ok + + request := &CloseWebAppRequest{ + WebAppLaunchID: webapplaunchid, + } + if err := c.rpc.Invoke(ctx, request, &ok); err != nil { + return err + } + return nil +} diff --git a/tdapi/tl_connected_website_gen.go b/tdapi/tl_connected_website_gen.go index d358b561a7..04c69c3008 100644 --- a/tdapi/tl_connected_website_gen.go +++ b/tdapi/tl_connected_website_gen.go @@ -49,8 +49,8 @@ type ConnectedWebsite struct { LastActiveDate int32 // IP address from which the user was logged in, in human-readable format IP string - // Human-readable description of a country and a region, from which the user was logged - // in, based on the IP address + // Human-readable description of a country and a region from which the user was logged in + // based on the IP address Location string } diff --git a/tdapi/tl_create_video_chat_gen.go b/tdapi/tl_create_video_chat_gen.go index 67f8b227e0..912cac30ce 100644 --- a/tdapi/tl_create_video_chat_gen.go +++ b/tdapi/tl_create_video_chat_gen.go @@ -33,7 +33,7 @@ var ( // CreateVideoChatRequest represents TL type `createVideoChat#7ea4958d`. type CreateVideoChatRequest struct { - // Chat identifier, in which the video chat will be created + // Identifier of a chat in which the video chat will be created ChatID int64 // Group call title; if empty, chat title will be used Title string diff --git a/tdapi/tl_draft_message_gen.go b/tdapi/tl_draft_message_gen.go index aba55b8610..d07ce44b16 100644 --- a/tdapi/tl_draft_message_gen.go +++ b/tdapi/tl_draft_message_gen.go @@ -33,7 +33,7 @@ var ( // DraftMessage represents TL type `draftMessage#51d71500`. type DraftMessage struct { - // Identifier of the message to reply to; 0 if none + // Identifier of the replied message; 0 if none ReplyToMessageID int64 // Point in time (Unix timestamp) when the draft was created Date int32 diff --git a/tdapi/tl_file_type_gen.go b/tdapi/tl_file_type_gen.go index 509f9956f2..925aa304bb 100644 --- a/tdapi/tl_file_type_gen.go +++ b/tdapi/tl_file_type_gen.go @@ -555,6 +555,137 @@ func (f *FileTypeDocument) DecodeTDLibJSON(b tdjson.Decoder) error { }) } +// FileTypeNotificationSound represents TL type `fileTypeNotificationSound#c32f9f09`. +type FileTypeNotificationSound struct { +} + +// FileTypeNotificationSoundTypeID is TL type id of FileTypeNotificationSound. +const FileTypeNotificationSoundTypeID = 0xc32f9f09 + +// construct implements constructor of FileTypeClass. +func (f FileTypeNotificationSound) construct() FileTypeClass { return &f } + +// Ensuring interfaces in compile-time for FileTypeNotificationSound. +var ( + _ bin.Encoder = &FileTypeNotificationSound{} + _ bin.Decoder = &FileTypeNotificationSound{} + _ bin.BareEncoder = &FileTypeNotificationSound{} + _ bin.BareDecoder = &FileTypeNotificationSound{} + + _ FileTypeClass = &FileTypeNotificationSound{} +) + +func (f *FileTypeNotificationSound) Zero() bool { + if f == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (f *FileTypeNotificationSound) String() string { + if f == nil { + return "FileTypeNotificationSound(nil)" + } + type Alias FileTypeNotificationSound + return fmt.Sprintf("FileTypeNotificationSound%+v", Alias(*f)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*FileTypeNotificationSound) TypeID() uint32 { + return FileTypeNotificationSoundTypeID +} + +// TypeName returns name of type in TL schema. +func (*FileTypeNotificationSound) TypeName() string { + return "fileTypeNotificationSound" +} + +// TypeInfo returns info about TL type. +func (f *FileTypeNotificationSound) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "fileTypeNotificationSound", + ID: FileTypeNotificationSoundTypeID, + } + if f == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (f *FileTypeNotificationSound) Encode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode fileTypeNotificationSound#c32f9f09 as nil") + } + b.PutID(FileTypeNotificationSoundTypeID) + return f.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (f *FileTypeNotificationSound) EncodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode fileTypeNotificationSound#c32f9f09 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (f *FileTypeNotificationSound) Decode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode fileTypeNotificationSound#c32f9f09 to nil") + } + if err := b.ConsumeID(FileTypeNotificationSoundTypeID); err != nil { + return fmt.Errorf("unable to decode fileTypeNotificationSound#c32f9f09: %w", err) + } + return f.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (f *FileTypeNotificationSound) DecodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode fileTypeNotificationSound#c32f9f09 to nil") + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (f *FileTypeNotificationSound) EncodeTDLibJSON(b tdjson.Encoder) error { + if f == nil { + return fmt.Errorf("can't encode fileTypeNotificationSound#c32f9f09 as nil") + } + b.ObjStart() + b.PutID("fileTypeNotificationSound") + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (f *FileTypeNotificationSound) DecodeTDLibJSON(b tdjson.Decoder) error { + if f == nil { + return fmt.Errorf("can't decode fileTypeNotificationSound#c32f9f09 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("fileTypeNotificationSound"); err != nil { + return fmt.Errorf("unable to decode fileTypeNotificationSound#c32f9f09: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + // FileTypePhoto represents TL type `fileTypePhoto#998b71a5`. type FileTypePhoto struct { } @@ -2142,6 +2273,7 @@ const FileTypeClassName = "FileType" // case *tdapi.FileTypeAnimation: // fileTypeAnimation#eeaa7dba // case *tdapi.FileTypeAudio: // fileTypeAudio#d5bbcea0 // case *tdapi.FileTypeDocument: // fileTypeDocument#de57030f +// case *tdapi.FileTypeNotificationSound: // fileTypeNotificationSound#c32f9f09 // case *tdapi.FileTypePhoto: // fileTypePhoto#998b71a5 // case *tdapi.FileTypeProfilePhoto: // fileTypeProfilePhoto#6afee3a3 // case *tdapi.FileTypeSecret: // fileTypeSecret#906d14f7 @@ -2213,6 +2345,13 @@ func DecodeFileType(buf *bin.Buffer) (FileTypeClass, error) { return nil, fmt.Errorf("unable to decode FileTypeClass: %w", err) } return &v, nil + case FileTypeNotificationSoundTypeID: + // Decoding fileTypeNotificationSound#c32f9f09. + v := FileTypeNotificationSound{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode FileTypeClass: %w", err) + } + return &v, nil case FileTypePhotoTypeID: // Decoding fileTypePhoto#998b71a5. v := FileTypePhoto{} @@ -2337,6 +2476,13 @@ func DecodeTDLibJSONFileType(buf tdjson.Decoder) (FileTypeClass, error) { return nil, fmt.Errorf("unable to decode FileTypeClass: %w", err) } return &v, nil + case "fileTypeNotificationSound": + // Decoding fileTypeNotificationSound#c32f9f09. + v := FileTypeNotificationSound{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode FileTypeClass: %w", err) + } + return &v, nil case "fileTypePhoto": // Decoding fileTypePhoto#998b71a5. v := FileTypePhoto{} diff --git a/tdapi/tl_get_attachment_menu_bot_gen.go b/tdapi/tl_get_attachment_menu_bot_gen.go new file mode 100644 index 0000000000..aa0f2828e4 --- /dev/null +++ b/tdapi/tl_get_attachment_menu_bot_gen.go @@ -0,0 +1,206 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// GetAttachmentMenuBotRequest represents TL type `getAttachmentMenuBot#3da561fb`. +type GetAttachmentMenuBotRequest struct { + // Bot's user identifier + BotUserID int64 +} + +// GetAttachmentMenuBotRequestTypeID is TL type id of GetAttachmentMenuBotRequest. +const GetAttachmentMenuBotRequestTypeID = 0x3da561fb + +// Ensuring interfaces in compile-time for GetAttachmentMenuBotRequest. +var ( + _ bin.Encoder = &GetAttachmentMenuBotRequest{} + _ bin.Decoder = &GetAttachmentMenuBotRequest{} + _ bin.BareEncoder = &GetAttachmentMenuBotRequest{} + _ bin.BareDecoder = &GetAttachmentMenuBotRequest{} +) + +func (g *GetAttachmentMenuBotRequest) Zero() bool { + if g == nil { + return true + } + if !(g.BotUserID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *GetAttachmentMenuBotRequest) String() string { + if g == nil { + return "GetAttachmentMenuBotRequest(nil)" + } + type Alias GetAttachmentMenuBotRequest + return fmt.Sprintf("GetAttachmentMenuBotRequest%+v", Alias(*g)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*GetAttachmentMenuBotRequest) TypeID() uint32 { + return GetAttachmentMenuBotRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*GetAttachmentMenuBotRequest) TypeName() string { + return "getAttachmentMenuBot" +} + +// TypeInfo returns info about TL type. +func (g *GetAttachmentMenuBotRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "getAttachmentMenuBot", + ID: GetAttachmentMenuBotRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "BotUserID", + SchemaName: "bot_user_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *GetAttachmentMenuBotRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode getAttachmentMenuBot#3da561fb as nil") + } + b.PutID(GetAttachmentMenuBotRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *GetAttachmentMenuBotRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode getAttachmentMenuBot#3da561fb as nil") + } + b.PutInt53(g.BotUserID) + return nil +} + +// Decode implements bin.Decoder. +func (g *GetAttachmentMenuBotRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode getAttachmentMenuBot#3da561fb to nil") + } + if err := b.ConsumeID(GetAttachmentMenuBotRequestTypeID); err != nil { + return fmt.Errorf("unable to decode getAttachmentMenuBot#3da561fb: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *GetAttachmentMenuBotRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode getAttachmentMenuBot#3da561fb to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode getAttachmentMenuBot#3da561fb: field bot_user_id: %w", err) + } + g.BotUserID = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (g *GetAttachmentMenuBotRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if g == nil { + return fmt.Errorf("can't encode getAttachmentMenuBot#3da561fb as nil") + } + b.ObjStart() + b.PutID("getAttachmentMenuBot") + b.Comma() + b.FieldStart("bot_user_id") + b.PutInt53(g.BotUserID) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (g *GetAttachmentMenuBotRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if g == nil { + return fmt.Errorf("can't decode getAttachmentMenuBot#3da561fb to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("getAttachmentMenuBot"); err != nil { + return fmt.Errorf("unable to decode getAttachmentMenuBot#3da561fb: %w", err) + } + case "bot_user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode getAttachmentMenuBot#3da561fb: field bot_user_id: %w", err) + } + g.BotUserID = value + default: + return b.Skip() + } + return nil + }) +} + +// GetBotUserID returns value of BotUserID field. +func (g *GetAttachmentMenuBotRequest) GetBotUserID() (value int64) { + if g == nil { + return + } + return g.BotUserID +} + +// GetAttachmentMenuBot invokes method getAttachmentMenuBot#3da561fb returning error if any. +func (c *Client) GetAttachmentMenuBot(ctx context.Context, botuserid int64) (*AttachmentMenuBot, error) { + var result AttachmentMenuBot + + request := &GetAttachmentMenuBotRequest{ + BotUserID: botuserid, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tdapi/tl_get_map_thumbnail_file_gen.go b/tdapi/tl_get_map_thumbnail_file_gen.go index 77f83af6d0..15feb2de06 100644 --- a/tdapi/tl_get_map_thumbnail_file_gen.go +++ b/tdapi/tl_get_map_thumbnail_file_gen.go @@ -43,7 +43,7 @@ type GetMapThumbnailFileRequest struct { Height int32 // Map scale; 1-3 Scale int32 - // Identifier of a chat, in which the thumbnail will be shown. Use 0 if unknown + // Identifier of a chat in which the thumbnail will be shown. Use 0 if unknown ChatID int64 } diff --git a/tdapi/tl_get_menu_button_gen.go b/tdapi/tl_get_menu_button_gen.go new file mode 100644 index 0000000000..f641b74445 --- /dev/null +++ b/tdapi/tl_get_menu_button_gen.go @@ -0,0 +1,206 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// GetMenuButtonRequest represents TL type `getMenuButton#e5eef440`. +type GetMenuButtonRequest struct { + // Identifier of the user or 0 to get the default menu button + UserID int64 +} + +// GetMenuButtonRequestTypeID is TL type id of GetMenuButtonRequest. +const GetMenuButtonRequestTypeID = 0xe5eef440 + +// Ensuring interfaces in compile-time for GetMenuButtonRequest. +var ( + _ bin.Encoder = &GetMenuButtonRequest{} + _ bin.Decoder = &GetMenuButtonRequest{} + _ bin.BareEncoder = &GetMenuButtonRequest{} + _ bin.BareDecoder = &GetMenuButtonRequest{} +) + +func (g *GetMenuButtonRequest) Zero() bool { + if g == nil { + return true + } + if !(g.UserID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *GetMenuButtonRequest) String() string { + if g == nil { + return "GetMenuButtonRequest(nil)" + } + type Alias GetMenuButtonRequest + return fmt.Sprintf("GetMenuButtonRequest%+v", Alias(*g)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*GetMenuButtonRequest) TypeID() uint32 { + return GetMenuButtonRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*GetMenuButtonRequest) TypeName() string { + return "getMenuButton" +} + +// TypeInfo returns info about TL type. +func (g *GetMenuButtonRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "getMenuButton", + ID: GetMenuButtonRequestTypeID, + } + 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 *GetMenuButtonRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode getMenuButton#e5eef440 as nil") + } + b.PutID(GetMenuButtonRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *GetMenuButtonRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode getMenuButton#e5eef440 as nil") + } + b.PutInt53(g.UserID) + return nil +} + +// Decode implements bin.Decoder. +func (g *GetMenuButtonRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode getMenuButton#e5eef440 to nil") + } + if err := b.ConsumeID(GetMenuButtonRequestTypeID); err != nil { + return fmt.Errorf("unable to decode getMenuButton#e5eef440: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *GetMenuButtonRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode getMenuButton#e5eef440 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode getMenuButton#e5eef440: field user_id: %w", err) + } + g.UserID = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (g *GetMenuButtonRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if g == nil { + return fmt.Errorf("can't encode getMenuButton#e5eef440 as nil") + } + b.ObjStart() + b.PutID("getMenuButton") + b.Comma() + b.FieldStart("user_id") + b.PutInt53(g.UserID) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (g *GetMenuButtonRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if g == nil { + return fmt.Errorf("can't decode getMenuButton#e5eef440 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("getMenuButton"); err != nil { + return fmt.Errorf("unable to decode getMenuButton#e5eef440: %w", err) + } + case "user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode getMenuButton#e5eef440: field user_id: %w", err) + } + g.UserID = value + default: + return b.Skip() + } + return nil + }) +} + +// GetUserID returns value of UserID field. +func (g *GetMenuButtonRequest) GetUserID() (value int64) { + if g == nil { + return + } + return g.UserID +} + +// GetMenuButton invokes method getMenuButton#e5eef440 returning error if any. +func (c *Client) GetMenuButton(ctx context.Context, userid int64) (*BotMenuButton, error) { + var result BotMenuButton + + request := &GetMenuButtonRequest{ + UserID: userid, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tdapi/tl_get_payment_form_gen.go b/tdapi/tl_get_payment_form_gen.go index 8fd9cd355e..c334094128 100644 --- a/tdapi/tl_get_payment_form_gen.go +++ b/tdapi/tl_get_payment_form_gen.go @@ -31,18 +31,18 @@ var ( _ = tdjson.Encoder{} ) -// GetPaymentFormRequest represents TL type `getPaymentForm#96e6319`. +// GetPaymentFormRequest represents TL type `getPaymentForm#90411057`. type GetPaymentFormRequest struct { // Chat identifier of the Invoice message ChatID int64 // Message identifier MessageID int64 // Preferred payment form theme; pass null to use the default theme - Theme PaymentFormTheme + Theme ThemeParameters } // GetPaymentFormRequestTypeID is TL type id of GetPaymentFormRequest. -const GetPaymentFormRequestTypeID = 0x96e6319 +const GetPaymentFormRequestTypeID = 0x90411057 // Ensuring interfaces in compile-time for GetPaymentFormRequest. var ( @@ -120,7 +120,7 @@ func (g *GetPaymentFormRequest) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (g *GetPaymentFormRequest) Encode(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't encode getPaymentForm#96e6319 as nil") + return fmt.Errorf("can't encode getPaymentForm#90411057 as nil") } b.PutID(GetPaymentFormRequestTypeID) return g.EncodeBare(b) @@ -129,12 +129,12 @@ func (g *GetPaymentFormRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (g *GetPaymentFormRequest) EncodeBare(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't encode getPaymentForm#96e6319 as nil") + return fmt.Errorf("can't encode getPaymentForm#90411057 as nil") } b.PutInt53(g.ChatID) b.PutInt53(g.MessageID) if err := g.Theme.Encode(b); err != nil { - return fmt.Errorf("unable to encode getPaymentForm#96e6319: field theme: %w", err) + return fmt.Errorf("unable to encode getPaymentForm#90411057: field theme: %w", err) } return nil } @@ -142,10 +142,10 @@ func (g *GetPaymentFormRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (g *GetPaymentFormRequest) Decode(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't decode getPaymentForm#96e6319 to nil") + return fmt.Errorf("can't decode getPaymentForm#90411057 to nil") } if err := b.ConsumeID(GetPaymentFormRequestTypeID); err != nil { - return fmt.Errorf("unable to decode getPaymentForm#96e6319: %w", err) + return fmt.Errorf("unable to decode getPaymentForm#90411057: %w", err) } return g.DecodeBare(b) } @@ -153,25 +153,25 @@ func (g *GetPaymentFormRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (g *GetPaymentFormRequest) DecodeBare(b *bin.Buffer) error { if g == nil { - return fmt.Errorf("can't decode getPaymentForm#96e6319 to nil") + return fmt.Errorf("can't decode getPaymentForm#90411057 to nil") } { value, err := b.Int53() if err != nil { - return fmt.Errorf("unable to decode getPaymentForm#96e6319: field chat_id: %w", err) + return fmt.Errorf("unable to decode getPaymentForm#90411057: field chat_id: %w", err) } g.ChatID = value } { value, err := b.Int53() if err != nil { - return fmt.Errorf("unable to decode getPaymentForm#96e6319: field message_id: %w", err) + return fmt.Errorf("unable to decode getPaymentForm#90411057: field message_id: %w", err) } g.MessageID = value } { if err := g.Theme.Decode(b); err != nil { - return fmt.Errorf("unable to decode getPaymentForm#96e6319: field theme: %w", err) + return fmt.Errorf("unable to decode getPaymentForm#90411057: field theme: %w", err) } } return nil @@ -180,7 +180,7 @@ func (g *GetPaymentFormRequest) DecodeBare(b *bin.Buffer) error { // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (g *GetPaymentFormRequest) EncodeTDLibJSON(b tdjson.Encoder) error { if g == nil { - return fmt.Errorf("can't encode getPaymentForm#96e6319 as nil") + return fmt.Errorf("can't encode getPaymentForm#90411057 as nil") } b.ObjStart() b.PutID("getPaymentForm") @@ -193,7 +193,7 @@ func (g *GetPaymentFormRequest) EncodeTDLibJSON(b tdjson.Encoder) error { b.Comma() b.FieldStart("theme") if err := g.Theme.EncodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to encode getPaymentForm#96e6319: field theme: %w", err) + return fmt.Errorf("unable to encode getPaymentForm#90411057: field theme: %w", err) } b.Comma() b.StripComma() @@ -204,30 +204,30 @@ func (g *GetPaymentFormRequest) EncodeTDLibJSON(b tdjson.Encoder) error { // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (g *GetPaymentFormRequest) DecodeTDLibJSON(b tdjson.Decoder) error { if g == nil { - return fmt.Errorf("can't decode getPaymentForm#96e6319 to nil") + return fmt.Errorf("can't decode getPaymentForm#90411057 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("getPaymentForm"); err != nil { - return fmt.Errorf("unable to decode getPaymentForm#96e6319: %w", err) + return fmt.Errorf("unable to decode getPaymentForm#90411057: %w", err) } case "chat_id": value, err := b.Int53() if err != nil { - return fmt.Errorf("unable to decode getPaymentForm#96e6319: field chat_id: %w", err) + return fmt.Errorf("unable to decode getPaymentForm#90411057: field chat_id: %w", err) } g.ChatID = value case "message_id": value, err := b.Int53() if err != nil { - return fmt.Errorf("unable to decode getPaymentForm#96e6319: field message_id: %w", err) + return fmt.Errorf("unable to decode getPaymentForm#90411057: field message_id: %w", err) } g.MessageID = value case "theme": if err := g.Theme.DecodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to decode getPaymentForm#96e6319: field theme: %w", err) + return fmt.Errorf("unable to decode getPaymentForm#90411057: field theme: %w", err) } default: return b.Skip() @@ -253,14 +253,14 @@ func (g *GetPaymentFormRequest) GetMessageID() (value int64) { } // GetTheme returns value of Theme field. -func (g *GetPaymentFormRequest) GetTheme() (value PaymentFormTheme) { +func (g *GetPaymentFormRequest) GetTheme() (value ThemeParameters) { if g == nil { return } return g.Theme } -// GetPaymentForm invokes method getPaymentForm#96e6319 returning error if any. +// GetPaymentForm invokes method getPaymentForm#90411057 returning error if any. func (c *Client) GetPaymentForm(ctx context.Context, request *GetPaymentFormRequest) (*PaymentForm, error) { var result PaymentForm diff --git a/tdapi/tl_get_saved_notification_sound_gen.go b/tdapi/tl_get_saved_notification_sound_gen.go new file mode 100644 index 0000000000..5f09d0e236 --- /dev/null +++ b/tdapi/tl_get_saved_notification_sound_gen.go @@ -0,0 +1,206 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// GetSavedNotificationSoundRequest represents TL type `getSavedNotificationSound#1b647917`. +type GetSavedNotificationSoundRequest struct { + // Identifier of the notification sound + NotificationSoundID int64 +} + +// GetSavedNotificationSoundRequestTypeID is TL type id of GetSavedNotificationSoundRequest. +const GetSavedNotificationSoundRequestTypeID = 0x1b647917 + +// Ensuring interfaces in compile-time for GetSavedNotificationSoundRequest. +var ( + _ bin.Encoder = &GetSavedNotificationSoundRequest{} + _ bin.Decoder = &GetSavedNotificationSoundRequest{} + _ bin.BareEncoder = &GetSavedNotificationSoundRequest{} + _ bin.BareDecoder = &GetSavedNotificationSoundRequest{} +) + +func (g *GetSavedNotificationSoundRequest) Zero() bool { + if g == nil { + return true + } + if !(g.NotificationSoundID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *GetSavedNotificationSoundRequest) String() string { + if g == nil { + return "GetSavedNotificationSoundRequest(nil)" + } + type Alias GetSavedNotificationSoundRequest + return fmt.Sprintf("GetSavedNotificationSoundRequest%+v", Alias(*g)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*GetSavedNotificationSoundRequest) TypeID() uint32 { + return GetSavedNotificationSoundRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*GetSavedNotificationSoundRequest) TypeName() string { + return "getSavedNotificationSound" +} + +// TypeInfo returns info about TL type. +func (g *GetSavedNotificationSoundRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "getSavedNotificationSound", + ID: GetSavedNotificationSoundRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "NotificationSoundID", + SchemaName: "notification_sound_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *GetSavedNotificationSoundRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode getSavedNotificationSound#1b647917 as nil") + } + b.PutID(GetSavedNotificationSoundRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *GetSavedNotificationSoundRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode getSavedNotificationSound#1b647917 as nil") + } + b.PutLong(g.NotificationSoundID) + return nil +} + +// Decode implements bin.Decoder. +func (g *GetSavedNotificationSoundRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode getSavedNotificationSound#1b647917 to nil") + } + if err := b.ConsumeID(GetSavedNotificationSoundRequestTypeID); err != nil { + return fmt.Errorf("unable to decode getSavedNotificationSound#1b647917: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *GetSavedNotificationSoundRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode getSavedNotificationSound#1b647917 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode getSavedNotificationSound#1b647917: field notification_sound_id: %w", err) + } + g.NotificationSoundID = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (g *GetSavedNotificationSoundRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if g == nil { + return fmt.Errorf("can't encode getSavedNotificationSound#1b647917 as nil") + } + b.ObjStart() + b.PutID("getSavedNotificationSound") + b.Comma() + b.FieldStart("notification_sound_id") + b.PutLong(g.NotificationSoundID) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (g *GetSavedNotificationSoundRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if g == nil { + return fmt.Errorf("can't decode getSavedNotificationSound#1b647917 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("getSavedNotificationSound"); err != nil { + return fmt.Errorf("unable to decode getSavedNotificationSound#1b647917: %w", err) + } + case "notification_sound_id": + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode getSavedNotificationSound#1b647917: field notification_sound_id: %w", err) + } + g.NotificationSoundID = value + default: + return b.Skip() + } + return nil + }) +} + +// GetNotificationSoundID returns value of NotificationSoundID field. +func (g *GetSavedNotificationSoundRequest) GetNotificationSoundID() (value int64) { + if g == nil { + return + } + return g.NotificationSoundID +} + +// GetSavedNotificationSound invokes method getSavedNotificationSound#1b647917 returning error if any. +func (c *Client) GetSavedNotificationSound(ctx context.Context, notificationsoundid int64) (*NotificationSounds, error) { + var result NotificationSounds + + request := &GetSavedNotificationSoundRequest{ + NotificationSoundID: notificationsoundid, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tdapi/tl_get_saved_notification_sounds_gen.go b/tdapi/tl_get_saved_notification_sounds_gen.go new file mode 100644 index 0000000000..81e2d516a6 --- /dev/null +++ b/tdapi/tl_get_saved_notification_sounds_gen.go @@ -0,0 +1,169 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// GetSavedNotificationSoundsRequest represents TL type `getSavedNotificationSounds#c0346fa8`. +type GetSavedNotificationSoundsRequest struct { +} + +// GetSavedNotificationSoundsRequestTypeID is TL type id of GetSavedNotificationSoundsRequest. +const GetSavedNotificationSoundsRequestTypeID = 0xc0346fa8 + +// Ensuring interfaces in compile-time for GetSavedNotificationSoundsRequest. +var ( + _ bin.Encoder = &GetSavedNotificationSoundsRequest{} + _ bin.Decoder = &GetSavedNotificationSoundsRequest{} + _ bin.BareEncoder = &GetSavedNotificationSoundsRequest{} + _ bin.BareDecoder = &GetSavedNotificationSoundsRequest{} +) + +func (g *GetSavedNotificationSoundsRequest) Zero() bool { + if g == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (g *GetSavedNotificationSoundsRequest) String() string { + if g == nil { + return "GetSavedNotificationSoundsRequest(nil)" + } + type Alias GetSavedNotificationSoundsRequest + return fmt.Sprintf("GetSavedNotificationSoundsRequest%+v", Alias(*g)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*GetSavedNotificationSoundsRequest) TypeID() uint32 { + return GetSavedNotificationSoundsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*GetSavedNotificationSoundsRequest) TypeName() string { + return "getSavedNotificationSounds" +} + +// TypeInfo returns info about TL type. +func (g *GetSavedNotificationSoundsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "getSavedNotificationSounds", + ID: GetSavedNotificationSoundsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (g *GetSavedNotificationSoundsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode getSavedNotificationSounds#c0346fa8 as nil") + } + b.PutID(GetSavedNotificationSoundsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *GetSavedNotificationSoundsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode getSavedNotificationSounds#c0346fa8 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (g *GetSavedNotificationSoundsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode getSavedNotificationSounds#c0346fa8 to nil") + } + if err := b.ConsumeID(GetSavedNotificationSoundsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode getSavedNotificationSounds#c0346fa8: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *GetSavedNotificationSoundsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode getSavedNotificationSounds#c0346fa8 to nil") + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (g *GetSavedNotificationSoundsRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if g == nil { + return fmt.Errorf("can't encode getSavedNotificationSounds#c0346fa8 as nil") + } + b.ObjStart() + b.PutID("getSavedNotificationSounds") + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (g *GetSavedNotificationSoundsRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if g == nil { + return fmt.Errorf("can't decode getSavedNotificationSounds#c0346fa8 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("getSavedNotificationSounds"); err != nil { + return fmt.Errorf("unable to decode getSavedNotificationSounds#c0346fa8: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetSavedNotificationSounds invokes method getSavedNotificationSounds#c0346fa8 returning error if any. +func (c *Client) GetSavedNotificationSounds(ctx context.Context) (*NotificationSounds, error) { + var result NotificationSounds + + request := &GetSavedNotificationSoundsRequest{} + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tdapi/tl_get_theme_parameters_json_string_gen.go b/tdapi/tl_get_theme_parameters_json_string_gen.go new file mode 100644 index 0000000000..b723291408 --- /dev/null +++ b/tdapi/tl_get_theme_parameters_json_string_gen.go @@ -0,0 +1,206 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// GetThemeParametersJSONStringRequest represents TL type `getThemeParametersJsonString#91b905f8`. +type GetThemeParametersJSONStringRequest struct { + // Theme parameters to convert to JSON + Theme ThemeParameters +} + +// GetThemeParametersJSONStringRequestTypeID is TL type id of GetThemeParametersJSONStringRequest. +const GetThemeParametersJSONStringRequestTypeID = 0x91b905f8 + +// Ensuring interfaces in compile-time for GetThemeParametersJSONStringRequest. +var ( + _ bin.Encoder = &GetThemeParametersJSONStringRequest{} + _ bin.Decoder = &GetThemeParametersJSONStringRequest{} + _ bin.BareEncoder = &GetThemeParametersJSONStringRequest{} + _ bin.BareDecoder = &GetThemeParametersJSONStringRequest{} +) + +func (g *GetThemeParametersJSONStringRequest) Zero() bool { + if g == nil { + return true + } + if !(g.Theme.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *GetThemeParametersJSONStringRequest) String() string { + if g == nil { + return "GetThemeParametersJSONStringRequest(nil)" + } + type Alias GetThemeParametersJSONStringRequest + return fmt.Sprintf("GetThemeParametersJSONStringRequest%+v", Alias(*g)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*GetThemeParametersJSONStringRequest) TypeID() uint32 { + return GetThemeParametersJSONStringRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*GetThemeParametersJSONStringRequest) TypeName() string { + return "getThemeParametersJsonString" +} + +// TypeInfo returns info about TL type. +func (g *GetThemeParametersJSONStringRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "getThemeParametersJsonString", + ID: GetThemeParametersJSONStringRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Theme", + SchemaName: "theme", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *GetThemeParametersJSONStringRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode getThemeParametersJsonString#91b905f8 as nil") + } + b.PutID(GetThemeParametersJSONStringRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *GetThemeParametersJSONStringRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode getThemeParametersJsonString#91b905f8 as nil") + } + if err := g.Theme.Encode(b); err != nil { + return fmt.Errorf("unable to encode getThemeParametersJsonString#91b905f8: field theme: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (g *GetThemeParametersJSONStringRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode getThemeParametersJsonString#91b905f8 to nil") + } + if err := b.ConsumeID(GetThemeParametersJSONStringRequestTypeID); err != nil { + return fmt.Errorf("unable to decode getThemeParametersJsonString#91b905f8: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *GetThemeParametersJSONStringRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode getThemeParametersJsonString#91b905f8 to nil") + } + { + if err := g.Theme.Decode(b); err != nil { + return fmt.Errorf("unable to decode getThemeParametersJsonString#91b905f8: field theme: %w", err) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (g *GetThemeParametersJSONStringRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if g == nil { + return fmt.Errorf("can't encode getThemeParametersJsonString#91b905f8 as nil") + } + b.ObjStart() + b.PutID("getThemeParametersJsonString") + b.Comma() + b.FieldStart("theme") + if err := g.Theme.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode getThemeParametersJsonString#91b905f8: field theme: %w", err) + } + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (g *GetThemeParametersJSONStringRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if g == nil { + return fmt.Errorf("can't decode getThemeParametersJsonString#91b905f8 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("getThemeParametersJsonString"); err != nil { + return fmt.Errorf("unable to decode getThemeParametersJsonString#91b905f8: %w", err) + } + case "theme": + if err := g.Theme.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode getThemeParametersJsonString#91b905f8: field theme: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetTheme returns value of Theme field. +func (g *GetThemeParametersJSONStringRequest) GetTheme() (value ThemeParameters) { + if g == nil { + return + } + return g.Theme +} + +// GetThemeParametersJSONString invokes method getThemeParametersJsonString#91b905f8 returning error if any. +func (c *Client) GetThemeParametersJSONString(ctx context.Context, theme ThemeParameters) (*Text, error) { + var result Text + + request := &GetThemeParametersJSONStringRequest{ + Theme: theme, + } + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tdapi/tl_get_web_app_url_gen.go b/tdapi/tl_get_web_app_url_gen.go new file mode 100644 index 0000000000..a7ed6cb70b --- /dev/null +++ b/tdapi/tl_get_web_app_url_gen.go @@ -0,0 +1,271 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// GetWebAppURLRequest represents TL type `getWebAppUrl#5f689ab3`. +type GetWebAppURLRequest struct { + // Identifier of the target bot + BotUserID int64 + // The URL from the keyboardButtonTypeWebApp button + URL string + // Preferred web app theme; pass null to use the default theme + Theme ThemeParameters +} + +// GetWebAppURLRequestTypeID is TL type id of GetWebAppURLRequest. +const GetWebAppURLRequestTypeID = 0x5f689ab3 + +// Ensuring interfaces in compile-time for GetWebAppURLRequest. +var ( + _ bin.Encoder = &GetWebAppURLRequest{} + _ bin.Decoder = &GetWebAppURLRequest{} + _ bin.BareEncoder = &GetWebAppURLRequest{} + _ bin.BareDecoder = &GetWebAppURLRequest{} +) + +func (g *GetWebAppURLRequest) Zero() bool { + if g == nil { + return true + } + if !(g.BotUserID == 0) { + return false + } + if !(g.URL == "") { + return false + } + if !(g.Theme.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *GetWebAppURLRequest) String() string { + if g == nil { + return "GetWebAppURLRequest(nil)" + } + type Alias GetWebAppURLRequest + return fmt.Sprintf("GetWebAppURLRequest%+v", Alias(*g)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*GetWebAppURLRequest) TypeID() uint32 { + return GetWebAppURLRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*GetWebAppURLRequest) TypeName() string { + return "getWebAppUrl" +} + +// TypeInfo returns info about TL type. +func (g *GetWebAppURLRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "getWebAppUrl", + ID: GetWebAppURLRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "BotUserID", + SchemaName: "bot_user_id", + }, + { + Name: "URL", + SchemaName: "url", + }, + { + Name: "Theme", + SchemaName: "theme", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *GetWebAppURLRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode getWebAppUrl#5f689ab3 as nil") + } + b.PutID(GetWebAppURLRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *GetWebAppURLRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode getWebAppUrl#5f689ab3 as nil") + } + b.PutInt53(g.BotUserID) + b.PutString(g.URL) + if err := g.Theme.Encode(b); err != nil { + return fmt.Errorf("unable to encode getWebAppUrl#5f689ab3: field theme: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (g *GetWebAppURLRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode getWebAppUrl#5f689ab3 to nil") + } + if err := b.ConsumeID(GetWebAppURLRequestTypeID); err != nil { + return fmt.Errorf("unable to decode getWebAppUrl#5f689ab3: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *GetWebAppURLRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode getWebAppUrl#5f689ab3 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode getWebAppUrl#5f689ab3: field bot_user_id: %w", err) + } + g.BotUserID = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode getWebAppUrl#5f689ab3: field url: %w", err) + } + g.URL = value + } + { + if err := g.Theme.Decode(b); err != nil { + return fmt.Errorf("unable to decode getWebAppUrl#5f689ab3: field theme: %w", err) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (g *GetWebAppURLRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if g == nil { + return fmt.Errorf("can't encode getWebAppUrl#5f689ab3 as nil") + } + b.ObjStart() + b.PutID("getWebAppUrl") + b.Comma() + b.FieldStart("bot_user_id") + b.PutInt53(g.BotUserID) + b.Comma() + b.FieldStart("url") + b.PutString(g.URL) + b.Comma() + b.FieldStart("theme") + if err := g.Theme.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode getWebAppUrl#5f689ab3: field theme: %w", err) + } + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (g *GetWebAppURLRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if g == nil { + return fmt.Errorf("can't decode getWebAppUrl#5f689ab3 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("getWebAppUrl"); err != nil { + return fmt.Errorf("unable to decode getWebAppUrl#5f689ab3: %w", err) + } + case "bot_user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode getWebAppUrl#5f689ab3: field bot_user_id: %w", err) + } + g.BotUserID = value + case "url": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode getWebAppUrl#5f689ab3: field url: %w", err) + } + g.URL = value + case "theme": + if err := g.Theme.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode getWebAppUrl#5f689ab3: field theme: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetBotUserID returns value of BotUserID field. +func (g *GetWebAppURLRequest) GetBotUserID() (value int64) { + if g == nil { + return + } + return g.BotUserID +} + +// GetURL returns value of URL field. +func (g *GetWebAppURLRequest) GetURL() (value string) { + if g == nil { + return + } + return g.URL +} + +// GetTheme returns value of Theme field. +func (g *GetWebAppURLRequest) GetTheme() (value ThemeParameters) { + if g == nil { + return + } + return g.Theme +} + +// GetWebAppURL invokes method getWebAppUrl#5f689ab3 returning error if any. +func (c *Client) GetWebAppURL(ctx context.Context, request *GetWebAppURLRequest) (*HTTPURL, error) { + var result HTTPURL + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tdapi/tl_inline_keyboard_button_type_gen.go b/tdapi/tl_inline_keyboard_button_type_gen.go index 63d0c08c1c..4a9a104306 100644 --- a/tdapi/tl_inline_keyboard_button_type_gen.go +++ b/tdapi/tl_inline_keyboard_button_type_gen.go @@ -199,7 +199,7 @@ func (i *InlineKeyboardButtonTypeURL) GetURL() (value string) { // InlineKeyboardButtonTypeLoginURL represents TL type `inlineKeyboardButtonTypeLoginUrl#b8455fa7`. type InlineKeyboardButtonTypeLoginURL struct { - // An HTTP URL to open + // An HTTP URL to pass to getLoginUrlInfo URL string // Unique button identifier ID int64 @@ -431,6 +431,172 @@ func (i *InlineKeyboardButtonTypeLoginURL) GetForwardText() (value string) { return i.ForwardText } +// InlineKeyboardButtonTypeWebApp represents TL type `inlineKeyboardButtonTypeWebApp#96a685c8`. +type InlineKeyboardButtonTypeWebApp struct { + // An HTTP URL to pass to openWebApp + URL string +} + +// InlineKeyboardButtonTypeWebAppTypeID is TL type id of InlineKeyboardButtonTypeWebApp. +const InlineKeyboardButtonTypeWebAppTypeID = 0x96a685c8 + +// construct implements constructor of InlineKeyboardButtonTypeClass. +func (i InlineKeyboardButtonTypeWebApp) construct() InlineKeyboardButtonTypeClass { return &i } + +// Ensuring interfaces in compile-time for InlineKeyboardButtonTypeWebApp. +var ( + _ bin.Encoder = &InlineKeyboardButtonTypeWebApp{} + _ bin.Decoder = &InlineKeyboardButtonTypeWebApp{} + _ bin.BareEncoder = &InlineKeyboardButtonTypeWebApp{} + _ bin.BareDecoder = &InlineKeyboardButtonTypeWebApp{} + + _ InlineKeyboardButtonTypeClass = &InlineKeyboardButtonTypeWebApp{} +) + +func (i *InlineKeyboardButtonTypeWebApp) Zero() bool { + if i == nil { + return true + } + if !(i.URL == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InlineKeyboardButtonTypeWebApp) String() string { + if i == nil { + return "InlineKeyboardButtonTypeWebApp(nil)" + } + type Alias InlineKeyboardButtonTypeWebApp + return fmt.Sprintf("InlineKeyboardButtonTypeWebApp%+v", Alias(*i)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InlineKeyboardButtonTypeWebApp) TypeID() uint32 { + return InlineKeyboardButtonTypeWebAppTypeID +} + +// TypeName returns name of type in TL schema. +func (*InlineKeyboardButtonTypeWebApp) TypeName() string { + return "inlineKeyboardButtonTypeWebApp" +} + +// TypeInfo returns info about TL type. +func (i *InlineKeyboardButtonTypeWebApp) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "inlineKeyboardButtonTypeWebApp", + ID: InlineKeyboardButtonTypeWebAppTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "URL", + SchemaName: "url", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (i *InlineKeyboardButtonTypeWebApp) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inlineKeyboardButtonTypeWebApp#96a685c8 as nil") + } + b.PutID(InlineKeyboardButtonTypeWebAppTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InlineKeyboardButtonTypeWebApp) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode inlineKeyboardButtonTypeWebApp#96a685c8 as nil") + } + b.PutString(i.URL) + return nil +} + +// Decode implements bin.Decoder. +func (i *InlineKeyboardButtonTypeWebApp) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inlineKeyboardButtonTypeWebApp#96a685c8 to nil") + } + if err := b.ConsumeID(InlineKeyboardButtonTypeWebAppTypeID); err != nil { + return fmt.Errorf("unable to decode inlineKeyboardButtonTypeWebApp#96a685c8: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InlineKeyboardButtonTypeWebApp) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode inlineKeyboardButtonTypeWebApp#96a685c8 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode inlineKeyboardButtonTypeWebApp#96a685c8: field url: %w", err) + } + i.URL = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (i *InlineKeyboardButtonTypeWebApp) EncodeTDLibJSON(b tdjson.Encoder) error { + if i == nil { + return fmt.Errorf("can't encode inlineKeyboardButtonTypeWebApp#96a685c8 as nil") + } + b.ObjStart() + b.PutID("inlineKeyboardButtonTypeWebApp") + b.Comma() + b.FieldStart("url") + b.PutString(i.URL) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (i *InlineKeyboardButtonTypeWebApp) DecodeTDLibJSON(b tdjson.Decoder) error { + if i == nil { + return fmt.Errorf("can't decode inlineKeyboardButtonTypeWebApp#96a685c8 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("inlineKeyboardButtonTypeWebApp"); err != nil { + return fmt.Errorf("unable to decode inlineKeyboardButtonTypeWebApp#96a685c8: %w", err) + } + case "url": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode inlineKeyboardButtonTypeWebApp#96a685c8: field url: %w", err) + } + i.URL = value + default: + return b.Skip() + } + return nil + }) +} + +// GetURL returns value of URL field. +func (i *InlineKeyboardButtonTypeWebApp) GetURL() (value string) { + if i == nil { + return + } + return i.URL +} + // InlineKeyboardButtonTypeCallback represents TL type `inlineKeyboardButtonTypeCallback#bccb7bfd`. type InlineKeyboardButtonTypeCallback struct { // Data to be sent to the bot via a callback query @@ -1406,6 +1572,7 @@ const InlineKeyboardButtonTypeClassName = "InlineKeyboardButtonType" // switch v := g.(type) { // case *tdapi.InlineKeyboardButtonTypeURL: // inlineKeyboardButtonTypeUrl#4365beac // case *tdapi.InlineKeyboardButtonTypeLoginURL: // inlineKeyboardButtonTypeLoginUrl#b8455fa7 +// case *tdapi.InlineKeyboardButtonTypeWebApp: // inlineKeyboardButtonTypeWebApp#96a685c8 // case *tdapi.InlineKeyboardButtonTypeCallback: // inlineKeyboardButtonTypeCallback#bccb7bfd // case *tdapi.InlineKeyboardButtonTypeCallbackWithPassword: // inlineKeyboardButtonTypeCallbackWithPassword#361f4248 // case *tdapi.InlineKeyboardButtonTypeCallbackGame: // inlineKeyboardButtonTypeCallbackGame#e9255468 @@ -1457,6 +1624,13 @@ func DecodeInlineKeyboardButtonType(buf *bin.Buffer) (InlineKeyboardButtonTypeCl return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err) } return &v, nil + case InlineKeyboardButtonTypeWebAppTypeID: + // Decoding inlineKeyboardButtonTypeWebApp#96a685c8. + v := InlineKeyboardButtonTypeWebApp{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err) + } + return &v, nil case InlineKeyboardButtonTypeCallbackTypeID: // Decoding inlineKeyboardButtonTypeCallback#bccb7bfd. v := InlineKeyboardButtonTypeCallback{} @@ -1525,6 +1699,13 @@ func DecodeTDLibJSONInlineKeyboardButtonType(buf tdjson.Decoder) (InlineKeyboard return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err) } return &v, nil + case "inlineKeyboardButtonTypeWebApp": + // Decoding inlineKeyboardButtonTypeWebApp#96a685c8. + v := InlineKeyboardButtonTypeWebApp{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode InlineKeyboardButtonTypeClass: %w", err) + } + return &v, nil case "inlineKeyboardButtonTypeCallback": // Decoding inlineKeyboardButtonTypeCallback#bccb7bfd. v := InlineKeyboardButtonTypeCallback{} diff --git a/tdapi/tl_internal_link_type_gen.go b/tdapi/tl_internal_link_type_gen.go index 2e56231bcf..cec7e9a185 100644 --- a/tdapi/tl_internal_link_type_gen.go +++ b/tdapi/tl_internal_link_type_gen.go @@ -162,6 +162,250 @@ func (i *InternalLinkTypeActiveSessions) DecodeTDLibJSON(b tdjson.Decoder) error }) } +// InternalLinkTypeAttachmentMenuBot represents TL type `internalLinkTypeAttachmentMenuBot#63932054`. +type InternalLinkTypeAttachmentMenuBot struct { + // An internal link pointing to a chat; may be null if the current chat needs to be kept + ChatLink InternalLinkTypeClass + // Username of the bot + BotUsername string + // URL to be passed to openWebApp + URL string +} + +// InternalLinkTypeAttachmentMenuBotTypeID is TL type id of InternalLinkTypeAttachmentMenuBot. +const InternalLinkTypeAttachmentMenuBotTypeID = 0x63932054 + +// construct implements constructor of InternalLinkTypeClass. +func (i InternalLinkTypeAttachmentMenuBot) construct() InternalLinkTypeClass { return &i } + +// Ensuring interfaces in compile-time for InternalLinkTypeAttachmentMenuBot. +var ( + _ bin.Encoder = &InternalLinkTypeAttachmentMenuBot{} + _ bin.Decoder = &InternalLinkTypeAttachmentMenuBot{} + _ bin.BareEncoder = &InternalLinkTypeAttachmentMenuBot{} + _ bin.BareDecoder = &InternalLinkTypeAttachmentMenuBot{} + + _ InternalLinkTypeClass = &InternalLinkTypeAttachmentMenuBot{} +) + +func (i *InternalLinkTypeAttachmentMenuBot) Zero() bool { + if i == nil { + return true + } + if !(i.ChatLink == nil) { + return false + } + if !(i.BotUsername == "") { + return false + } + if !(i.URL == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InternalLinkTypeAttachmentMenuBot) String() string { + if i == nil { + return "InternalLinkTypeAttachmentMenuBot(nil)" + } + type Alias InternalLinkTypeAttachmentMenuBot + return fmt.Sprintf("InternalLinkTypeAttachmentMenuBot%+v", Alias(*i)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InternalLinkTypeAttachmentMenuBot) TypeID() uint32 { + return InternalLinkTypeAttachmentMenuBotTypeID +} + +// TypeName returns name of type in TL schema. +func (*InternalLinkTypeAttachmentMenuBot) TypeName() string { + return "internalLinkTypeAttachmentMenuBot" +} + +// TypeInfo returns info about TL type. +func (i *InternalLinkTypeAttachmentMenuBot) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "internalLinkTypeAttachmentMenuBot", + ID: InternalLinkTypeAttachmentMenuBotTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ChatLink", + SchemaName: "chat_link", + }, + { + Name: "BotUsername", + SchemaName: "bot_username", + }, + { + Name: "URL", + SchemaName: "url", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (i *InternalLinkTypeAttachmentMenuBot) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode internalLinkTypeAttachmentMenuBot#63932054 as nil") + } + b.PutID(InternalLinkTypeAttachmentMenuBotTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InternalLinkTypeAttachmentMenuBot) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode internalLinkTypeAttachmentMenuBot#63932054 as nil") + } + if i.ChatLink == nil { + return fmt.Errorf("unable to encode internalLinkTypeAttachmentMenuBot#63932054: field chat_link is nil") + } + if err := i.ChatLink.Encode(b); err != nil { + return fmt.Errorf("unable to encode internalLinkTypeAttachmentMenuBot#63932054: field chat_link: %w", err) + } + b.PutString(i.BotUsername) + b.PutString(i.URL) + return nil +} + +// Decode implements bin.Decoder. +func (i *InternalLinkTypeAttachmentMenuBot) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode internalLinkTypeAttachmentMenuBot#63932054 to nil") + } + if err := b.ConsumeID(InternalLinkTypeAttachmentMenuBotTypeID); err != nil { + return fmt.Errorf("unable to decode internalLinkTypeAttachmentMenuBot#63932054: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InternalLinkTypeAttachmentMenuBot) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode internalLinkTypeAttachmentMenuBot#63932054 to nil") + } + { + value, err := DecodeInternalLinkType(b) + if err != nil { + return fmt.Errorf("unable to decode internalLinkTypeAttachmentMenuBot#63932054: field chat_link: %w", err) + } + i.ChatLink = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode internalLinkTypeAttachmentMenuBot#63932054: field bot_username: %w", err) + } + i.BotUsername = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode internalLinkTypeAttachmentMenuBot#63932054: field url: %w", err) + } + i.URL = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (i *InternalLinkTypeAttachmentMenuBot) EncodeTDLibJSON(b tdjson.Encoder) error { + if i == nil { + return fmt.Errorf("can't encode internalLinkTypeAttachmentMenuBot#63932054 as nil") + } + b.ObjStart() + b.PutID("internalLinkTypeAttachmentMenuBot") + b.Comma() + b.FieldStart("chat_link") + if i.ChatLink == nil { + return fmt.Errorf("unable to encode internalLinkTypeAttachmentMenuBot#63932054: field chat_link is nil") + } + if err := i.ChatLink.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode internalLinkTypeAttachmentMenuBot#63932054: field chat_link: %w", err) + } + b.Comma() + b.FieldStart("bot_username") + b.PutString(i.BotUsername) + b.Comma() + b.FieldStart("url") + b.PutString(i.URL) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (i *InternalLinkTypeAttachmentMenuBot) DecodeTDLibJSON(b tdjson.Decoder) error { + if i == nil { + return fmt.Errorf("can't decode internalLinkTypeAttachmentMenuBot#63932054 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("internalLinkTypeAttachmentMenuBot"); err != nil { + return fmt.Errorf("unable to decode internalLinkTypeAttachmentMenuBot#63932054: %w", err) + } + case "chat_link": + value, err := DecodeTDLibJSONInternalLinkType(b) + if err != nil { + return fmt.Errorf("unable to decode internalLinkTypeAttachmentMenuBot#63932054: field chat_link: %w", err) + } + i.ChatLink = value + case "bot_username": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode internalLinkTypeAttachmentMenuBot#63932054: field bot_username: %w", err) + } + i.BotUsername = value + case "url": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode internalLinkTypeAttachmentMenuBot#63932054: field url: %w", err) + } + i.URL = value + default: + return b.Skip() + } + return nil + }) +} + +// GetChatLink returns value of ChatLink field. +func (i *InternalLinkTypeAttachmentMenuBot) GetChatLink() (value InternalLinkTypeClass) { + if i == nil { + return + } + return i.ChatLink +} + +// GetBotUsername returns value of BotUsername field. +func (i *InternalLinkTypeAttachmentMenuBot) GetBotUsername() (value string) { + if i == nil { + return + } + return i.BotUsername +} + +// GetURL returns value of URL field. +func (i *InternalLinkTypeAttachmentMenuBot) GetURL() (value string) { + if i == nil { + return + } + return i.URL +} + // InternalLinkTypeAuthenticationCode represents TL type `internalLinkTypeAuthenticationCode#f3874ff2`. type InternalLinkTypeAuthenticationCode struct { // The authentication code @@ -694,16 +938,18 @@ func (i *InternalLinkTypeBotStart) GetStartParameter() (value string) { return i.StartParameter } -// InternalLinkTypeBotStartInGroup represents TL type `internalLinkTypeBotStartInGroup#c201649c`. +// InternalLinkTypeBotStartInGroup represents TL type `internalLinkTypeBotStartInGroup#ca0d8cce`. type InternalLinkTypeBotStartInGroup struct { // Username of the bot BotUsername string // The parameter to be passed to sendBotStartMessage StartParameter string + // Expected administrator rights for the bot; may be null + AdministratorRights ChatAdministratorRights } // InternalLinkTypeBotStartInGroupTypeID is TL type id of InternalLinkTypeBotStartInGroup. -const InternalLinkTypeBotStartInGroupTypeID = 0xc201649c +const InternalLinkTypeBotStartInGroupTypeID = 0xca0d8cce // construct implements constructor of InternalLinkTypeClass. func (i InternalLinkTypeBotStartInGroup) construct() InternalLinkTypeClass { return &i } @@ -728,6 +974,9 @@ func (i *InternalLinkTypeBotStartInGroup) Zero() bool { if !(i.StartParameter == "") { return false } + if !(i.AdministratorRights.Zero()) { + return false + } return true } @@ -772,6 +1021,10 @@ func (i *InternalLinkTypeBotStartInGroup) TypeInfo() tdp.Type { Name: "StartParameter", SchemaName: "start_parameter", }, + { + Name: "AdministratorRights", + SchemaName: "administrator_rights", + }, } return typ } @@ -779,7 +1032,7 @@ func (i *InternalLinkTypeBotStartInGroup) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (i *InternalLinkTypeBotStartInGroup) Encode(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't encode internalLinkTypeBotStartInGroup#c201649c as nil") + return fmt.Errorf("can't encode internalLinkTypeBotStartInGroup#ca0d8cce as nil") } b.PutID(InternalLinkTypeBotStartInGroupTypeID) return i.EncodeBare(b) @@ -788,20 +1041,23 @@ func (i *InternalLinkTypeBotStartInGroup) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (i *InternalLinkTypeBotStartInGroup) EncodeBare(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't encode internalLinkTypeBotStartInGroup#c201649c as nil") + return fmt.Errorf("can't encode internalLinkTypeBotStartInGroup#ca0d8cce as nil") } b.PutString(i.BotUsername) b.PutString(i.StartParameter) + if err := i.AdministratorRights.Encode(b); err != nil { + return fmt.Errorf("unable to encode internalLinkTypeBotStartInGroup#ca0d8cce: field administrator_rights: %w", err) + } return nil } // Decode implements bin.Decoder. func (i *InternalLinkTypeBotStartInGroup) Decode(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't decode internalLinkTypeBotStartInGroup#c201649c to nil") + return fmt.Errorf("can't decode internalLinkTypeBotStartInGroup#ca0d8cce to nil") } if err := b.ConsumeID(InternalLinkTypeBotStartInGroupTypeID); err != nil { - return fmt.Errorf("unable to decode internalLinkTypeBotStartInGroup#c201649c: %w", err) + return fmt.Errorf("unable to decode internalLinkTypeBotStartInGroup#ca0d8cce: %w", err) } return i.DecodeBare(b) } @@ -809,29 +1065,34 @@ func (i *InternalLinkTypeBotStartInGroup) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (i *InternalLinkTypeBotStartInGroup) DecodeBare(b *bin.Buffer) error { if i == nil { - return fmt.Errorf("can't decode internalLinkTypeBotStartInGroup#c201649c to nil") + return fmt.Errorf("can't decode internalLinkTypeBotStartInGroup#ca0d8cce to nil") } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode internalLinkTypeBotStartInGroup#c201649c: field bot_username: %w", err) + return fmt.Errorf("unable to decode internalLinkTypeBotStartInGroup#ca0d8cce: field bot_username: %w", err) } i.BotUsername = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode internalLinkTypeBotStartInGroup#c201649c: field start_parameter: %w", err) + return fmt.Errorf("unable to decode internalLinkTypeBotStartInGroup#ca0d8cce: field start_parameter: %w", err) } i.StartParameter = value } + { + if err := i.AdministratorRights.Decode(b); err != nil { + return fmt.Errorf("unable to decode internalLinkTypeBotStartInGroup#ca0d8cce: field administrator_rights: %w", err) + } + } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (i *InternalLinkTypeBotStartInGroup) EncodeTDLibJSON(b tdjson.Encoder) error { if i == nil { - return fmt.Errorf("can't encode internalLinkTypeBotStartInGroup#c201649c as nil") + return fmt.Errorf("can't encode internalLinkTypeBotStartInGroup#ca0d8cce as nil") } b.ObjStart() b.PutID("internalLinkTypeBotStartInGroup") @@ -842,6 +1103,11 @@ func (i *InternalLinkTypeBotStartInGroup) EncodeTDLibJSON(b tdjson.Encoder) erro b.FieldStart("start_parameter") b.PutString(i.StartParameter) b.Comma() + b.FieldStart("administrator_rights") + if err := i.AdministratorRights.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode internalLinkTypeBotStartInGroup#ca0d8cce: field administrator_rights: %w", err) + } + b.Comma() b.StripComma() b.ObjEnd() return nil @@ -850,27 +1116,31 @@ func (i *InternalLinkTypeBotStartInGroup) EncodeTDLibJSON(b tdjson.Encoder) erro // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (i *InternalLinkTypeBotStartInGroup) DecodeTDLibJSON(b tdjson.Decoder) error { if i == nil { - return fmt.Errorf("can't decode internalLinkTypeBotStartInGroup#c201649c to nil") + return fmt.Errorf("can't decode internalLinkTypeBotStartInGroup#ca0d8cce to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("internalLinkTypeBotStartInGroup"); err != nil { - return fmt.Errorf("unable to decode internalLinkTypeBotStartInGroup#c201649c: %w", err) + return fmt.Errorf("unable to decode internalLinkTypeBotStartInGroup#ca0d8cce: %w", err) } case "bot_username": value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode internalLinkTypeBotStartInGroup#c201649c: field bot_username: %w", err) + return fmt.Errorf("unable to decode internalLinkTypeBotStartInGroup#ca0d8cce: field bot_username: %w", err) } i.BotUsername = value case "start_parameter": value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode internalLinkTypeBotStartInGroup#c201649c: field start_parameter: %w", err) + return fmt.Errorf("unable to decode internalLinkTypeBotStartInGroup#ca0d8cce: field start_parameter: %w", err) } i.StartParameter = value + case "administrator_rights": + if err := i.AdministratorRights.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode internalLinkTypeBotStartInGroup#ca0d8cce: field administrator_rights: %w", err) + } default: return b.Skip() } @@ -894,6 +1164,214 @@ func (i *InternalLinkTypeBotStartInGroup) GetStartParameter() (value string) { return i.StartParameter } +// GetAdministratorRights returns value of AdministratorRights field. +func (i *InternalLinkTypeBotStartInGroup) GetAdministratorRights() (value ChatAdministratorRights) { + if i == nil { + return + } + return i.AdministratorRights +} + +// InternalLinkTypeBotAddToChannel represents TL type `internalLinkTypeBotAddToChannel#538ac2c0`. +type InternalLinkTypeBotAddToChannel struct { + // Username of the bot + BotUsername string + // Expected administrator rights for the bot + AdministratorRights ChatAdministratorRights +} + +// InternalLinkTypeBotAddToChannelTypeID is TL type id of InternalLinkTypeBotAddToChannel. +const InternalLinkTypeBotAddToChannelTypeID = 0x538ac2c0 + +// construct implements constructor of InternalLinkTypeClass. +func (i InternalLinkTypeBotAddToChannel) construct() InternalLinkTypeClass { return &i } + +// Ensuring interfaces in compile-time for InternalLinkTypeBotAddToChannel. +var ( + _ bin.Encoder = &InternalLinkTypeBotAddToChannel{} + _ bin.Decoder = &InternalLinkTypeBotAddToChannel{} + _ bin.BareEncoder = &InternalLinkTypeBotAddToChannel{} + _ bin.BareDecoder = &InternalLinkTypeBotAddToChannel{} + + _ InternalLinkTypeClass = &InternalLinkTypeBotAddToChannel{} +) + +func (i *InternalLinkTypeBotAddToChannel) Zero() bool { + if i == nil { + return true + } + if !(i.BotUsername == "") { + return false + } + if !(i.AdministratorRights.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InternalLinkTypeBotAddToChannel) String() string { + if i == nil { + return "InternalLinkTypeBotAddToChannel(nil)" + } + type Alias InternalLinkTypeBotAddToChannel + return fmt.Sprintf("InternalLinkTypeBotAddToChannel%+v", Alias(*i)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InternalLinkTypeBotAddToChannel) TypeID() uint32 { + return InternalLinkTypeBotAddToChannelTypeID +} + +// TypeName returns name of type in TL schema. +func (*InternalLinkTypeBotAddToChannel) TypeName() string { + return "internalLinkTypeBotAddToChannel" +} + +// TypeInfo returns info about TL type. +func (i *InternalLinkTypeBotAddToChannel) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "internalLinkTypeBotAddToChannel", + ID: InternalLinkTypeBotAddToChannelTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "BotUsername", + SchemaName: "bot_username", + }, + { + Name: "AdministratorRights", + SchemaName: "administrator_rights", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (i *InternalLinkTypeBotAddToChannel) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode internalLinkTypeBotAddToChannel#538ac2c0 as nil") + } + b.PutID(InternalLinkTypeBotAddToChannelTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InternalLinkTypeBotAddToChannel) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode internalLinkTypeBotAddToChannel#538ac2c0 as nil") + } + b.PutString(i.BotUsername) + if err := i.AdministratorRights.Encode(b); err != nil { + return fmt.Errorf("unable to encode internalLinkTypeBotAddToChannel#538ac2c0: field administrator_rights: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (i *InternalLinkTypeBotAddToChannel) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode internalLinkTypeBotAddToChannel#538ac2c0 to nil") + } + if err := b.ConsumeID(InternalLinkTypeBotAddToChannelTypeID); err != nil { + return fmt.Errorf("unable to decode internalLinkTypeBotAddToChannel#538ac2c0: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InternalLinkTypeBotAddToChannel) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode internalLinkTypeBotAddToChannel#538ac2c0 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode internalLinkTypeBotAddToChannel#538ac2c0: field bot_username: %w", err) + } + i.BotUsername = value + } + { + if err := i.AdministratorRights.Decode(b); err != nil { + return fmt.Errorf("unable to decode internalLinkTypeBotAddToChannel#538ac2c0: field administrator_rights: %w", err) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (i *InternalLinkTypeBotAddToChannel) EncodeTDLibJSON(b tdjson.Encoder) error { + if i == nil { + return fmt.Errorf("can't encode internalLinkTypeBotAddToChannel#538ac2c0 as nil") + } + b.ObjStart() + b.PutID("internalLinkTypeBotAddToChannel") + b.Comma() + b.FieldStart("bot_username") + b.PutString(i.BotUsername) + b.Comma() + b.FieldStart("administrator_rights") + if err := i.AdministratorRights.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode internalLinkTypeBotAddToChannel#538ac2c0: field administrator_rights: %w", err) + } + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (i *InternalLinkTypeBotAddToChannel) DecodeTDLibJSON(b tdjson.Decoder) error { + if i == nil { + return fmt.Errorf("can't decode internalLinkTypeBotAddToChannel#538ac2c0 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("internalLinkTypeBotAddToChannel"); err != nil { + return fmt.Errorf("unable to decode internalLinkTypeBotAddToChannel#538ac2c0: %w", err) + } + case "bot_username": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode internalLinkTypeBotAddToChannel#538ac2c0: field bot_username: %w", err) + } + i.BotUsername = value + case "administrator_rights": + if err := i.AdministratorRights.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode internalLinkTypeBotAddToChannel#538ac2c0: field administrator_rights: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetBotUsername returns value of BotUsername field. +func (i *InternalLinkTypeBotAddToChannel) GetBotUsername() (value string) { + if i == nil { + return + } + return i.BotUsername +} + +// GetAdministratorRights returns value of AdministratorRights field. +func (i *InternalLinkTypeBotAddToChannel) GetAdministratorRights() (value ChatAdministratorRights) { + if i == nil { + return + } + return i.AdministratorRights +} + // InternalLinkTypeChangePhoneNumber represents TL type `internalLinkTypeChangePhoneNumber#f0275b01`. type InternalLinkTypeChangePhoneNumber struct { } @@ -4668,10 +5146,12 @@ const InternalLinkTypeClassName = "InternalLinkType" // } // switch v := g.(type) { // case *tdapi.InternalLinkTypeActiveSessions: // internalLinkTypeActiveSessions#706bbbad +// case *tdapi.InternalLinkTypeAttachmentMenuBot: // internalLinkTypeAttachmentMenuBot#63932054 // case *tdapi.InternalLinkTypeAuthenticationCode: // internalLinkTypeAuthenticationCode#f3874ff2 // case *tdapi.InternalLinkTypeBackground: // internalLinkTypeBackground#b0d2908 // case *tdapi.InternalLinkTypeBotStart: // internalLinkTypeBotStart#b812d93d -// case *tdapi.InternalLinkTypeBotStartInGroup: // internalLinkTypeBotStartInGroup#c201649c +// case *tdapi.InternalLinkTypeBotStartInGroup: // internalLinkTypeBotStartInGroup#ca0d8cce +// case *tdapi.InternalLinkTypeBotAddToChannel: // internalLinkTypeBotAddToChannel#538ac2c0 // case *tdapi.InternalLinkTypeChangePhoneNumber: // internalLinkTypeChangePhoneNumber#f0275b01 // case *tdapi.InternalLinkTypeChatInvite: // internalLinkTypeChatInvite#198c3cd9 // case *tdapi.InternalLinkTypeFilterSettings: // internalLinkTypeFilterSettings#5981179b @@ -4732,6 +5212,13 @@ func DecodeInternalLinkType(buf *bin.Buffer) (InternalLinkTypeClass, error) { return nil, fmt.Errorf("unable to decode InternalLinkTypeClass: %w", err) } return &v, nil + case InternalLinkTypeAttachmentMenuBotTypeID: + // Decoding internalLinkTypeAttachmentMenuBot#63932054. + v := InternalLinkTypeAttachmentMenuBot{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InternalLinkTypeClass: %w", err) + } + return &v, nil case InternalLinkTypeAuthenticationCodeTypeID: // Decoding internalLinkTypeAuthenticationCode#f3874ff2. v := InternalLinkTypeAuthenticationCode{} @@ -4754,12 +5241,19 @@ func DecodeInternalLinkType(buf *bin.Buffer) (InternalLinkTypeClass, error) { } return &v, nil case InternalLinkTypeBotStartInGroupTypeID: - // Decoding internalLinkTypeBotStartInGroup#c201649c. + // Decoding internalLinkTypeBotStartInGroup#ca0d8cce. v := InternalLinkTypeBotStartInGroup{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode InternalLinkTypeClass: %w", err) } return &v, nil + case InternalLinkTypeBotAddToChannelTypeID: + // Decoding internalLinkTypeBotAddToChannel#538ac2c0. + v := InternalLinkTypeBotAddToChannel{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InternalLinkTypeClass: %w", err) + } + return &v, nil case InternalLinkTypeChangePhoneNumberTypeID: // Decoding internalLinkTypeChangePhoneNumber#f0275b01. v := InternalLinkTypeChangePhoneNumber{} @@ -4933,6 +5427,13 @@ func DecodeTDLibJSONInternalLinkType(buf tdjson.Decoder) (InternalLinkTypeClass, return nil, fmt.Errorf("unable to decode InternalLinkTypeClass: %w", err) } return &v, nil + case "internalLinkTypeAttachmentMenuBot": + // Decoding internalLinkTypeAttachmentMenuBot#63932054. + v := InternalLinkTypeAttachmentMenuBot{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode InternalLinkTypeClass: %w", err) + } + return &v, nil case "internalLinkTypeAuthenticationCode": // Decoding internalLinkTypeAuthenticationCode#f3874ff2. v := InternalLinkTypeAuthenticationCode{} @@ -4955,12 +5456,19 @@ func DecodeTDLibJSONInternalLinkType(buf tdjson.Decoder) (InternalLinkTypeClass, } return &v, nil case "internalLinkTypeBotStartInGroup": - // Decoding internalLinkTypeBotStartInGroup#c201649c. + // Decoding internalLinkTypeBotStartInGroup#ca0d8cce. v := InternalLinkTypeBotStartInGroup{} if err := v.DecodeTDLibJSON(buf); err != nil { return nil, fmt.Errorf("unable to decode InternalLinkTypeClass: %w", err) } return &v, nil + case "internalLinkTypeBotAddToChannel": + // Decoding internalLinkTypeBotAddToChannel#538ac2c0. + v := InternalLinkTypeBotAddToChannel{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode InternalLinkTypeClass: %w", err) + } + return &v, nil case "internalLinkTypeChangePhoneNumber": // Decoding internalLinkTypeChangePhoneNumber#f0275b01. v := InternalLinkTypeChangePhoneNumber{} diff --git a/tdapi/tl_keyboard_button_type_gen.go b/tdapi/tl_keyboard_button_type_gen.go index 6a69bc9bf3..7abfad2002 100644 --- a/tdapi/tl_keyboard_button_type_gen.go +++ b/tdapi/tl_keyboard_button_type_gen.go @@ -624,6 +624,172 @@ func (k *KeyboardButtonTypeRequestPoll) GetForceQuiz() (value bool) { return k.ForceQuiz } +// KeyboardButtonTypeWebApp represents TL type `keyboardButtonTypeWebApp#70c8ff62`. +type KeyboardButtonTypeWebApp struct { + // An HTTP URL to pass to getWebAppUrl + URL string +} + +// KeyboardButtonTypeWebAppTypeID is TL type id of KeyboardButtonTypeWebApp. +const KeyboardButtonTypeWebAppTypeID = 0x70c8ff62 + +// construct implements constructor of KeyboardButtonTypeClass. +func (k KeyboardButtonTypeWebApp) construct() KeyboardButtonTypeClass { return &k } + +// Ensuring interfaces in compile-time for KeyboardButtonTypeWebApp. +var ( + _ bin.Encoder = &KeyboardButtonTypeWebApp{} + _ bin.Decoder = &KeyboardButtonTypeWebApp{} + _ bin.BareEncoder = &KeyboardButtonTypeWebApp{} + _ bin.BareDecoder = &KeyboardButtonTypeWebApp{} + + _ KeyboardButtonTypeClass = &KeyboardButtonTypeWebApp{} +) + +func (k *KeyboardButtonTypeWebApp) Zero() bool { + if k == nil { + return true + } + if !(k.URL == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (k *KeyboardButtonTypeWebApp) String() string { + if k == nil { + return "KeyboardButtonTypeWebApp(nil)" + } + type Alias KeyboardButtonTypeWebApp + return fmt.Sprintf("KeyboardButtonTypeWebApp%+v", Alias(*k)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*KeyboardButtonTypeWebApp) TypeID() uint32 { + return KeyboardButtonTypeWebAppTypeID +} + +// TypeName returns name of type in TL schema. +func (*KeyboardButtonTypeWebApp) TypeName() string { + return "keyboardButtonTypeWebApp" +} + +// TypeInfo returns info about TL type. +func (k *KeyboardButtonTypeWebApp) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "keyboardButtonTypeWebApp", + ID: KeyboardButtonTypeWebAppTypeID, + } + if k == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "URL", + SchemaName: "url", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (k *KeyboardButtonTypeWebApp) Encode(b *bin.Buffer) error { + if k == nil { + return fmt.Errorf("can't encode keyboardButtonTypeWebApp#70c8ff62 as nil") + } + b.PutID(KeyboardButtonTypeWebAppTypeID) + return k.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (k *KeyboardButtonTypeWebApp) EncodeBare(b *bin.Buffer) error { + if k == nil { + return fmt.Errorf("can't encode keyboardButtonTypeWebApp#70c8ff62 as nil") + } + b.PutString(k.URL) + return nil +} + +// Decode implements bin.Decoder. +func (k *KeyboardButtonTypeWebApp) Decode(b *bin.Buffer) error { + if k == nil { + return fmt.Errorf("can't decode keyboardButtonTypeWebApp#70c8ff62 to nil") + } + if err := b.ConsumeID(KeyboardButtonTypeWebAppTypeID); err != nil { + return fmt.Errorf("unable to decode keyboardButtonTypeWebApp#70c8ff62: %w", err) + } + return k.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (k *KeyboardButtonTypeWebApp) DecodeBare(b *bin.Buffer) error { + if k == nil { + return fmt.Errorf("can't decode keyboardButtonTypeWebApp#70c8ff62 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode keyboardButtonTypeWebApp#70c8ff62: field url: %w", err) + } + k.URL = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (k *KeyboardButtonTypeWebApp) EncodeTDLibJSON(b tdjson.Encoder) error { + if k == nil { + return fmt.Errorf("can't encode keyboardButtonTypeWebApp#70c8ff62 as nil") + } + b.ObjStart() + b.PutID("keyboardButtonTypeWebApp") + b.Comma() + b.FieldStart("url") + b.PutString(k.URL) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (k *KeyboardButtonTypeWebApp) DecodeTDLibJSON(b tdjson.Decoder) error { + if k == nil { + return fmt.Errorf("can't decode keyboardButtonTypeWebApp#70c8ff62 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("keyboardButtonTypeWebApp"); err != nil { + return fmt.Errorf("unable to decode keyboardButtonTypeWebApp#70c8ff62: %w", err) + } + case "url": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode keyboardButtonTypeWebApp#70c8ff62: field url: %w", err) + } + k.URL = value + default: + return b.Skip() + } + return nil + }) +} + +// GetURL returns value of URL field. +func (k *KeyboardButtonTypeWebApp) GetURL() (value string) { + if k == nil { + return + } + return k.URL +} + // KeyboardButtonTypeClassName is schema name of KeyboardButtonTypeClass. const KeyboardButtonTypeClassName = "KeyboardButtonType" @@ -639,6 +805,7 @@ const KeyboardButtonTypeClassName = "KeyboardButtonType" // case *tdapi.KeyboardButtonTypeRequestPhoneNumber: // keyboardButtonTypeRequestPhoneNumber#a4d9b7b9 // case *tdapi.KeyboardButtonTypeRequestLocation: // keyboardButtonTypeRequestLocation#f8828cfd // case *tdapi.KeyboardButtonTypeRequestPoll: // keyboardButtonTypeRequestPoll#7164dcb8 +// case *tdapi.KeyboardButtonTypeWebApp: // keyboardButtonTypeWebApp#70c8ff62 // default: panic(v) // } type KeyboardButtonTypeClass interface { @@ -698,6 +865,13 @@ func DecodeKeyboardButtonType(buf *bin.Buffer) (KeyboardButtonTypeClass, error) return nil, fmt.Errorf("unable to decode KeyboardButtonTypeClass: %w", err) } return &v, nil + case KeyboardButtonTypeWebAppTypeID: + // Decoding keyboardButtonTypeWebApp#70c8ff62. + v := KeyboardButtonTypeWebApp{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode KeyboardButtonTypeClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode KeyboardButtonTypeClass: %w", bin.NewUnexpectedID(id)) } @@ -738,6 +912,13 @@ func DecodeTDLibJSONKeyboardButtonType(buf tdjson.Decoder) (KeyboardButtonTypeCl return nil, fmt.Errorf("unable to decode KeyboardButtonTypeClass: %w", err) } return &v, nil + case "keyboardButtonTypeWebApp": + // Decoding keyboardButtonTypeWebApp#70c8ff62. + v := KeyboardButtonTypeWebApp{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode KeyboardButtonTypeClass: %w", err) + } + return &v, nil default: return nil, fmt.Errorf("unable to decode KeyboardButtonTypeClass: %w", tdjson.NewUnexpectedID(id)) } diff --git a/tdapi/tl_message_content_gen.go b/tdapi/tl_message_content_gen.go index dd917ef215..b3c9ce33c2 100644 --- a/tdapi/tl_message_content_gen.go +++ b/tdapi/tl_message_content_gen.go @@ -8975,6 +8975,372 @@ func (m *MessageWebsiteConnected) GetDomainName() (value string) { return m.DomainName } +// MessageWebAppDataSent represents TL type `messageWebAppDataSent#fb033912`. +type MessageWebAppDataSent struct { + // Text of the keyboardButtonTypeWebApp button, which opened the web app + ButtonText string +} + +// MessageWebAppDataSentTypeID is TL type id of MessageWebAppDataSent. +const MessageWebAppDataSentTypeID = 0xfb033912 + +// construct implements constructor of MessageContentClass. +func (m MessageWebAppDataSent) construct() MessageContentClass { return &m } + +// Ensuring interfaces in compile-time for MessageWebAppDataSent. +var ( + _ bin.Encoder = &MessageWebAppDataSent{} + _ bin.Decoder = &MessageWebAppDataSent{} + _ bin.BareEncoder = &MessageWebAppDataSent{} + _ bin.BareDecoder = &MessageWebAppDataSent{} + + _ MessageContentClass = &MessageWebAppDataSent{} +) + +func (m *MessageWebAppDataSent) Zero() bool { + if m == nil { + return true + } + if !(m.ButtonText == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (m *MessageWebAppDataSent) String() string { + if m == nil { + return "MessageWebAppDataSent(nil)" + } + type Alias MessageWebAppDataSent + return fmt.Sprintf("MessageWebAppDataSent%+v", Alias(*m)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessageWebAppDataSent) TypeID() uint32 { + return MessageWebAppDataSentTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessageWebAppDataSent) TypeName() string { + return "messageWebAppDataSent" +} + +// TypeInfo returns info about TL type. +func (m *MessageWebAppDataSent) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messageWebAppDataSent", + ID: MessageWebAppDataSentTypeID, + } + if m == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ButtonText", + SchemaName: "button_text", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (m *MessageWebAppDataSent) Encode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageWebAppDataSent#fb033912 as nil") + } + b.PutID(MessageWebAppDataSentTypeID) + return m.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (m *MessageWebAppDataSent) EncodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageWebAppDataSent#fb033912 as nil") + } + b.PutString(m.ButtonText) + return nil +} + +// Decode implements bin.Decoder. +func (m *MessageWebAppDataSent) Decode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageWebAppDataSent#fb033912 to nil") + } + if err := b.ConsumeID(MessageWebAppDataSentTypeID); err != nil { + return fmt.Errorf("unable to decode messageWebAppDataSent#fb033912: %w", err) + } + return m.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (m *MessageWebAppDataSent) DecodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageWebAppDataSent#fb033912 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messageWebAppDataSent#fb033912: field button_text: %w", err) + } + m.ButtonText = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (m *MessageWebAppDataSent) EncodeTDLibJSON(b tdjson.Encoder) error { + if m == nil { + return fmt.Errorf("can't encode messageWebAppDataSent#fb033912 as nil") + } + b.ObjStart() + b.PutID("messageWebAppDataSent") + b.Comma() + b.FieldStart("button_text") + b.PutString(m.ButtonText) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (m *MessageWebAppDataSent) DecodeTDLibJSON(b tdjson.Decoder) error { + if m == nil { + return fmt.Errorf("can't decode messageWebAppDataSent#fb033912 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("messageWebAppDataSent"); err != nil { + return fmt.Errorf("unable to decode messageWebAppDataSent#fb033912: %w", err) + } + case "button_text": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messageWebAppDataSent#fb033912: field button_text: %w", err) + } + m.ButtonText = value + default: + return b.Skip() + } + return nil + }) +} + +// GetButtonText returns value of ButtonText field. +func (m *MessageWebAppDataSent) GetButtonText() (value string) { + if m == nil { + return + } + return m.ButtonText +} + +// MessageWebAppDataReceived represents TL type `messageWebAppDataReceived#ff7d1a15`. +type MessageWebAppDataReceived struct { + // Text of the keyboardButtonTypeWebApp button, which opened the web app + ButtonText string + // Received data + Data string +} + +// MessageWebAppDataReceivedTypeID is TL type id of MessageWebAppDataReceived. +const MessageWebAppDataReceivedTypeID = 0xff7d1a15 + +// construct implements constructor of MessageContentClass. +func (m MessageWebAppDataReceived) construct() MessageContentClass { return &m } + +// Ensuring interfaces in compile-time for MessageWebAppDataReceived. +var ( + _ bin.Encoder = &MessageWebAppDataReceived{} + _ bin.Decoder = &MessageWebAppDataReceived{} + _ bin.BareEncoder = &MessageWebAppDataReceived{} + _ bin.BareDecoder = &MessageWebAppDataReceived{} + + _ MessageContentClass = &MessageWebAppDataReceived{} +) + +func (m *MessageWebAppDataReceived) Zero() bool { + if m == nil { + return true + } + if !(m.ButtonText == "") { + return false + } + if !(m.Data == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (m *MessageWebAppDataReceived) String() string { + if m == nil { + return "MessageWebAppDataReceived(nil)" + } + type Alias MessageWebAppDataReceived + return fmt.Sprintf("MessageWebAppDataReceived%+v", Alias(*m)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*MessageWebAppDataReceived) TypeID() uint32 { + return MessageWebAppDataReceivedTypeID +} + +// TypeName returns name of type in TL schema. +func (*MessageWebAppDataReceived) TypeName() string { + return "messageWebAppDataReceived" +} + +// TypeInfo returns info about TL type. +func (m *MessageWebAppDataReceived) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "messageWebAppDataReceived", + ID: MessageWebAppDataReceivedTypeID, + } + if m == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ButtonText", + SchemaName: "button_text", + }, + { + Name: "Data", + SchemaName: "data", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (m *MessageWebAppDataReceived) Encode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageWebAppDataReceived#ff7d1a15 as nil") + } + b.PutID(MessageWebAppDataReceivedTypeID) + return m.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (m *MessageWebAppDataReceived) EncodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't encode messageWebAppDataReceived#ff7d1a15 as nil") + } + b.PutString(m.ButtonText) + b.PutString(m.Data) + return nil +} + +// Decode implements bin.Decoder. +func (m *MessageWebAppDataReceived) Decode(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageWebAppDataReceived#ff7d1a15 to nil") + } + if err := b.ConsumeID(MessageWebAppDataReceivedTypeID); err != nil { + return fmt.Errorf("unable to decode messageWebAppDataReceived#ff7d1a15: %w", err) + } + return m.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (m *MessageWebAppDataReceived) DecodeBare(b *bin.Buffer) error { + if m == nil { + return fmt.Errorf("can't decode messageWebAppDataReceived#ff7d1a15 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messageWebAppDataReceived#ff7d1a15: field button_text: %w", err) + } + m.ButtonText = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messageWebAppDataReceived#ff7d1a15: field data: %w", err) + } + m.Data = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (m *MessageWebAppDataReceived) EncodeTDLibJSON(b tdjson.Encoder) error { + if m == nil { + return fmt.Errorf("can't encode messageWebAppDataReceived#ff7d1a15 as nil") + } + b.ObjStart() + b.PutID("messageWebAppDataReceived") + b.Comma() + b.FieldStart("button_text") + b.PutString(m.ButtonText) + b.Comma() + b.FieldStart("data") + b.PutString(m.Data) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (m *MessageWebAppDataReceived) DecodeTDLibJSON(b tdjson.Decoder) error { + if m == nil { + return fmt.Errorf("can't decode messageWebAppDataReceived#ff7d1a15 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("messageWebAppDataReceived"); err != nil { + return fmt.Errorf("unable to decode messageWebAppDataReceived#ff7d1a15: %w", err) + } + case "button_text": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messageWebAppDataReceived#ff7d1a15: field button_text: %w", err) + } + m.ButtonText = value + case "data": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode messageWebAppDataReceived#ff7d1a15: field data: %w", err) + } + m.Data = value + default: + return b.Skip() + } + return nil + }) +} + +// GetButtonText returns value of ButtonText field. +func (m *MessageWebAppDataReceived) GetButtonText() (value string) { + if m == nil { + return + } + return m.ButtonText +} + +// GetData returns value of Data field. +func (m *MessageWebAppDataReceived) GetData() (value string) { + if m == nil { + return + } + return m.Data +} + // MessagePassportDataSent represents TL type `messagePassportDataSent#26c5ed6b`. type MessagePassportDataSent struct { // List of Telegram Passport element types sent @@ -9844,6 +10210,8 @@ const MessageContentClassName = "MessageContent" // case *tdapi.MessagePaymentSuccessfulBot: // messagePaymentSuccessfulBot#e5de169e // case *tdapi.MessageContactRegistered: // messageContactRegistered#a678fcff // case *tdapi.MessageWebsiteConnected: // messageWebsiteConnected#bff3a408 +// case *tdapi.MessageWebAppDataSent: // messageWebAppDataSent#fb033912 +// case *tdapi.MessageWebAppDataReceived: // messageWebAppDataReceived#ff7d1a15 // case *tdapi.MessagePassportDataSent: // messagePassportDataSent#26c5ed6b // case *tdapi.MessagePassportDataReceived: // messagePassportDataReceived#e0b936b9 // case *tdapi.MessageProximityAlertTriggered: // messageProximityAlertTriggered#409f6d3 @@ -10194,6 +10562,20 @@ func DecodeMessageContent(buf *bin.Buffer) (MessageContentClass, error) { return nil, fmt.Errorf("unable to decode MessageContentClass: %w", err) } return &v, nil + case MessageWebAppDataSentTypeID: + // Decoding messageWebAppDataSent#fb033912. + v := MessageWebAppDataSent{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessageContentClass: %w", err) + } + return &v, nil + case MessageWebAppDataReceivedTypeID: + // Decoding messageWebAppDataReceived#ff7d1a15. + v := MessageWebAppDataReceived{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessageContentClass: %w", err) + } + return &v, nil case MessagePassportDataSentTypeID: // Decoding messagePassportDataSent#26c5ed6b. v := MessagePassportDataSent{} @@ -10549,6 +10931,20 @@ func DecodeTDLibJSONMessageContent(buf tdjson.Decoder) (MessageContentClass, err return nil, fmt.Errorf("unable to decode MessageContentClass: %w", err) } return &v, nil + case "messageWebAppDataSent": + // Decoding messageWebAppDataSent#fb033912. + v := MessageWebAppDataSent{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessageContentClass: %w", err) + } + return &v, nil + case "messageWebAppDataReceived": + // Decoding messageWebAppDataReceived#ff7d1a15. + v := MessageWebAppDataReceived{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode MessageContentClass: %w", err) + } + return &v, nil case "messagePassportDataSent": // Decoding messagePassportDataSent#26c5ed6b. v := MessagePassportDataSent{} diff --git a/tdapi/tl_message_reaction_gen.go b/tdapi/tl_message_reaction_gen.go index e93a19b041..be89dc7fc3 100644 --- a/tdapi/tl_message_reaction_gen.go +++ b/tdapi/tl_message_reaction_gen.go @@ -40,7 +40,7 @@ type MessageReaction struct { // True, if the reaction is chosen by the current user IsChosen bool // Identifiers of at most 3 recent message senders, added the reaction; available in - // private chats, basic groups and supergroups + // private, basic group and supergroup chats RecentSenderIDs []MessageSenderClass } diff --git a/tdapi/tl_notification_gen.go b/tdapi/tl_notification_gen.go index 79afe8263d..87be728f77 100644 --- a/tdapi/tl_notification_gen.go +++ b/tdapi/tl_notification_gen.go @@ -31,20 +31,20 @@ var ( _ = tdjson.Encoder{} ) -// Notification represents TL type `notification#2f0343d0`. +// Notification represents TL type `notification#81fa1b96`. type Notification struct { // Unique persistent identifier of this notification ID int32 // Notification date Date int32 - // True, if the notification was initially silent - IsSilent bool + // Identifier of the notification sound to be played; 0 if sound is disabled + SoundID int64 // Notification type Type NotificationTypeClass } // NotificationTypeID is TL type id of Notification. -const NotificationTypeID = 0x2f0343d0 +const NotificationTypeID = 0x81fa1b96 // Ensuring interfaces in compile-time for Notification. var ( @@ -64,7 +64,7 @@ func (n *Notification) Zero() bool { if !(n.Date == 0) { return false } - if !(n.IsSilent == false) { + if !(n.SoundID == 0) { return false } if !(n.Type == nil) { @@ -115,8 +115,8 @@ func (n *Notification) TypeInfo() tdp.Type { SchemaName: "date", }, { - Name: "IsSilent", - SchemaName: "is_silent", + Name: "SoundID", + SchemaName: "sound_id", }, { Name: "Type", @@ -129,7 +129,7 @@ func (n *Notification) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (n *Notification) Encode(b *bin.Buffer) error { if n == nil { - return fmt.Errorf("can't encode notification#2f0343d0 as nil") + return fmt.Errorf("can't encode notification#81fa1b96 as nil") } b.PutID(NotificationTypeID) return n.EncodeBare(b) @@ -138,16 +138,16 @@ func (n *Notification) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (n *Notification) EncodeBare(b *bin.Buffer) error { if n == nil { - return fmt.Errorf("can't encode notification#2f0343d0 as nil") + return fmt.Errorf("can't encode notification#81fa1b96 as nil") } b.PutInt32(n.ID) b.PutInt32(n.Date) - b.PutBool(n.IsSilent) + b.PutLong(n.SoundID) if n.Type == nil { - return fmt.Errorf("unable to encode notification#2f0343d0: field type is nil") + return fmt.Errorf("unable to encode notification#81fa1b96: field type is nil") } if err := n.Type.Encode(b); err != nil { - return fmt.Errorf("unable to encode notification#2f0343d0: field type: %w", err) + return fmt.Errorf("unable to encode notification#81fa1b96: field type: %w", err) } return nil } @@ -155,10 +155,10 @@ func (n *Notification) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (n *Notification) Decode(b *bin.Buffer) error { if n == nil { - return fmt.Errorf("can't decode notification#2f0343d0 to nil") + return fmt.Errorf("can't decode notification#81fa1b96 to nil") } if err := b.ConsumeID(NotificationTypeID); err != nil { - return fmt.Errorf("unable to decode notification#2f0343d0: %w", err) + return fmt.Errorf("unable to decode notification#81fa1b96: %w", err) } return n.DecodeBare(b) } @@ -166,33 +166,33 @@ func (n *Notification) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (n *Notification) DecodeBare(b *bin.Buffer) error { if n == nil { - return fmt.Errorf("can't decode notification#2f0343d0 to nil") + return fmt.Errorf("can't decode notification#81fa1b96 to nil") } { value, err := b.Int32() if err != nil { - return fmt.Errorf("unable to decode notification#2f0343d0: field id: %w", err) + return fmt.Errorf("unable to decode notification#81fa1b96: field id: %w", err) } n.ID = value } { value, err := b.Int32() if err != nil { - return fmt.Errorf("unable to decode notification#2f0343d0: field date: %w", err) + return fmt.Errorf("unable to decode notification#81fa1b96: field date: %w", err) } n.Date = value } { - value, err := b.Bool() + value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode notification#2f0343d0: field is_silent: %w", err) + return fmt.Errorf("unable to decode notification#81fa1b96: field sound_id: %w", err) } - n.IsSilent = value + n.SoundID = value } { value, err := DecodeNotificationType(b) if err != nil { - return fmt.Errorf("unable to decode notification#2f0343d0: field type: %w", err) + return fmt.Errorf("unable to decode notification#81fa1b96: field type: %w", err) } n.Type = value } @@ -202,7 +202,7 @@ func (n *Notification) DecodeBare(b *bin.Buffer) error { // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (n *Notification) EncodeTDLibJSON(b tdjson.Encoder) error { if n == nil { - return fmt.Errorf("can't encode notification#2f0343d0 as nil") + return fmt.Errorf("can't encode notification#81fa1b96 as nil") } b.ObjStart() b.PutID("notification") @@ -213,15 +213,15 @@ func (n *Notification) EncodeTDLibJSON(b tdjson.Encoder) error { b.FieldStart("date") b.PutInt32(n.Date) b.Comma() - b.FieldStart("is_silent") - b.PutBool(n.IsSilent) + b.FieldStart("sound_id") + b.PutLong(n.SoundID) b.Comma() b.FieldStart("type") if n.Type == nil { - return fmt.Errorf("unable to encode notification#2f0343d0: field type is nil") + return fmt.Errorf("unable to encode notification#81fa1b96: field type is nil") } if err := n.Type.EncodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to encode notification#2f0343d0: field type: %w", err) + return fmt.Errorf("unable to encode notification#81fa1b96: field type: %w", err) } b.Comma() b.StripComma() @@ -232,37 +232,37 @@ func (n *Notification) EncodeTDLibJSON(b tdjson.Encoder) error { // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (n *Notification) DecodeTDLibJSON(b tdjson.Decoder) error { if n == nil { - return fmt.Errorf("can't decode notification#2f0343d0 to nil") + return fmt.Errorf("can't decode notification#81fa1b96 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("notification"); err != nil { - return fmt.Errorf("unable to decode notification#2f0343d0: %w", err) + return fmt.Errorf("unable to decode notification#81fa1b96: %w", err) } case "id": value, err := b.Int32() if err != nil { - return fmt.Errorf("unable to decode notification#2f0343d0: field id: %w", err) + return fmt.Errorf("unable to decode notification#81fa1b96: field id: %w", err) } n.ID = value case "date": value, err := b.Int32() if err != nil { - return fmt.Errorf("unable to decode notification#2f0343d0: field date: %w", err) + return fmt.Errorf("unable to decode notification#81fa1b96: field date: %w", err) } n.Date = value - case "is_silent": - value, err := b.Bool() + case "sound_id": + value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode notification#2f0343d0: field is_silent: %w", err) + return fmt.Errorf("unable to decode notification#81fa1b96: field sound_id: %w", err) } - n.IsSilent = value + n.SoundID = value case "type": value, err := DecodeTDLibJSONNotificationType(b) if err != nil { - return fmt.Errorf("unable to decode notification#2f0343d0: field type: %w", err) + return fmt.Errorf("unable to decode notification#81fa1b96: field type: %w", err) } n.Type = value default: @@ -288,12 +288,12 @@ func (n *Notification) GetDate() (value int32) { return n.Date } -// GetIsSilent returns value of IsSilent field. -func (n *Notification) GetIsSilent() (value bool) { +// GetSoundID returns value of SoundID field. +func (n *Notification) GetSoundID() (value int64) { if n == nil { return } - return n.IsSilent + return n.SoundID } // GetType returns value of Type field. diff --git a/tdapi/tl_notification_sound_gen.go b/tdapi/tl_notification_sound_gen.go new file mode 100644 index 0000000000..984213350e --- /dev/null +++ b/tdapi/tl_notification_sound_gen.go @@ -0,0 +1,363 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// NotificationSound represents TL type `notificationSound#f4ef6137`. +type NotificationSound struct { + // Unique identifier of the notification sound + ID int64 + // Duration of the sound, in seconds + Duration int32 + // Point in time (Unix timestamp) when the sound was created + Date int32 + // Title of the notification sound + Title string + // Arbitrary data, defined while the sound was uploaded + Data string + // File containing the sound + Sound File +} + +// NotificationSoundTypeID is TL type id of NotificationSound. +const NotificationSoundTypeID = 0xf4ef6137 + +// Ensuring interfaces in compile-time for NotificationSound. +var ( + _ bin.Encoder = &NotificationSound{} + _ bin.Decoder = &NotificationSound{} + _ bin.BareEncoder = &NotificationSound{} + _ bin.BareDecoder = &NotificationSound{} +) + +func (n *NotificationSound) Zero() bool { + if n == nil { + return true + } + if !(n.ID == 0) { + return false + } + if !(n.Duration == 0) { + return false + } + if !(n.Date == 0) { + return false + } + if !(n.Title == "") { + return false + } + if !(n.Data == "") { + return false + } + if !(n.Sound.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (n *NotificationSound) String() string { + if n == nil { + return "NotificationSound(nil)" + } + type Alias NotificationSound + return fmt.Sprintf("NotificationSound%+v", Alias(*n)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*NotificationSound) TypeID() uint32 { + return NotificationSoundTypeID +} + +// TypeName returns name of type in TL schema. +func (*NotificationSound) TypeName() string { + return "notificationSound" +} + +// TypeInfo returns info about TL type. +func (n *NotificationSound) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "notificationSound", + ID: NotificationSoundTypeID, + } + if n == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ID", + SchemaName: "id", + }, + { + Name: "Duration", + SchemaName: "duration", + }, + { + Name: "Date", + SchemaName: "date", + }, + { + Name: "Title", + SchemaName: "title", + }, + { + Name: "Data", + SchemaName: "data", + }, + { + Name: "Sound", + SchemaName: "sound", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (n *NotificationSound) Encode(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't encode notificationSound#f4ef6137 as nil") + } + b.PutID(NotificationSoundTypeID) + return n.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (n *NotificationSound) EncodeBare(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't encode notificationSound#f4ef6137 as nil") + } + b.PutLong(n.ID) + b.PutInt32(n.Duration) + b.PutInt32(n.Date) + b.PutString(n.Title) + b.PutString(n.Data) + if err := n.Sound.Encode(b); err != nil { + return fmt.Errorf("unable to encode notificationSound#f4ef6137: field sound: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (n *NotificationSound) Decode(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't decode notificationSound#f4ef6137 to nil") + } + if err := b.ConsumeID(NotificationSoundTypeID); err != nil { + return fmt.Errorf("unable to decode notificationSound#f4ef6137: %w", err) + } + return n.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (n *NotificationSound) DecodeBare(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't decode notificationSound#f4ef6137 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode notificationSound#f4ef6137: field id: %w", err) + } + n.ID = value + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode notificationSound#f4ef6137: field duration: %w", err) + } + n.Duration = value + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode notificationSound#f4ef6137: field date: %w", err) + } + n.Date = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode notificationSound#f4ef6137: field title: %w", err) + } + n.Title = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode notificationSound#f4ef6137: field data: %w", err) + } + n.Data = value + } + { + if err := n.Sound.Decode(b); err != nil { + return fmt.Errorf("unable to decode notificationSound#f4ef6137: field sound: %w", err) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (n *NotificationSound) EncodeTDLibJSON(b tdjson.Encoder) error { + if n == nil { + return fmt.Errorf("can't encode notificationSound#f4ef6137 as nil") + } + b.ObjStart() + b.PutID("notificationSound") + b.Comma() + b.FieldStart("id") + b.PutLong(n.ID) + b.Comma() + b.FieldStart("duration") + b.PutInt32(n.Duration) + b.Comma() + b.FieldStart("date") + b.PutInt32(n.Date) + b.Comma() + b.FieldStart("title") + b.PutString(n.Title) + b.Comma() + b.FieldStart("data") + b.PutString(n.Data) + b.Comma() + b.FieldStart("sound") + if err := n.Sound.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode notificationSound#f4ef6137: field sound: %w", err) + } + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (n *NotificationSound) DecodeTDLibJSON(b tdjson.Decoder) error { + if n == nil { + return fmt.Errorf("can't decode notificationSound#f4ef6137 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("notificationSound"); err != nil { + return fmt.Errorf("unable to decode notificationSound#f4ef6137: %w", err) + } + case "id": + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode notificationSound#f4ef6137: field id: %w", err) + } + n.ID = value + case "duration": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode notificationSound#f4ef6137: field duration: %w", err) + } + n.Duration = value + case "date": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode notificationSound#f4ef6137: field date: %w", err) + } + n.Date = value + case "title": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode notificationSound#f4ef6137: field title: %w", err) + } + n.Title = value + case "data": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode notificationSound#f4ef6137: field data: %w", err) + } + n.Data = value + case "sound": + if err := n.Sound.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode notificationSound#f4ef6137: field sound: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetID returns value of ID field. +func (n *NotificationSound) GetID() (value int64) { + if n == nil { + return + } + return n.ID +} + +// GetDuration returns value of Duration field. +func (n *NotificationSound) GetDuration() (value int32) { + if n == nil { + return + } + return n.Duration +} + +// GetDate returns value of Date field. +func (n *NotificationSound) GetDate() (value int32) { + if n == nil { + return + } + return n.Date +} + +// GetTitle returns value of Title field. +func (n *NotificationSound) GetTitle() (value string) { + if n == nil { + return + } + return n.Title +} + +// GetData returns value of Data field. +func (n *NotificationSound) GetData() (value string) { + if n == nil { + return + } + return n.Data +} + +// GetSound returns value of Sound field. +func (n *NotificationSound) GetSound() (value File) { + if n == nil { + return + } + return n.Sound +} diff --git a/tdapi/tl_notification_sounds_gen.go b/tdapi/tl_notification_sounds_gen.go new file mode 100644 index 0000000000..bf498632f7 --- /dev/null +++ b/tdapi/tl_notification_sounds_gen.go @@ -0,0 +1,221 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// NotificationSounds represents TL type `notificationSounds#7ba3c849`. +type NotificationSounds struct { + // A list of notification sounds + NotificationSounds []NotificationSound +} + +// NotificationSoundsTypeID is TL type id of NotificationSounds. +const NotificationSoundsTypeID = 0x7ba3c849 + +// Ensuring interfaces in compile-time for NotificationSounds. +var ( + _ bin.Encoder = &NotificationSounds{} + _ bin.Decoder = &NotificationSounds{} + _ bin.BareEncoder = &NotificationSounds{} + _ bin.BareDecoder = &NotificationSounds{} +) + +func (n *NotificationSounds) Zero() bool { + if n == nil { + return true + } + if !(n.NotificationSounds == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (n *NotificationSounds) String() string { + if n == nil { + return "NotificationSounds(nil)" + } + type Alias NotificationSounds + return fmt.Sprintf("NotificationSounds%+v", Alias(*n)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*NotificationSounds) TypeID() uint32 { + return NotificationSoundsTypeID +} + +// TypeName returns name of type in TL schema. +func (*NotificationSounds) TypeName() string { + return "notificationSounds" +} + +// TypeInfo returns info about TL type. +func (n *NotificationSounds) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "notificationSounds", + ID: NotificationSoundsTypeID, + } + if n == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "NotificationSounds", + SchemaName: "notification_sounds", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (n *NotificationSounds) Encode(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't encode notificationSounds#7ba3c849 as nil") + } + b.PutID(NotificationSoundsTypeID) + return n.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (n *NotificationSounds) EncodeBare(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't encode notificationSounds#7ba3c849 as nil") + } + b.PutInt(len(n.NotificationSounds)) + for idx, v := range n.NotificationSounds { + if err := v.EncodeBare(b); err != nil { + return fmt.Errorf("unable to encode bare notificationSounds#7ba3c849: field notification_sounds element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (n *NotificationSounds) Decode(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't decode notificationSounds#7ba3c849 to nil") + } + if err := b.ConsumeID(NotificationSoundsTypeID); err != nil { + return fmt.Errorf("unable to decode notificationSounds#7ba3c849: %w", err) + } + return n.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (n *NotificationSounds) DecodeBare(b *bin.Buffer) error { + if n == nil { + return fmt.Errorf("can't decode notificationSounds#7ba3c849 to nil") + } + { + headerLen, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode notificationSounds#7ba3c849: field notification_sounds: %w", err) + } + + if headerLen > 0 { + n.NotificationSounds = make([]NotificationSound, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value NotificationSound + if err := value.DecodeBare(b); err != nil { + return fmt.Errorf("unable to decode bare notificationSounds#7ba3c849: field notification_sounds: %w", err) + } + n.NotificationSounds = append(n.NotificationSounds, value) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (n *NotificationSounds) EncodeTDLibJSON(b tdjson.Encoder) error { + if n == nil { + return fmt.Errorf("can't encode notificationSounds#7ba3c849 as nil") + } + b.ObjStart() + b.PutID("notificationSounds") + b.Comma() + b.FieldStart("notification_sounds") + b.ArrStart() + for idx, v := range n.NotificationSounds { + if err := v.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode notificationSounds#7ba3c849: field notification_sounds element with index %d: %w", idx, err) + } + b.Comma() + } + b.StripComma() + b.ArrEnd() + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (n *NotificationSounds) DecodeTDLibJSON(b tdjson.Decoder) error { + if n == nil { + return fmt.Errorf("can't decode notificationSounds#7ba3c849 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("notificationSounds"); err != nil { + return fmt.Errorf("unable to decode notificationSounds#7ba3c849: %w", err) + } + case "notification_sounds": + if err := b.Arr(func(b tdjson.Decoder) error { + var value NotificationSound + if err := value.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode notificationSounds#7ba3c849: field notification_sounds: %w", err) + } + n.NotificationSounds = append(n.NotificationSounds, value) + return nil + }); err != nil { + return fmt.Errorf("unable to decode notificationSounds#7ba3c849: field notification_sounds: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetNotificationSounds returns value of NotificationSounds field. +func (n *NotificationSounds) GetNotificationSounds() (value []NotificationSound) { + if n == nil { + return + } + return n.NotificationSounds +} diff --git a/tdapi/tl_open_web_app_gen.go b/tdapi/tl_open_web_app_gen.go new file mode 100644 index 0000000000..eb71279556 --- /dev/null +++ b/tdapi/tl_open_web_app_gen.go @@ -0,0 +1,341 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// OpenWebAppRequest represents TL type `openWebApp#914ac418`. +type OpenWebAppRequest struct { + // Identifier of the chat in which the web app is opened. Web apps can be opened only in + // private chats for now + ChatID int64 + // Identifier of the bot, providing the web app + BotUserID int64 + // The URL from an inlineKeyboardButtonTypeWebApp button, a botMenuButton button, or an + // internalLinkTypeAttachmentMenuBot link, or an empty string otherwise + URL string + // Preferred web app theme; pass null to use the default theme + Theme ThemeParameters + // Identifier of the replied message for the message sent by the web app; 0 if none + ReplyToMessageID int64 +} + +// OpenWebAppRequestTypeID is TL type id of OpenWebAppRequest. +const OpenWebAppRequestTypeID = 0x914ac418 + +// Ensuring interfaces in compile-time for OpenWebAppRequest. +var ( + _ bin.Encoder = &OpenWebAppRequest{} + _ bin.Decoder = &OpenWebAppRequest{} + _ bin.BareEncoder = &OpenWebAppRequest{} + _ bin.BareDecoder = &OpenWebAppRequest{} +) + +func (o *OpenWebAppRequest) Zero() bool { + if o == nil { + return true + } + if !(o.ChatID == 0) { + return false + } + if !(o.BotUserID == 0) { + return false + } + if !(o.URL == "") { + return false + } + if !(o.Theme.Zero()) { + return false + } + if !(o.ReplyToMessageID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (o *OpenWebAppRequest) String() string { + if o == nil { + return "OpenWebAppRequest(nil)" + } + type Alias OpenWebAppRequest + return fmt.Sprintf("OpenWebAppRequest%+v", Alias(*o)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*OpenWebAppRequest) TypeID() uint32 { + return OpenWebAppRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*OpenWebAppRequest) TypeName() string { + return "openWebApp" +} + +// TypeInfo returns info about TL type. +func (o *OpenWebAppRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "openWebApp", + ID: OpenWebAppRequestTypeID, + } + if o == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ChatID", + SchemaName: "chat_id", + }, + { + Name: "BotUserID", + SchemaName: "bot_user_id", + }, + { + Name: "URL", + SchemaName: "url", + }, + { + Name: "Theme", + SchemaName: "theme", + }, + { + Name: "ReplyToMessageID", + SchemaName: "reply_to_message_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (o *OpenWebAppRequest) Encode(b *bin.Buffer) error { + if o == nil { + return fmt.Errorf("can't encode openWebApp#914ac418 as nil") + } + b.PutID(OpenWebAppRequestTypeID) + return o.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (o *OpenWebAppRequest) EncodeBare(b *bin.Buffer) error { + if o == nil { + return fmt.Errorf("can't encode openWebApp#914ac418 as nil") + } + b.PutInt53(o.ChatID) + b.PutInt53(o.BotUserID) + b.PutString(o.URL) + if err := o.Theme.Encode(b); err != nil { + return fmt.Errorf("unable to encode openWebApp#914ac418: field theme: %w", err) + } + b.PutInt53(o.ReplyToMessageID) + return nil +} + +// Decode implements bin.Decoder. +func (o *OpenWebAppRequest) Decode(b *bin.Buffer) error { + if o == nil { + return fmt.Errorf("can't decode openWebApp#914ac418 to nil") + } + if err := b.ConsumeID(OpenWebAppRequestTypeID); err != nil { + return fmt.Errorf("unable to decode openWebApp#914ac418: %w", err) + } + return o.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (o *OpenWebAppRequest) DecodeBare(b *bin.Buffer) error { + if o == nil { + return fmt.Errorf("can't decode openWebApp#914ac418 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode openWebApp#914ac418: field chat_id: %w", err) + } + o.ChatID = value + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode openWebApp#914ac418: field bot_user_id: %w", err) + } + o.BotUserID = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode openWebApp#914ac418: field url: %w", err) + } + o.URL = value + } + { + if err := o.Theme.Decode(b); err != nil { + return fmt.Errorf("unable to decode openWebApp#914ac418: field theme: %w", err) + } + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode openWebApp#914ac418: field reply_to_message_id: %w", err) + } + o.ReplyToMessageID = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (o *OpenWebAppRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if o == nil { + return fmt.Errorf("can't encode openWebApp#914ac418 as nil") + } + b.ObjStart() + b.PutID("openWebApp") + b.Comma() + b.FieldStart("chat_id") + b.PutInt53(o.ChatID) + b.Comma() + b.FieldStart("bot_user_id") + b.PutInt53(o.BotUserID) + b.Comma() + b.FieldStart("url") + b.PutString(o.URL) + b.Comma() + b.FieldStart("theme") + if err := o.Theme.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode openWebApp#914ac418: field theme: %w", err) + } + b.Comma() + b.FieldStart("reply_to_message_id") + b.PutInt53(o.ReplyToMessageID) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (o *OpenWebAppRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if o == nil { + return fmt.Errorf("can't decode openWebApp#914ac418 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("openWebApp"); err != nil { + return fmt.Errorf("unable to decode openWebApp#914ac418: %w", err) + } + case "chat_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode openWebApp#914ac418: field chat_id: %w", err) + } + o.ChatID = value + case "bot_user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode openWebApp#914ac418: field bot_user_id: %w", err) + } + o.BotUserID = value + case "url": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode openWebApp#914ac418: field url: %w", err) + } + o.URL = value + case "theme": + if err := o.Theme.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode openWebApp#914ac418: field theme: %w", err) + } + case "reply_to_message_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode openWebApp#914ac418: field reply_to_message_id: %w", err) + } + o.ReplyToMessageID = value + default: + return b.Skip() + } + return nil + }) +} + +// GetChatID returns value of ChatID field. +func (o *OpenWebAppRequest) GetChatID() (value int64) { + if o == nil { + return + } + return o.ChatID +} + +// GetBotUserID returns value of BotUserID field. +func (o *OpenWebAppRequest) GetBotUserID() (value int64) { + if o == nil { + return + } + return o.BotUserID +} + +// GetURL returns value of URL field. +func (o *OpenWebAppRequest) GetURL() (value string) { + if o == nil { + return + } + return o.URL +} + +// GetTheme returns value of Theme field. +func (o *OpenWebAppRequest) GetTheme() (value ThemeParameters) { + if o == nil { + return + } + return o.Theme +} + +// GetReplyToMessageID returns value of ReplyToMessageID field. +func (o *OpenWebAppRequest) GetReplyToMessageID() (value int64) { + if o == nil { + return + } + return o.ReplyToMessageID +} + +// OpenWebApp invokes method openWebApp#914ac418 returning error if any. +func (c *Client) OpenWebApp(ctx context.Context, request *OpenWebAppRequest) (*WebAppInfo, error) { + var result WebAppInfo + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tdapi/tl_page_block_gen.go b/tdapi/tl_page_block_gen.go index a487d40f53..44d39bcbbd 100644 --- a/tdapi/tl_page_block_gen.go +++ b/tdapi/tl_page_block_gen.go @@ -5174,7 +5174,7 @@ type PageBlockChatLink struct { Title string // Chat photo; may be null Photo ChatPhotoInfo - // Chat username, by which all other information about the chat can be resolved + // Chat username by which all other information about the chat can be resolved Username string } diff --git a/tdapi/tl_payment_form_theme_gen.go b/tdapi/tl_payment_form_theme_gen.go deleted file mode 100644 index 6554d0f5be..0000000000 --- a/tdapi/tl_payment_form_theme_gen.go +++ /dev/null @@ -1,363 +0,0 @@ -// Code generated by gotdgen, DO NOT EDIT. - -package tdapi - -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{} -) - -// PaymentFormTheme represents TL type `paymentFormTheme#97180f8f`. -type PaymentFormTheme struct { - // A color of the payment form background in the RGB24 format - BackgroundColor int32 - // A color of text in the RGB24 format - TextColor int32 - // A color of hints in the RGB24 format - HintColor int32 - // A color of links in the RGB24 format - LinkColor int32 - // A color of the buttons in the RGB24 format - ButtonColor int32 - // A color of text on the buttons in the RGB24 format - ButtonTextColor int32 -} - -// PaymentFormThemeTypeID is TL type id of PaymentFormTheme. -const PaymentFormThemeTypeID = 0x97180f8f - -// Ensuring interfaces in compile-time for PaymentFormTheme. -var ( - _ bin.Encoder = &PaymentFormTheme{} - _ bin.Decoder = &PaymentFormTheme{} - _ bin.BareEncoder = &PaymentFormTheme{} - _ bin.BareDecoder = &PaymentFormTheme{} -) - -func (p *PaymentFormTheme) Zero() bool { - if p == nil { - return true - } - if !(p.BackgroundColor == 0) { - return false - } - if !(p.TextColor == 0) { - return false - } - if !(p.HintColor == 0) { - return false - } - if !(p.LinkColor == 0) { - return false - } - if !(p.ButtonColor == 0) { - return false - } - if !(p.ButtonTextColor == 0) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (p *PaymentFormTheme) String() string { - if p == nil { - return "PaymentFormTheme(nil)" - } - type Alias PaymentFormTheme - return fmt.Sprintf("PaymentFormTheme%+v", Alias(*p)) -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*PaymentFormTheme) TypeID() uint32 { - return PaymentFormThemeTypeID -} - -// TypeName returns name of type in TL schema. -func (*PaymentFormTheme) TypeName() string { - return "paymentFormTheme" -} - -// TypeInfo returns info about TL type. -func (p *PaymentFormTheme) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "paymentFormTheme", - ID: PaymentFormThemeTypeID, - } - if p == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "BackgroundColor", - SchemaName: "background_color", - }, - { - Name: "TextColor", - SchemaName: "text_color", - }, - { - Name: "HintColor", - SchemaName: "hint_color", - }, - { - Name: "LinkColor", - SchemaName: "link_color", - }, - { - Name: "ButtonColor", - SchemaName: "button_color", - }, - { - Name: "ButtonTextColor", - SchemaName: "button_text_color", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (p *PaymentFormTheme) Encode(b *bin.Buffer) error { - if p == nil { - return fmt.Errorf("can't encode paymentFormTheme#97180f8f as nil") - } - b.PutID(PaymentFormThemeTypeID) - return p.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (p *PaymentFormTheme) EncodeBare(b *bin.Buffer) error { - if p == nil { - return fmt.Errorf("can't encode paymentFormTheme#97180f8f as nil") - } - b.PutInt32(p.BackgroundColor) - b.PutInt32(p.TextColor) - b.PutInt32(p.HintColor) - b.PutInt32(p.LinkColor) - b.PutInt32(p.ButtonColor) - b.PutInt32(p.ButtonTextColor) - return nil -} - -// Decode implements bin.Decoder. -func (p *PaymentFormTheme) Decode(b *bin.Buffer) error { - if p == nil { - return fmt.Errorf("can't decode paymentFormTheme#97180f8f to nil") - } - if err := b.ConsumeID(PaymentFormThemeTypeID); err != nil { - return fmt.Errorf("unable to decode paymentFormTheme#97180f8f: %w", err) - } - return p.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (p *PaymentFormTheme) DecodeBare(b *bin.Buffer) error { - if p == nil { - return fmt.Errorf("can't decode paymentFormTheme#97180f8f to nil") - } - { - value, err := b.Int32() - if err != nil { - return fmt.Errorf("unable to decode paymentFormTheme#97180f8f: field background_color: %w", err) - } - p.BackgroundColor = value - } - { - value, err := b.Int32() - if err != nil { - return fmt.Errorf("unable to decode paymentFormTheme#97180f8f: field text_color: %w", err) - } - p.TextColor = value - } - { - value, err := b.Int32() - if err != nil { - return fmt.Errorf("unable to decode paymentFormTheme#97180f8f: field hint_color: %w", err) - } - p.HintColor = value - } - { - value, err := b.Int32() - if err != nil { - return fmt.Errorf("unable to decode paymentFormTheme#97180f8f: field link_color: %w", err) - } - p.LinkColor = value - } - { - value, err := b.Int32() - if err != nil { - return fmt.Errorf("unable to decode paymentFormTheme#97180f8f: field button_color: %w", err) - } - p.ButtonColor = value - } - { - value, err := b.Int32() - if err != nil { - return fmt.Errorf("unable to decode paymentFormTheme#97180f8f: field button_text_color: %w", err) - } - p.ButtonTextColor = value - } - return nil -} - -// EncodeTDLibJSON implements tdjson.TDLibEncoder. -func (p *PaymentFormTheme) EncodeTDLibJSON(b tdjson.Encoder) error { - if p == nil { - return fmt.Errorf("can't encode paymentFormTheme#97180f8f as nil") - } - b.ObjStart() - b.PutID("paymentFormTheme") - b.Comma() - b.FieldStart("background_color") - b.PutInt32(p.BackgroundColor) - b.Comma() - b.FieldStart("text_color") - b.PutInt32(p.TextColor) - b.Comma() - b.FieldStart("hint_color") - b.PutInt32(p.HintColor) - b.Comma() - b.FieldStart("link_color") - b.PutInt32(p.LinkColor) - b.Comma() - b.FieldStart("button_color") - b.PutInt32(p.ButtonColor) - b.Comma() - b.FieldStart("button_text_color") - b.PutInt32(p.ButtonTextColor) - b.Comma() - b.StripComma() - b.ObjEnd() - return nil -} - -// DecodeTDLibJSON implements tdjson.TDLibDecoder. -func (p *PaymentFormTheme) DecodeTDLibJSON(b tdjson.Decoder) error { - if p == nil { - return fmt.Errorf("can't decode paymentFormTheme#97180f8f to nil") - } - - return b.Obj(func(b tdjson.Decoder, key []byte) error { - switch string(key) { - case tdjson.TypeField: - if err := b.ConsumeID("paymentFormTheme"); err != nil { - return fmt.Errorf("unable to decode paymentFormTheme#97180f8f: %w", err) - } - case "background_color": - value, err := b.Int32() - if err != nil { - return fmt.Errorf("unable to decode paymentFormTheme#97180f8f: field background_color: %w", err) - } - p.BackgroundColor = value - case "text_color": - value, err := b.Int32() - if err != nil { - return fmt.Errorf("unable to decode paymentFormTheme#97180f8f: field text_color: %w", err) - } - p.TextColor = value - case "hint_color": - value, err := b.Int32() - if err != nil { - return fmt.Errorf("unable to decode paymentFormTheme#97180f8f: field hint_color: %w", err) - } - p.HintColor = value - case "link_color": - value, err := b.Int32() - if err != nil { - return fmt.Errorf("unable to decode paymentFormTheme#97180f8f: field link_color: %w", err) - } - p.LinkColor = value - case "button_color": - value, err := b.Int32() - if err != nil { - return fmt.Errorf("unable to decode paymentFormTheme#97180f8f: field button_color: %w", err) - } - p.ButtonColor = value - case "button_text_color": - value, err := b.Int32() - if err != nil { - return fmt.Errorf("unable to decode paymentFormTheme#97180f8f: field button_text_color: %w", err) - } - p.ButtonTextColor = value - default: - return b.Skip() - } - return nil - }) -} - -// GetBackgroundColor returns value of BackgroundColor field. -func (p *PaymentFormTheme) GetBackgroundColor() (value int32) { - if p == nil { - return - } - return p.BackgroundColor -} - -// GetTextColor returns value of TextColor field. -func (p *PaymentFormTheme) GetTextColor() (value int32) { - if p == nil { - return - } - return p.TextColor -} - -// GetHintColor returns value of HintColor field. -func (p *PaymentFormTheme) GetHintColor() (value int32) { - if p == nil { - return - } - return p.HintColor -} - -// GetLinkColor returns value of LinkColor field. -func (p *PaymentFormTheme) GetLinkColor() (value int32) { - if p == nil { - return - } - return p.LinkColor -} - -// GetButtonColor returns value of ButtonColor field. -func (p *PaymentFormTheme) GetButtonColor() (value int32) { - if p == nil { - return - } - return p.ButtonColor -} - -// GetButtonTextColor returns value of ButtonTextColor field. -func (p *PaymentFormTheme) GetButtonTextColor() (value int32) { - if p == nil { - return - } - return p.ButtonTextColor -} diff --git a/tdapi/tl_registry_gen.go b/tdapi/tl_registry_gen.go index c5983268cf..d3356700b7 100644 --- a/tdapi/tl_registry_gen.go +++ b/tdapi/tl_registry_gen.go @@ -118,10 +118,11 @@ func TypesMap() map[uint32]string { ChatPhotoInfoTypeID: "chatPhotoInfo#9f51bb6", UserTypeRegularTypeID: "userTypeRegular#dc51699b", UserTypeDeletedTypeID: "userTypeDeleted#94403d24", - UserTypeBotTypeID: "userTypeBot#4b3e8235", + UserTypeBotTypeID: "userTypeBot#c6256f88", UserTypeUnknownTypeID: "userTypeUnknown#d4d0613d", BotCommandTypeID: "botCommand#c27ac8c7", BotCommandsTypeID: "botCommands#4f9aa2c5", + BotMenuButtonTypeID: "botMenuButton#c7b57ce6", ChatLocationTypeID: "chatLocation#a29b8f21", AnimatedChatPhotoTypeID: "animatedChatPhoto#b719c2e", ChatPhotoTypeID: "chatPhoto#77176e42", @@ -129,14 +130,16 @@ func TypesMap() map[uint32]string { InputChatPhotoPreviousTypeID: "inputChatPhotoPrevious#160e9d1", InputChatPhotoStaticTypeID: "inputChatPhotoStatic#75f7e2b3", InputChatPhotoAnimationTypeID: "inputChatPhotoAnimation#56a3422", + ChatPermissionsTypeID: "chatPermissions#5e73d8df", + ChatAdministratorRightsTypeID: "chatAdministratorRights#6ffd893e", UserTypeID: "user#dff1de69", - UserFullInfoTypeID: "userFullInfo#bbb225cf", + BotInfoTypeID: "botInfo#729c7b7e", + UserFullInfoTypeID: "userFullInfo#b2090391", UsersTypeID: "users#9d955a12", ChatAdministratorTypeID: "chatAdministrator#7277bd2c", ChatAdministratorsTypeID: "chatAdministrators#5141ca21", - ChatPermissionsTypeID: "chatPermissions#5e73d8df", ChatMemberStatusCreatorTypeID: "chatMemberStatusCreator#f6764afe", - ChatMemberStatusAdministratorTypeID: "chatMemberStatusAdministrator#4e6efea", + ChatMemberStatusAdministratorTypeID: "chatMemberStatusAdministrator#fbd3841d", ChatMemberStatusMemberTypeID: "chatMemberStatusMember#32597455", ChatMemberStatusRestrictedTypeID: "chatMemberStatusRestricted#630774a6", ChatMemberStatusLeftTypeID: "chatMemberStatusLeft#ffa74425", @@ -205,8 +208,8 @@ func TypesMap() map[uint32]string { NotificationSettingsScopePrivateChatsTypeID: "notificationSettingsScopePrivateChats#37e04d67", NotificationSettingsScopeGroupChatsTypeID: "notificationSettingsScopeGroupChats#483fd1f3", NotificationSettingsScopeChannelChatsTypeID: "notificationSettingsScopeChannelChats#20aa0588", - ChatNotificationSettingsTypeID: "chatNotificationSettings#5998c172", - ScopeNotificationSettingsTypeID: "scopeNotificationSettings#e69a2c3f", + ChatNotificationSettingsTypeID: "chatNotificationSettings#38493760", + ScopeNotificationSettingsTypeID: "scopeNotificationSettings#ad8a189b", DraftMessageTypeID: "draftMessage#51d71500", ChatTypePrivateTypeID: "chatTypePrivate#5e1e6374", ChatTypeBasicGroupTypeID: "chatTypeBasicGroup#3a0c4c5c", @@ -241,9 +244,11 @@ func TypesMap() map[uint32]string { KeyboardButtonTypeRequestPhoneNumberTypeID: "keyboardButtonTypeRequestPhoneNumber#a4d9b7b9", KeyboardButtonTypeRequestLocationTypeID: "keyboardButtonTypeRequestLocation#f8828cfd", KeyboardButtonTypeRequestPollTypeID: "keyboardButtonTypeRequestPoll#7164dcb8", + KeyboardButtonTypeWebAppTypeID: "keyboardButtonTypeWebApp#70c8ff62", KeyboardButtonTypeID: "keyboardButton#84a0ce74", InlineKeyboardButtonTypeURLTypeID: "inlineKeyboardButtonTypeUrl#4365beac", InlineKeyboardButtonTypeLoginURLTypeID: "inlineKeyboardButtonTypeLoginUrl#b8455fa7", + InlineKeyboardButtonTypeWebAppTypeID: "inlineKeyboardButtonTypeWebApp#96a685c8", InlineKeyboardButtonTypeCallbackTypeID: "inlineKeyboardButtonTypeCallback#bccb7bfd", InlineKeyboardButtonTypeCallbackWithPasswordTypeID: "inlineKeyboardButtonTypeCallbackWithPassword#361f4248", InlineKeyboardButtonTypeCallbackGameTypeID: "inlineKeyboardButtonTypeCallbackGame#e9255468", @@ -257,6 +262,7 @@ func TypesMap() map[uint32]string { ReplyMarkupInlineKeyboardTypeID: "replyMarkupInlineKeyboard#92ac0efb", LoginURLInfoOpenTypeID: "loginUrlInfoOpen#bfaf12d4", LoginURLInfoRequestConfirmationTypeID: "loginUrlInfoRequestConfirmation#7edb242f", + WebAppInfoTypeID: "webAppInfo#2efdb2e8", MessageThreadInfoTypeID: "messageThreadInfo#683fd5ad", RichTextPlainTypeID: "richTextPlain#1cc42966", RichTextBoldTypeID: "richTextBold#63970f6c", @@ -322,6 +328,7 @@ func TypesMap() map[uint32]string { BankCardActionOpenURLTypeID: "bankCardActionOpenUrl#f44a5885", BankCardInfoTypeID: "bankCardInfo#2bc7da9f", AddressTypeID: "address#86304f3a", + ThemeParametersTypeID: "themeParameters#8d6f03d4", LabeledPricePartTypeID: "labeledPricePart#20f2e726", InvoiceTypeID: "invoice#eed5ccb4", OrderInfoTypeID: "orderInfo#2ebad96e", @@ -332,7 +339,6 @@ func TypesMap() map[uint32]string { InputCredentialsApplePayTypeID: "inputCredentialsApplePay#b5b2d6d1", InputCredentialsGooglePayTypeID: "inputCredentialsGooglePay#32544764", PaymentsProviderStripeTypeID: "paymentsProviderStripe#41042678", - PaymentFormThemeTypeID: "paymentFormTheme#97180f8f", PaymentFormTypeID: "paymentForm#572da1e6", ValidatedOrderInfoTypeID: "validatedOrderInfo#ac585f14", PaymentResultTypeID: "paymentResult#d00fe85d", @@ -455,6 +461,8 @@ func TypesMap() map[uint32]string { MessagePaymentSuccessfulBotTypeID: "messagePaymentSuccessfulBot#e5de169e", MessageContactRegisteredTypeID: "messageContactRegistered#a678fcff", MessageWebsiteConnectedTypeID: "messageWebsiteConnected#bff3a408", + MessageWebAppDataSentTypeID: "messageWebAppDataSent#fb033912", + MessageWebAppDataReceivedTypeID: "messageWebAppDataReceived#ff7d1a15", MessagePassportDataSentTypeID: "messagePassportDataSent#26c5ed6b", MessagePassportDataReceivedTypeID: "messagePassportDataReceived#e0b936b9", MessageProximityAlertTriggeredTypeID: "messageProximityAlertTriggered#409f6d3", @@ -590,6 +598,9 @@ func TypesMap() map[uint32]string { DiceStickersRegularTypeID: "diceStickersRegular#d3dfecce", DiceStickersSlotMachineTypeID: "diceStickersSlotMachine#e9a28cac", ImportedContactsTypeID: "importedContacts#1119a03e", + AttachmentMenuBotColorTypeID: "attachmentMenuBotColor#64235ebc", + AttachmentMenuBotTypeID: "attachmentMenuBot#5e82be30", + SentWebAppMessageTypeID: "sentWebAppMessage#4a24eec0", HTTPURLTypeID: "httpUrl#87b775a6", InputInlineQueryResultAnimationTypeID: "inputInlineQueryResultAnimation#a7335216", InputInlineQueryResultArticleTypeID: "inputInlineQueryResultArticle#75a3d10c", @@ -747,7 +758,9 @@ func TypesMap() map[uint32]string { NotificationGroupTypeMentionsTypeID: "notificationGroupTypeMentions#85ca89ad", NotificationGroupTypeSecretChatTypeID: "notificationGroupTypeSecretChat#52e54e34", NotificationGroupTypeCallsTypeID: "notificationGroupTypeCalls#5233c152", - NotificationTypeID: "notification#2f0343d0", + NotificationSoundTypeID: "notificationSound#f4ef6137", + NotificationSoundsTypeID: "notificationSounds#7ba3c849", + NotificationTypeID: "notification#81fa1b96", NotificationGroupTypeID: "notificationGroup#d02a41ba", OptionValueBooleanTypeID: "optionValueBoolean#3c35f1e", OptionValueEmptyTypeID: "optionValueEmpty#36c62493", @@ -793,10 +806,12 @@ func TypesMap() map[uint32]string { ChatReportReasonPersonalDetailsTypeID: "chatReportReasonPersonalDetails#42d38775", ChatReportReasonCustomTypeID: "chatReportReasonCustom#4cd37316", InternalLinkTypeActiveSessionsTypeID: "internalLinkTypeActiveSessions#706bbbad", + InternalLinkTypeAttachmentMenuBotTypeID: "internalLinkTypeAttachmentMenuBot#63932054", InternalLinkTypeAuthenticationCodeTypeID: "internalLinkTypeAuthenticationCode#f3874ff2", InternalLinkTypeBackgroundTypeID: "internalLinkTypeBackground#b0d2908", InternalLinkTypeBotStartTypeID: "internalLinkTypeBotStart#b812d93d", - InternalLinkTypeBotStartInGroupTypeID: "internalLinkTypeBotStartInGroup#c201649c", + InternalLinkTypeBotStartInGroupTypeID: "internalLinkTypeBotStartInGroup#ca0d8cce", + InternalLinkTypeBotAddToChannelTypeID: "internalLinkTypeBotAddToChannel#538ac2c0", InternalLinkTypeChangePhoneNumberTypeID: "internalLinkTypeChangePhoneNumber#f0275b01", InternalLinkTypeChatInviteTypeID: "internalLinkTypeChatInvite#198c3cd9", InternalLinkTypeFilterSettingsTypeID: "internalLinkTypeFilterSettings#5981179b", @@ -826,6 +841,7 @@ func TypesMap() map[uint32]string { FileTypeAnimationTypeID: "fileTypeAnimation#eeaa7dba", FileTypeAudioTypeID: "fileTypeAudio#d5bbcea0", FileTypeDocumentTypeID: "fileTypeDocument#de57030f", + FileTypeNotificationSoundTypeID: "fileTypeNotificationSound#c32f9f09", FileTypePhotoTypeID: "fileTypePhoto#998b71a5", FileTypeProfilePhotoTypeID: "fileTypeProfilePhoto#6afee3a3", FileTypeSecretTypeID: "fileTypeSecret#906d14f7", @@ -953,7 +969,7 @@ func TypesMap() map[uint32]string { UpdateChatOnlineMemberCountTypeID: "updateChatOnlineMemberCount#1d0caa9d", UpdateScopeNotificationSettingsTypeID: "updateScopeNotificationSettings#b83ccb73", UpdateNotificationTypeID: "updateNotification#8ee67ed4", - UpdateNotificationGroupTypeID: "updateNotificationGroup#2ec53c49", + UpdateNotificationGroupTypeID: "updateNotificationGroup#96cd9e06", UpdateActiveNotificationsTypeID: "updateActiveNotifications#317d80f2", UpdateHavePendingNotificationsTypeID: "updateHavePendingNotifications#aaee1db", UpdateDeleteMessagesTypeID: "updateDeleteMessages#6a05bf9", @@ -988,12 +1004,15 @@ func TypesMap() map[uint32]string { UpdateRecentStickersTypeID: "updateRecentStickers#aefdf8dc", UpdateFavoriteStickersTypeID: "updateFavoriteStickers#113f2b6a", UpdateSavedAnimationsTypeID: "updateSavedAnimations#1084a1c8", + UpdateSavedNotificationSoundsTypeID: "updateSavedNotificationSounds#5a6653b4", UpdateSelectedBackgroundTypeID: "updateSelectedBackground#99bd205d", UpdateChatThemesTypeID: "updateChatThemes#98dc58d5", UpdateLanguagePackStringsTypeID: "updateLanguagePackStrings#af87919f", UpdateConnectionStateTypeID: "updateConnectionState#57939e2e", UpdateTermsOfServiceTypeID: "updateTermsOfService#b23cc55e", UpdateUsersNearbyTypeID: "updateUsersNearby#97c8ab5", + UpdateAttachmentMenuBotsTypeID: "updateAttachmentMenuBots#b6b910c", + UpdateWebAppMessageSentTypeID: "updateWebAppMessageSent#58431229", UpdateReactionsTypeID: "updateReactions#e769e4e7", UpdateDiceEmojisTypeID: "updateDiceEmojis#9d0f91df", UpdateAnimatedEmojiMessageClickedTypeID: "updateAnimatedEmojiMessageClicked#a3167405", @@ -1156,6 +1175,7 @@ func TypesMap() map[uint32]string { GetLanguagePackStringRequestTypeID: "getLanguagePackString#8fcde73", GetJSONValueRequestTypeID: "getJsonValue#92fa5a05", GetJSONStringRequestTypeID: "getJsonString#278b9421", + GetThemeParametersJSONStringRequestTypeID: "getThemeParametersJsonString#91b905f8", SetPollAnswerRequestTypeID: "setPollAnswer#5303b916", GetPollVotersRequestTypeID: "getPollVoters#7bb2649e", StopPollRequestTypeID: "stopPoll#62e80aad", @@ -1164,6 +1184,11 @@ func TypesMap() map[uint32]string { GetLoginURLRequestTypeID: "getLoginUrl#2f3295d1", GetInlineQueryResultsRequestTypeID: "getInlineQueryResults#79dcf86c", AnswerInlineQueryRequestTypeID: "answerInlineQuery#18ec5846", + GetWebAppURLRequestTypeID: "getWebAppUrl#5f689ab3", + SendWebAppDataRequestTypeID: "sendWebAppData#ab1fce0c", + OpenWebAppRequestTypeID: "openWebApp#914ac418", + CloseWebAppRequestTypeID: "closeWebApp#68a124c6", + AnswerWebAppQueryRequestTypeID: "answerWebAppQuery#a0b49cf1", GetCallbackQueryAnswerRequestTypeID: "getCallbackQueryAnswer#6ef7a5f", AnswerCallbackQueryRequestTypeID: "answerCallbackQuery#bb462e76", AnswerShippingQueryRequestTypeID: "answerShippingQuery#7a3c2432", @@ -1232,12 +1257,18 @@ func TypesMap() map[uint32]string { SearchChatMembersRequestTypeID: "searchChatMembers#e56d46c5", GetChatAdministratorsRequestTypeID: "getChatAdministrators#5c0eb6bb", ClearAllDraftMessagesRequestTypeID: "clearAllDraftMessages#fd3c74db", + GetSavedNotificationSoundRequestTypeID: "getSavedNotificationSound#1b647917", + GetSavedNotificationSoundsRequestTypeID: "getSavedNotificationSounds#c0346fa8", + AddSavedNotificationSoundRequestTypeID: "addSavedNotificationSound#3e3984ef", + RemoveSavedNotificationSoundRequestTypeID: "removeSavedNotificationSound#e363474e", GetChatNotificationSettingsExceptionsRequestTypeID: "getChatNotificationSettingsExceptions#bfe0e11", GetScopeNotificationSettingsRequestTypeID: "getScopeNotificationSettings#c4a8254f", SetScopeNotificationSettingsRequestTypeID: "setScopeNotificationSettings#85cfb63a", ResetAllNotificationSettingsRequestTypeID: "resetAllNotificationSettings#f5a0a8f9", ToggleChatIsPinnedRequestTypeID: "toggleChatIsPinned#a776263e", SetPinnedChatsRequestTypeID: "setPinnedChats#c6c6edf1", + GetAttachmentMenuBotRequestTypeID: "getAttachmentMenuBot#3da561fb", + ToggleBotIsAddedToAttachmentMenuRequestTypeID: "toggleBotIsAddedToAttachmentMenu#b56763e2", DownloadFileRequestTypeID: "downloadFile#be50685a", GetFileDownloadedPrefixSizeRequestTypeID: "getFileDownloadedPrefixSize#9c8724a0", CancelDownloadFileRequestTypeID: "cancelDownloadFile#8b8052de", @@ -1367,6 +1398,10 @@ func TypesMap() map[uint32]string { SetCommandsRequestTypeID: "setCommands#b0e0217a", DeleteCommandsRequestTypeID: "deleteCommands#3bc47c2a", GetCommandsRequestTypeID: "getCommands#58ba8ff7", + SetMenuButtonRequestTypeID: "setMenuButton#b44fc141", + GetMenuButtonRequestTypeID: "getMenuButton#e5eef440", + SetDefaultGroupAdministratorRightsRequestTypeID: "setDefaultGroupAdministratorRights#65577768", + SetDefaultChannelAdministratorRightsRequestTypeID: "setDefaultChannelAdministratorRights#f20d5e19", GetActiveSessionsRequestTypeID: "getActiveSessions#42bd6d3e", TerminateSessionRequestTypeID: "terminateSession#e7b7c92c", TerminateAllOtherSessionsRequestTypeID: "terminateAllOtherSessions#6fba6113", @@ -1385,7 +1420,7 @@ func TypesMap() map[uint32]string { GetSupergroupMembersRequestTypeID: "getSupergroupMembers#ddf821c8", CloseSecretChatRequestTypeID: "closeSecretChat#e3ed044b", GetChatEventLogRequestTypeID: "getChatEventLog#f47b0a9b", - GetPaymentFormRequestTypeID: "getPaymentForm#96e6319", + GetPaymentFormRequestTypeID: "getPaymentForm#90411057", ValidateOrderInfoRequestTypeID: "validateOrderInfo#90a9c4", SendPaymentFormRequestTypeID: "sendPaymentForm#5b9133ff", GetPaymentReceiptRequestTypeID: "getPaymentReceipt#3c6cb956", @@ -1599,6 +1634,7 @@ func NamesMap() map[string]uint32 { "userTypeUnknown": UserTypeUnknownTypeID, "botCommand": BotCommandTypeID, "botCommands": BotCommandsTypeID, + "botMenuButton": BotMenuButtonTypeID, "chatLocation": ChatLocationTypeID, "animatedChatPhoto": AnimatedChatPhotoTypeID, "chatPhoto": ChatPhotoTypeID, @@ -1606,12 +1642,14 @@ func NamesMap() map[string]uint32 { "inputChatPhotoPrevious": InputChatPhotoPreviousTypeID, "inputChatPhotoStatic": InputChatPhotoStaticTypeID, "inputChatPhotoAnimation": InputChatPhotoAnimationTypeID, + "chatPermissions": ChatPermissionsTypeID, + "chatAdministratorRights": ChatAdministratorRightsTypeID, "user": UserTypeID, + "botInfo": BotInfoTypeID, "userFullInfo": UserFullInfoTypeID, "users": UsersTypeID, "chatAdministrator": ChatAdministratorTypeID, "chatAdministrators": ChatAdministratorsTypeID, - "chatPermissions": ChatPermissionsTypeID, "chatMemberStatusCreator": ChatMemberStatusCreatorTypeID, "chatMemberStatusAdministrator": ChatMemberStatusAdministratorTypeID, "chatMemberStatusMember": ChatMemberStatusMemberTypeID, @@ -1718,9 +1756,11 @@ func NamesMap() map[string]uint32 { "keyboardButtonTypeRequestPhoneNumber": KeyboardButtonTypeRequestPhoneNumberTypeID, "keyboardButtonTypeRequestLocation": KeyboardButtonTypeRequestLocationTypeID, "keyboardButtonTypeRequestPoll": KeyboardButtonTypeRequestPollTypeID, + "keyboardButtonTypeWebApp": KeyboardButtonTypeWebAppTypeID, "keyboardButton": KeyboardButtonTypeID, "inlineKeyboardButtonTypeUrl": InlineKeyboardButtonTypeURLTypeID, "inlineKeyboardButtonTypeLoginUrl": InlineKeyboardButtonTypeLoginURLTypeID, + "inlineKeyboardButtonTypeWebApp": InlineKeyboardButtonTypeWebAppTypeID, "inlineKeyboardButtonTypeCallback": InlineKeyboardButtonTypeCallbackTypeID, "inlineKeyboardButtonTypeCallbackWithPassword": InlineKeyboardButtonTypeCallbackWithPasswordTypeID, "inlineKeyboardButtonTypeCallbackGame": InlineKeyboardButtonTypeCallbackGameTypeID, @@ -1734,6 +1774,7 @@ func NamesMap() map[string]uint32 { "replyMarkupInlineKeyboard": ReplyMarkupInlineKeyboardTypeID, "loginUrlInfoOpen": LoginURLInfoOpenTypeID, "loginUrlInfoRequestConfirmation": LoginURLInfoRequestConfirmationTypeID, + "webAppInfo": WebAppInfoTypeID, "messageThreadInfo": MessageThreadInfoTypeID, "richTextPlain": RichTextPlainTypeID, "richTextBold": RichTextBoldTypeID, @@ -1799,6 +1840,7 @@ func NamesMap() map[string]uint32 { "bankCardActionOpenUrl": BankCardActionOpenURLTypeID, "bankCardInfo": BankCardInfoTypeID, "address": AddressTypeID, + "themeParameters": ThemeParametersTypeID, "labeledPricePart": LabeledPricePartTypeID, "invoice": InvoiceTypeID, "orderInfo": OrderInfoTypeID, @@ -1809,7 +1851,6 @@ func NamesMap() map[string]uint32 { "inputCredentialsApplePay": InputCredentialsApplePayTypeID, "inputCredentialsGooglePay": InputCredentialsGooglePayTypeID, "paymentsProviderStripe": PaymentsProviderStripeTypeID, - "paymentFormTheme": PaymentFormThemeTypeID, "paymentForm": PaymentFormTypeID, "validatedOrderInfo": ValidatedOrderInfoTypeID, "paymentResult": PaymentResultTypeID, @@ -1932,6 +1973,8 @@ func NamesMap() map[string]uint32 { "messagePaymentSuccessfulBot": MessagePaymentSuccessfulBotTypeID, "messageContactRegistered": MessageContactRegisteredTypeID, "messageWebsiteConnected": MessageWebsiteConnectedTypeID, + "messageWebAppDataSent": MessageWebAppDataSentTypeID, + "messageWebAppDataReceived": MessageWebAppDataReceivedTypeID, "messagePassportDataSent": MessagePassportDataSentTypeID, "messagePassportDataReceived": MessagePassportDataReceivedTypeID, "messageProximityAlertTriggered": MessageProximityAlertTriggeredTypeID, @@ -2067,6 +2110,9 @@ func NamesMap() map[string]uint32 { "diceStickersRegular": DiceStickersRegularTypeID, "diceStickersSlotMachine": DiceStickersSlotMachineTypeID, "importedContacts": ImportedContactsTypeID, + "attachmentMenuBotColor": AttachmentMenuBotColorTypeID, + "attachmentMenuBot": AttachmentMenuBotTypeID, + "sentWebAppMessage": SentWebAppMessageTypeID, "httpUrl": HTTPURLTypeID, "inputInlineQueryResultAnimation": InputInlineQueryResultAnimationTypeID, "inputInlineQueryResultArticle": InputInlineQueryResultArticleTypeID, @@ -2224,6 +2270,8 @@ func NamesMap() map[string]uint32 { "notificationGroupTypeMentions": NotificationGroupTypeMentionsTypeID, "notificationGroupTypeSecretChat": NotificationGroupTypeSecretChatTypeID, "notificationGroupTypeCalls": NotificationGroupTypeCallsTypeID, + "notificationSound": NotificationSoundTypeID, + "notificationSounds": NotificationSoundsTypeID, "notification": NotificationTypeID, "notificationGroup": NotificationGroupTypeID, "optionValueBoolean": OptionValueBooleanTypeID, @@ -2270,10 +2318,12 @@ func NamesMap() map[string]uint32 { "chatReportReasonPersonalDetails": ChatReportReasonPersonalDetailsTypeID, "chatReportReasonCustom": ChatReportReasonCustomTypeID, "internalLinkTypeActiveSessions": InternalLinkTypeActiveSessionsTypeID, + "internalLinkTypeAttachmentMenuBot": InternalLinkTypeAttachmentMenuBotTypeID, "internalLinkTypeAuthenticationCode": InternalLinkTypeAuthenticationCodeTypeID, "internalLinkTypeBackground": InternalLinkTypeBackgroundTypeID, "internalLinkTypeBotStart": InternalLinkTypeBotStartTypeID, "internalLinkTypeBotStartInGroup": InternalLinkTypeBotStartInGroupTypeID, + "internalLinkTypeBotAddToChannel": InternalLinkTypeBotAddToChannelTypeID, "internalLinkTypeChangePhoneNumber": InternalLinkTypeChangePhoneNumberTypeID, "internalLinkTypeChatInvite": InternalLinkTypeChatInviteTypeID, "internalLinkTypeFilterSettings": InternalLinkTypeFilterSettingsTypeID, @@ -2303,6 +2353,7 @@ func NamesMap() map[string]uint32 { "fileTypeAnimation": FileTypeAnimationTypeID, "fileTypeAudio": FileTypeAudioTypeID, "fileTypeDocument": FileTypeDocumentTypeID, + "fileTypeNotificationSound": FileTypeNotificationSoundTypeID, "fileTypePhoto": FileTypePhotoTypeID, "fileTypeProfilePhoto": FileTypeProfilePhotoTypeID, "fileTypeSecret": FileTypeSecretTypeID, @@ -2465,12 +2516,15 @@ func NamesMap() map[string]uint32 { "updateRecentStickers": UpdateRecentStickersTypeID, "updateFavoriteStickers": UpdateFavoriteStickersTypeID, "updateSavedAnimations": UpdateSavedAnimationsTypeID, + "updateSavedNotificationSounds": UpdateSavedNotificationSoundsTypeID, "updateSelectedBackground": UpdateSelectedBackgroundTypeID, "updateChatThemes": UpdateChatThemesTypeID, "updateLanguagePackStrings": UpdateLanguagePackStringsTypeID, "updateConnectionState": UpdateConnectionStateTypeID, "updateTermsOfService": UpdateTermsOfServiceTypeID, "updateUsersNearby": UpdateUsersNearbyTypeID, + "updateAttachmentMenuBots": UpdateAttachmentMenuBotsTypeID, + "updateWebAppMessageSent": UpdateWebAppMessageSentTypeID, "updateReactions": UpdateReactionsTypeID, "updateDiceEmojis": UpdateDiceEmojisTypeID, "updateAnimatedEmojiMessageClicked": UpdateAnimatedEmojiMessageClickedTypeID, @@ -2633,6 +2687,7 @@ func NamesMap() map[string]uint32 { "getLanguagePackString": GetLanguagePackStringRequestTypeID, "getJsonValue": GetJSONValueRequestTypeID, "getJsonString": GetJSONStringRequestTypeID, + "getThemeParametersJsonString": GetThemeParametersJSONStringRequestTypeID, "setPollAnswer": SetPollAnswerRequestTypeID, "getPollVoters": GetPollVotersRequestTypeID, "stopPoll": StopPollRequestTypeID, @@ -2641,6 +2696,11 @@ func NamesMap() map[string]uint32 { "getLoginUrl": GetLoginURLRequestTypeID, "getInlineQueryResults": GetInlineQueryResultsRequestTypeID, "answerInlineQuery": AnswerInlineQueryRequestTypeID, + "getWebAppUrl": GetWebAppURLRequestTypeID, + "sendWebAppData": SendWebAppDataRequestTypeID, + "openWebApp": OpenWebAppRequestTypeID, + "closeWebApp": CloseWebAppRequestTypeID, + "answerWebAppQuery": AnswerWebAppQueryRequestTypeID, "getCallbackQueryAnswer": GetCallbackQueryAnswerRequestTypeID, "answerCallbackQuery": AnswerCallbackQueryRequestTypeID, "answerShippingQuery": AnswerShippingQueryRequestTypeID, @@ -2709,12 +2769,18 @@ func NamesMap() map[string]uint32 { "searchChatMembers": SearchChatMembersRequestTypeID, "getChatAdministrators": GetChatAdministratorsRequestTypeID, "clearAllDraftMessages": ClearAllDraftMessagesRequestTypeID, + "getSavedNotificationSound": GetSavedNotificationSoundRequestTypeID, + "getSavedNotificationSounds": GetSavedNotificationSoundsRequestTypeID, + "addSavedNotificationSound": AddSavedNotificationSoundRequestTypeID, + "removeSavedNotificationSound": RemoveSavedNotificationSoundRequestTypeID, "getChatNotificationSettingsExceptions": GetChatNotificationSettingsExceptionsRequestTypeID, "getScopeNotificationSettings": GetScopeNotificationSettingsRequestTypeID, "setScopeNotificationSettings": SetScopeNotificationSettingsRequestTypeID, "resetAllNotificationSettings": ResetAllNotificationSettingsRequestTypeID, "toggleChatIsPinned": ToggleChatIsPinnedRequestTypeID, "setPinnedChats": SetPinnedChatsRequestTypeID, + "getAttachmentMenuBot": GetAttachmentMenuBotRequestTypeID, + "toggleBotIsAddedToAttachmentMenu": ToggleBotIsAddedToAttachmentMenuRequestTypeID, "downloadFile": DownloadFileRequestTypeID, "getFileDownloadedPrefixSize": GetFileDownloadedPrefixSizeRequestTypeID, "cancelDownloadFile": CancelDownloadFileRequestTypeID, @@ -2844,6 +2910,10 @@ func NamesMap() map[string]uint32 { "setCommands": SetCommandsRequestTypeID, "deleteCommands": DeleteCommandsRequestTypeID, "getCommands": GetCommandsRequestTypeID, + "setMenuButton": SetMenuButtonRequestTypeID, + "getMenuButton": GetMenuButtonRequestTypeID, + "setDefaultGroupAdministratorRights": SetDefaultGroupAdministratorRightsRequestTypeID, + "setDefaultChannelAdministratorRights": SetDefaultChannelAdministratorRightsRequestTypeID, "getActiveSessions": GetActiveSessionsRequestTypeID, "terminateSession": TerminateSessionRequestTypeID, "terminateAllOtherSessions": TerminateAllOtherSessionsRequestTypeID, @@ -3076,6 +3146,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { UserTypeUnknownTypeID: func() bin.Object { return &UserTypeUnknown{} }, BotCommandTypeID: func() bin.Object { return &BotCommand{} }, BotCommandsTypeID: func() bin.Object { return &BotCommands{} }, + BotMenuButtonTypeID: func() bin.Object { return &BotMenuButton{} }, ChatLocationTypeID: func() bin.Object { return &ChatLocation{} }, AnimatedChatPhotoTypeID: func() bin.Object { return &AnimatedChatPhoto{} }, ChatPhotoTypeID: func() bin.Object { return &ChatPhoto{} }, @@ -3083,12 +3154,14 @@ func TypesConstructorMap() map[uint32]func() bin.Object { InputChatPhotoPreviousTypeID: func() bin.Object { return &InputChatPhotoPrevious{} }, InputChatPhotoStaticTypeID: func() bin.Object { return &InputChatPhotoStatic{} }, InputChatPhotoAnimationTypeID: func() bin.Object { return &InputChatPhotoAnimation{} }, + ChatPermissionsTypeID: func() bin.Object { return &ChatPermissions{} }, + ChatAdministratorRightsTypeID: func() bin.Object { return &ChatAdministratorRights{} }, UserTypeID: func() bin.Object { return &User{} }, + BotInfoTypeID: func() bin.Object { return &BotInfo{} }, UserFullInfoTypeID: func() bin.Object { return &UserFullInfo{} }, UsersTypeID: func() bin.Object { return &Users{} }, ChatAdministratorTypeID: func() bin.Object { return &ChatAdministrator{} }, ChatAdministratorsTypeID: func() bin.Object { return &ChatAdministrators{} }, - ChatPermissionsTypeID: func() bin.Object { return &ChatPermissions{} }, ChatMemberStatusCreatorTypeID: func() bin.Object { return &ChatMemberStatusCreator{} }, ChatMemberStatusAdministratorTypeID: func() bin.Object { return &ChatMemberStatusAdministrator{} }, ChatMemberStatusMemberTypeID: func() bin.Object { return &ChatMemberStatusMember{} }, @@ -3195,9 +3268,11 @@ func TypesConstructorMap() map[uint32]func() bin.Object { KeyboardButtonTypeRequestPhoneNumberTypeID: func() bin.Object { return &KeyboardButtonTypeRequestPhoneNumber{} }, KeyboardButtonTypeRequestLocationTypeID: func() bin.Object { return &KeyboardButtonTypeRequestLocation{} }, KeyboardButtonTypeRequestPollTypeID: func() bin.Object { return &KeyboardButtonTypeRequestPoll{} }, + KeyboardButtonTypeWebAppTypeID: func() bin.Object { return &KeyboardButtonTypeWebApp{} }, KeyboardButtonTypeID: func() bin.Object { return &KeyboardButton{} }, InlineKeyboardButtonTypeURLTypeID: func() bin.Object { return &InlineKeyboardButtonTypeURL{} }, InlineKeyboardButtonTypeLoginURLTypeID: func() bin.Object { return &InlineKeyboardButtonTypeLoginURL{} }, + InlineKeyboardButtonTypeWebAppTypeID: func() bin.Object { return &InlineKeyboardButtonTypeWebApp{} }, InlineKeyboardButtonTypeCallbackTypeID: func() bin.Object { return &InlineKeyboardButtonTypeCallback{} }, InlineKeyboardButtonTypeCallbackWithPasswordTypeID: func() bin.Object { return &InlineKeyboardButtonTypeCallbackWithPassword{} }, InlineKeyboardButtonTypeCallbackGameTypeID: func() bin.Object { return &InlineKeyboardButtonTypeCallbackGame{} }, @@ -3211,6 +3286,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { ReplyMarkupInlineKeyboardTypeID: func() bin.Object { return &ReplyMarkupInlineKeyboard{} }, LoginURLInfoOpenTypeID: func() bin.Object { return &LoginURLInfoOpen{} }, LoginURLInfoRequestConfirmationTypeID: func() bin.Object { return &LoginURLInfoRequestConfirmation{} }, + WebAppInfoTypeID: func() bin.Object { return &WebAppInfo{} }, MessageThreadInfoTypeID: func() bin.Object { return &MessageThreadInfo{} }, RichTextPlainTypeID: func() bin.Object { return &RichTextPlain{} }, RichTextBoldTypeID: func() bin.Object { return &RichTextBold{} }, @@ -3276,6 +3352,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { BankCardActionOpenURLTypeID: func() bin.Object { return &BankCardActionOpenURL{} }, BankCardInfoTypeID: func() bin.Object { return &BankCardInfo{} }, AddressTypeID: func() bin.Object { return &Address{} }, + ThemeParametersTypeID: func() bin.Object { return &ThemeParameters{} }, LabeledPricePartTypeID: func() bin.Object { return &LabeledPricePart{} }, InvoiceTypeID: func() bin.Object { return &Invoice{} }, OrderInfoTypeID: func() bin.Object { return &OrderInfo{} }, @@ -3286,7 +3363,6 @@ func TypesConstructorMap() map[uint32]func() bin.Object { InputCredentialsApplePayTypeID: func() bin.Object { return &InputCredentialsApplePay{} }, InputCredentialsGooglePayTypeID: func() bin.Object { return &InputCredentialsGooglePay{} }, PaymentsProviderStripeTypeID: func() bin.Object { return &PaymentsProviderStripe{} }, - PaymentFormThemeTypeID: func() bin.Object { return &PaymentFormTheme{} }, PaymentFormTypeID: func() bin.Object { return &PaymentForm{} }, ValidatedOrderInfoTypeID: func() bin.Object { return &ValidatedOrderInfo{} }, PaymentResultTypeID: func() bin.Object { return &PaymentResult{} }, @@ -3409,6 +3485,8 @@ func TypesConstructorMap() map[uint32]func() bin.Object { MessagePaymentSuccessfulBotTypeID: func() bin.Object { return &MessagePaymentSuccessfulBot{} }, MessageContactRegisteredTypeID: func() bin.Object { return &MessageContactRegistered{} }, MessageWebsiteConnectedTypeID: func() bin.Object { return &MessageWebsiteConnected{} }, + MessageWebAppDataSentTypeID: func() bin.Object { return &MessageWebAppDataSent{} }, + MessageWebAppDataReceivedTypeID: func() bin.Object { return &MessageWebAppDataReceived{} }, MessagePassportDataSentTypeID: func() bin.Object { return &MessagePassportDataSent{} }, MessagePassportDataReceivedTypeID: func() bin.Object { return &MessagePassportDataReceived{} }, MessageProximityAlertTriggeredTypeID: func() bin.Object { return &MessageProximityAlertTriggered{} }, @@ -3544,6 +3622,9 @@ func TypesConstructorMap() map[uint32]func() bin.Object { DiceStickersRegularTypeID: func() bin.Object { return &DiceStickersRegular{} }, DiceStickersSlotMachineTypeID: func() bin.Object { return &DiceStickersSlotMachine{} }, ImportedContactsTypeID: func() bin.Object { return &ImportedContacts{} }, + AttachmentMenuBotColorTypeID: func() bin.Object { return &AttachmentMenuBotColor{} }, + AttachmentMenuBotTypeID: func() bin.Object { return &AttachmentMenuBot{} }, + SentWebAppMessageTypeID: func() bin.Object { return &SentWebAppMessage{} }, HTTPURLTypeID: func() bin.Object { return &HTTPURL{} }, InputInlineQueryResultAnimationTypeID: func() bin.Object { return &InputInlineQueryResultAnimation{} }, InputInlineQueryResultArticleTypeID: func() bin.Object { return &InputInlineQueryResultArticle{} }, @@ -3701,6 +3782,8 @@ func TypesConstructorMap() map[uint32]func() bin.Object { NotificationGroupTypeMentionsTypeID: func() bin.Object { return &NotificationGroupTypeMentions{} }, NotificationGroupTypeSecretChatTypeID: func() bin.Object { return &NotificationGroupTypeSecretChat{} }, NotificationGroupTypeCallsTypeID: func() bin.Object { return &NotificationGroupTypeCalls{} }, + NotificationSoundTypeID: func() bin.Object { return &NotificationSound{} }, + NotificationSoundsTypeID: func() bin.Object { return &NotificationSounds{} }, NotificationTypeID: func() bin.Object { return &Notification{} }, NotificationGroupTypeID: func() bin.Object { return &NotificationGroup{} }, OptionValueBooleanTypeID: func() bin.Object { return &OptionValueBoolean{} }, @@ -3747,10 +3830,12 @@ func TypesConstructorMap() map[uint32]func() bin.Object { ChatReportReasonPersonalDetailsTypeID: func() bin.Object { return &ChatReportReasonPersonalDetails{} }, ChatReportReasonCustomTypeID: func() bin.Object { return &ChatReportReasonCustom{} }, InternalLinkTypeActiveSessionsTypeID: func() bin.Object { return &InternalLinkTypeActiveSessions{} }, + InternalLinkTypeAttachmentMenuBotTypeID: func() bin.Object { return &InternalLinkTypeAttachmentMenuBot{} }, InternalLinkTypeAuthenticationCodeTypeID: func() bin.Object { return &InternalLinkTypeAuthenticationCode{} }, InternalLinkTypeBackgroundTypeID: func() bin.Object { return &InternalLinkTypeBackground{} }, InternalLinkTypeBotStartTypeID: func() bin.Object { return &InternalLinkTypeBotStart{} }, InternalLinkTypeBotStartInGroupTypeID: func() bin.Object { return &InternalLinkTypeBotStartInGroup{} }, + InternalLinkTypeBotAddToChannelTypeID: func() bin.Object { return &InternalLinkTypeBotAddToChannel{} }, InternalLinkTypeChangePhoneNumberTypeID: func() bin.Object { return &InternalLinkTypeChangePhoneNumber{} }, InternalLinkTypeChatInviteTypeID: func() bin.Object { return &InternalLinkTypeChatInvite{} }, InternalLinkTypeFilterSettingsTypeID: func() bin.Object { return &InternalLinkTypeFilterSettings{} }, @@ -3780,6 +3865,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { FileTypeAnimationTypeID: func() bin.Object { return &FileTypeAnimation{} }, FileTypeAudioTypeID: func() bin.Object { return &FileTypeAudio{} }, FileTypeDocumentTypeID: func() bin.Object { return &FileTypeDocument{} }, + FileTypeNotificationSoundTypeID: func() bin.Object { return &FileTypeNotificationSound{} }, FileTypePhotoTypeID: func() bin.Object { return &FileTypePhoto{} }, FileTypeProfilePhotoTypeID: func() bin.Object { return &FileTypeProfilePhoto{} }, FileTypeSecretTypeID: func() bin.Object { return &FileTypeSecret{} }, @@ -3942,12 +4028,15 @@ func TypesConstructorMap() map[uint32]func() bin.Object { UpdateRecentStickersTypeID: func() bin.Object { return &UpdateRecentStickers{} }, UpdateFavoriteStickersTypeID: func() bin.Object { return &UpdateFavoriteStickers{} }, UpdateSavedAnimationsTypeID: func() bin.Object { return &UpdateSavedAnimations{} }, + UpdateSavedNotificationSoundsTypeID: func() bin.Object { return &UpdateSavedNotificationSounds{} }, UpdateSelectedBackgroundTypeID: func() bin.Object { return &UpdateSelectedBackground{} }, UpdateChatThemesTypeID: func() bin.Object { return &UpdateChatThemes{} }, UpdateLanguagePackStringsTypeID: func() bin.Object { return &UpdateLanguagePackStrings{} }, UpdateConnectionStateTypeID: func() bin.Object { return &UpdateConnectionState{} }, UpdateTermsOfServiceTypeID: func() bin.Object { return &UpdateTermsOfService{} }, UpdateUsersNearbyTypeID: func() bin.Object { return &UpdateUsersNearby{} }, + UpdateAttachmentMenuBotsTypeID: func() bin.Object { return &UpdateAttachmentMenuBots{} }, + UpdateWebAppMessageSentTypeID: func() bin.Object { return &UpdateWebAppMessageSent{} }, UpdateReactionsTypeID: func() bin.Object { return &UpdateReactions{} }, UpdateDiceEmojisTypeID: func() bin.Object { return &UpdateDiceEmojis{} }, UpdateAnimatedEmojiMessageClickedTypeID: func() bin.Object { return &UpdateAnimatedEmojiMessageClicked{} }, @@ -4110,6 +4199,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { GetLanguagePackStringRequestTypeID: func() bin.Object { return &GetLanguagePackStringRequest{} }, GetJSONValueRequestTypeID: func() bin.Object { return &GetJSONValueRequest{} }, GetJSONStringRequestTypeID: func() bin.Object { return &GetJSONStringRequest{} }, + GetThemeParametersJSONStringRequestTypeID: func() bin.Object { return &GetThemeParametersJSONStringRequest{} }, SetPollAnswerRequestTypeID: func() bin.Object { return &SetPollAnswerRequest{} }, GetPollVotersRequestTypeID: func() bin.Object { return &GetPollVotersRequest{} }, StopPollRequestTypeID: func() bin.Object { return &StopPollRequest{} }, @@ -4118,6 +4208,11 @@ func TypesConstructorMap() map[uint32]func() bin.Object { GetLoginURLRequestTypeID: func() bin.Object { return &GetLoginURLRequest{} }, GetInlineQueryResultsRequestTypeID: func() bin.Object { return &GetInlineQueryResultsRequest{} }, AnswerInlineQueryRequestTypeID: func() bin.Object { return &AnswerInlineQueryRequest{} }, + GetWebAppURLRequestTypeID: func() bin.Object { return &GetWebAppURLRequest{} }, + SendWebAppDataRequestTypeID: func() bin.Object { return &SendWebAppDataRequest{} }, + OpenWebAppRequestTypeID: func() bin.Object { return &OpenWebAppRequest{} }, + CloseWebAppRequestTypeID: func() bin.Object { return &CloseWebAppRequest{} }, + AnswerWebAppQueryRequestTypeID: func() bin.Object { return &AnswerWebAppQueryRequest{} }, GetCallbackQueryAnswerRequestTypeID: func() bin.Object { return &GetCallbackQueryAnswerRequest{} }, AnswerCallbackQueryRequestTypeID: func() bin.Object { return &AnswerCallbackQueryRequest{} }, AnswerShippingQueryRequestTypeID: func() bin.Object { return &AnswerShippingQueryRequest{} }, @@ -4186,12 +4281,18 @@ func TypesConstructorMap() map[uint32]func() bin.Object { SearchChatMembersRequestTypeID: func() bin.Object { return &SearchChatMembersRequest{} }, GetChatAdministratorsRequestTypeID: func() bin.Object { return &GetChatAdministratorsRequest{} }, ClearAllDraftMessagesRequestTypeID: func() bin.Object { return &ClearAllDraftMessagesRequest{} }, + GetSavedNotificationSoundRequestTypeID: func() bin.Object { return &GetSavedNotificationSoundRequest{} }, + GetSavedNotificationSoundsRequestTypeID: func() bin.Object { return &GetSavedNotificationSoundsRequest{} }, + AddSavedNotificationSoundRequestTypeID: func() bin.Object { return &AddSavedNotificationSoundRequest{} }, + RemoveSavedNotificationSoundRequestTypeID: func() bin.Object { return &RemoveSavedNotificationSoundRequest{} }, GetChatNotificationSettingsExceptionsRequestTypeID: func() bin.Object { return &GetChatNotificationSettingsExceptionsRequest{} }, GetScopeNotificationSettingsRequestTypeID: func() bin.Object { return &GetScopeNotificationSettingsRequest{} }, SetScopeNotificationSettingsRequestTypeID: func() bin.Object { return &SetScopeNotificationSettingsRequest{} }, ResetAllNotificationSettingsRequestTypeID: func() bin.Object { return &ResetAllNotificationSettingsRequest{} }, ToggleChatIsPinnedRequestTypeID: func() bin.Object { return &ToggleChatIsPinnedRequest{} }, SetPinnedChatsRequestTypeID: func() bin.Object { return &SetPinnedChatsRequest{} }, + GetAttachmentMenuBotRequestTypeID: func() bin.Object { return &GetAttachmentMenuBotRequest{} }, + ToggleBotIsAddedToAttachmentMenuRequestTypeID: func() bin.Object { return &ToggleBotIsAddedToAttachmentMenuRequest{} }, DownloadFileRequestTypeID: func() bin.Object { return &DownloadFileRequest{} }, GetFileDownloadedPrefixSizeRequestTypeID: func() bin.Object { return &GetFileDownloadedPrefixSizeRequest{} }, CancelDownloadFileRequestTypeID: func() bin.Object { return &CancelDownloadFileRequest{} }, @@ -4321,6 +4422,10 @@ func TypesConstructorMap() map[uint32]func() bin.Object { SetCommandsRequestTypeID: func() bin.Object { return &SetCommandsRequest{} }, DeleteCommandsRequestTypeID: func() bin.Object { return &DeleteCommandsRequest{} }, GetCommandsRequestTypeID: func() bin.Object { return &GetCommandsRequest{} }, + SetMenuButtonRequestTypeID: func() bin.Object { return &SetMenuButtonRequest{} }, + GetMenuButtonRequestTypeID: func() bin.Object { return &GetMenuButtonRequest{} }, + SetDefaultGroupAdministratorRightsRequestTypeID: func() bin.Object { return &SetDefaultGroupAdministratorRightsRequest{} }, + SetDefaultChannelAdministratorRightsRequestTypeID: func() bin.Object { return &SetDefaultChannelAdministratorRightsRequest{} }, GetActiveSessionsRequestTypeID: func() bin.Object { return &GetActiveSessionsRequest{} }, TerminateSessionRequestTypeID: func() bin.Object { return &TerminateSessionRequest{} }, TerminateAllOtherSessionsRequestTypeID: func() bin.Object { return &TerminateAllOtherSessionsRequest{} }, @@ -4701,6 +4806,7 @@ func ClassConstructorsMap() map[string][]uint32 { FileTypeAnimationTypeID, FileTypeAudioTypeID, FileTypeDocumentTypeID, + FileTypeNotificationSoundTypeID, FileTypePhotoTypeID, FileTypeProfilePhotoTypeID, FileTypeSecretTypeID, @@ -4722,6 +4828,7 @@ func ClassConstructorsMap() map[string][]uint32 { InlineKeyboardButtonTypeClassName: { InlineKeyboardButtonTypeURLTypeID, InlineKeyboardButtonTypeLoginURLTypeID, + InlineKeyboardButtonTypeWebAppTypeID, InlineKeyboardButtonTypeCallbackTypeID, InlineKeyboardButtonTypeCallbackWithPasswordTypeID, InlineKeyboardButtonTypeCallbackGameTypeID, @@ -4825,10 +4932,12 @@ func ClassConstructorsMap() map[string][]uint32 { }, InternalLinkTypeClassName: { InternalLinkTypeActiveSessionsTypeID, + InternalLinkTypeAttachmentMenuBotTypeID, InternalLinkTypeAuthenticationCodeTypeID, InternalLinkTypeBackgroundTypeID, InternalLinkTypeBotStartTypeID, InternalLinkTypeBotStartInGroupTypeID, + InternalLinkTypeBotAddToChannelTypeID, InternalLinkTypeChangePhoneNumberTypeID, InternalLinkTypeChatInviteTypeID, InternalLinkTypeFilterSettingsTypeID, @@ -4865,6 +4974,7 @@ func ClassConstructorsMap() map[string][]uint32 { KeyboardButtonTypeRequestPhoneNumberTypeID, KeyboardButtonTypeRequestLocationTypeID, KeyboardButtonTypeRequestPollTypeID, + KeyboardButtonTypeWebAppTypeID, }, LanguagePackStringValueClassName: { LanguagePackStringValueOrdinaryTypeID, @@ -4932,6 +5042,8 @@ func ClassConstructorsMap() map[string][]uint32 { MessagePaymentSuccessfulBotTypeID, MessageContactRegisteredTypeID, MessageWebsiteConnectedTypeID, + MessageWebAppDataSentTypeID, + MessageWebAppDataReceivedTypeID, MessagePassportDataSentTypeID, MessagePassportDataReceivedTypeID, MessageProximityAlertTriggeredTypeID, @@ -5330,12 +5442,15 @@ func ClassConstructorsMap() map[string][]uint32 { UpdateRecentStickersTypeID, UpdateFavoriteStickersTypeID, UpdateSavedAnimationsTypeID, + UpdateSavedNotificationSoundsTypeID, UpdateSelectedBackgroundTypeID, UpdateChatThemesTypeID, UpdateLanguagePackStringsTypeID, UpdateConnectionStateTypeID, UpdateTermsOfServiceTypeID, UpdateUsersNearbyTypeID, + UpdateAttachmentMenuBotsTypeID, + UpdateWebAppMessageSentTypeID, UpdateReactionsTypeID, UpdateDiceEmojisTypeID, UpdateAnimatedEmojiMessageClickedTypeID, diff --git a/tdapi/tl_remove_saved_notification_sound_gen.go b/tdapi/tl_remove_saved_notification_sound_gen.go new file mode 100644 index 0000000000..180aade97e --- /dev/null +++ b/tdapi/tl_remove_saved_notification_sound_gen.go @@ -0,0 +1,206 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// RemoveSavedNotificationSoundRequest represents TL type `removeSavedNotificationSound#e363474e`. +type RemoveSavedNotificationSoundRequest struct { + // Identifier of the notification sound + NotificationSoundID int64 +} + +// RemoveSavedNotificationSoundRequestTypeID is TL type id of RemoveSavedNotificationSoundRequest. +const RemoveSavedNotificationSoundRequestTypeID = 0xe363474e + +// Ensuring interfaces in compile-time for RemoveSavedNotificationSoundRequest. +var ( + _ bin.Encoder = &RemoveSavedNotificationSoundRequest{} + _ bin.Decoder = &RemoveSavedNotificationSoundRequest{} + _ bin.BareEncoder = &RemoveSavedNotificationSoundRequest{} + _ bin.BareDecoder = &RemoveSavedNotificationSoundRequest{} +) + +func (r *RemoveSavedNotificationSoundRequest) Zero() bool { + if r == nil { + return true + } + if !(r.NotificationSoundID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (r *RemoveSavedNotificationSoundRequest) String() string { + if r == nil { + return "RemoveSavedNotificationSoundRequest(nil)" + } + type Alias RemoveSavedNotificationSoundRequest + return fmt.Sprintf("RemoveSavedNotificationSoundRequest%+v", Alias(*r)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*RemoveSavedNotificationSoundRequest) TypeID() uint32 { + return RemoveSavedNotificationSoundRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*RemoveSavedNotificationSoundRequest) TypeName() string { + return "removeSavedNotificationSound" +} + +// TypeInfo returns info about TL type. +func (r *RemoveSavedNotificationSoundRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "removeSavedNotificationSound", + ID: RemoveSavedNotificationSoundRequestTypeID, + } + if r == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "NotificationSoundID", + SchemaName: "notification_sound_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (r *RemoveSavedNotificationSoundRequest) Encode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode removeSavedNotificationSound#e363474e as nil") + } + b.PutID(RemoveSavedNotificationSoundRequestTypeID) + return r.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (r *RemoveSavedNotificationSoundRequest) EncodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't encode removeSavedNotificationSound#e363474e as nil") + } + b.PutLong(r.NotificationSoundID) + return nil +} + +// Decode implements bin.Decoder. +func (r *RemoveSavedNotificationSoundRequest) Decode(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode removeSavedNotificationSound#e363474e to nil") + } + if err := b.ConsumeID(RemoveSavedNotificationSoundRequestTypeID); err != nil { + return fmt.Errorf("unable to decode removeSavedNotificationSound#e363474e: %w", err) + } + return r.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (r *RemoveSavedNotificationSoundRequest) DecodeBare(b *bin.Buffer) error { + if r == nil { + return fmt.Errorf("can't decode removeSavedNotificationSound#e363474e to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode removeSavedNotificationSound#e363474e: field notification_sound_id: %w", err) + } + r.NotificationSoundID = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (r *RemoveSavedNotificationSoundRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if r == nil { + return fmt.Errorf("can't encode removeSavedNotificationSound#e363474e as nil") + } + b.ObjStart() + b.PutID("removeSavedNotificationSound") + b.Comma() + b.FieldStart("notification_sound_id") + b.PutLong(r.NotificationSoundID) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (r *RemoveSavedNotificationSoundRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if r == nil { + return fmt.Errorf("can't decode removeSavedNotificationSound#e363474e to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("removeSavedNotificationSound"); err != nil { + return fmt.Errorf("unable to decode removeSavedNotificationSound#e363474e: %w", err) + } + case "notification_sound_id": + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode removeSavedNotificationSound#e363474e: field notification_sound_id: %w", err) + } + r.NotificationSoundID = value + default: + return b.Skip() + } + return nil + }) +} + +// GetNotificationSoundID returns value of NotificationSoundID field. +func (r *RemoveSavedNotificationSoundRequest) GetNotificationSoundID() (value int64) { + if r == nil { + return + } + return r.NotificationSoundID +} + +// RemoveSavedNotificationSound invokes method removeSavedNotificationSound#e363474e returning error if any. +func (c *Client) RemoveSavedNotificationSound(ctx context.Context, notificationsoundid int64) error { + var ok Ok + + request := &RemoveSavedNotificationSoundRequest{ + NotificationSoundID: notificationsoundid, + } + if err := c.rpc.Invoke(ctx, request, &ok); err != nil { + return err + } + return nil +} diff --git a/tdapi/tl_scope_notification_settings_gen.go b/tdapi/tl_scope_notification_settings_gen.go index 3529841a99..258975ee52 100644 --- a/tdapi/tl_scope_notification_settings_gen.go +++ b/tdapi/tl_scope_notification_settings_gen.go @@ -31,13 +31,12 @@ var ( _ = tdjson.Encoder{} ) -// ScopeNotificationSettings represents TL type `scopeNotificationSettings#e69a2c3f`. +// ScopeNotificationSettings represents TL type `scopeNotificationSettings#ad8a189b`. type ScopeNotificationSettings struct { // Time left before notifications will be unmuted, in seconds MuteFor int32 - // The name of an audio file to be used for notification sounds; only applies to iOS - // applications - Sound string + // Identifier of the notification sound to be played; 0 if sound is disabled + SoundID int64 // True, if message content must be displayed in notifications ShowPreview bool // True, if notifications for incoming pinned messages will be created as for an ordinary @@ -49,7 +48,7 @@ type ScopeNotificationSettings struct { } // ScopeNotificationSettingsTypeID is TL type id of ScopeNotificationSettings. -const ScopeNotificationSettingsTypeID = 0xe69a2c3f +const ScopeNotificationSettingsTypeID = 0xad8a189b // Ensuring interfaces in compile-time for ScopeNotificationSettings. var ( @@ -66,7 +65,7 @@ func (s *ScopeNotificationSettings) Zero() bool { if !(s.MuteFor == 0) { return false } - if !(s.Sound == "") { + if !(s.SoundID == 0) { return false } if !(s.ShowPreview == false) { @@ -119,8 +118,8 @@ func (s *ScopeNotificationSettings) TypeInfo() tdp.Type { SchemaName: "mute_for", }, { - Name: "Sound", - SchemaName: "sound", + Name: "SoundID", + SchemaName: "sound_id", }, { Name: "ShowPreview", @@ -141,7 +140,7 @@ func (s *ScopeNotificationSettings) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (s *ScopeNotificationSettings) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode scopeNotificationSettings#e69a2c3f as nil") + return fmt.Errorf("can't encode scopeNotificationSettings#ad8a189b as nil") } b.PutID(ScopeNotificationSettingsTypeID) return s.EncodeBare(b) @@ -150,10 +149,10 @@ func (s *ScopeNotificationSettings) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *ScopeNotificationSettings) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode scopeNotificationSettings#e69a2c3f as nil") + return fmt.Errorf("can't encode scopeNotificationSettings#ad8a189b as nil") } b.PutInt32(s.MuteFor) - b.PutString(s.Sound) + b.PutLong(s.SoundID) b.PutBool(s.ShowPreview) b.PutBool(s.DisablePinnedMessageNotifications) b.PutBool(s.DisableMentionNotifications) @@ -163,10 +162,10 @@ func (s *ScopeNotificationSettings) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *ScopeNotificationSettings) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode scopeNotificationSettings#e69a2c3f to nil") + return fmt.Errorf("can't decode scopeNotificationSettings#ad8a189b to nil") } if err := b.ConsumeID(ScopeNotificationSettingsTypeID); err != nil { - return fmt.Errorf("unable to decode scopeNotificationSettings#e69a2c3f: %w", err) + return fmt.Errorf("unable to decode scopeNotificationSettings#ad8a189b: %w", err) } return s.DecodeBare(b) } @@ -174,40 +173,40 @@ func (s *ScopeNotificationSettings) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *ScopeNotificationSettings) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode scopeNotificationSettings#e69a2c3f to nil") + return fmt.Errorf("can't decode scopeNotificationSettings#ad8a189b to nil") } { value, err := b.Int32() if err != nil { - return fmt.Errorf("unable to decode scopeNotificationSettings#e69a2c3f: field mute_for: %w", err) + return fmt.Errorf("unable to decode scopeNotificationSettings#ad8a189b: field mute_for: %w", err) } s.MuteFor = value } { - value, err := b.String() + value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode scopeNotificationSettings#e69a2c3f: field sound: %w", err) + return fmt.Errorf("unable to decode scopeNotificationSettings#ad8a189b: field sound_id: %w", err) } - s.Sound = value + s.SoundID = value } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode scopeNotificationSettings#e69a2c3f: field show_preview: %w", err) + return fmt.Errorf("unable to decode scopeNotificationSettings#ad8a189b: field show_preview: %w", err) } s.ShowPreview = value } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode scopeNotificationSettings#e69a2c3f: field disable_pinned_message_notifications: %w", err) + return fmt.Errorf("unable to decode scopeNotificationSettings#ad8a189b: field disable_pinned_message_notifications: %w", err) } s.DisablePinnedMessageNotifications = value } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode scopeNotificationSettings#e69a2c3f: field disable_mention_notifications: %w", err) + return fmt.Errorf("unable to decode scopeNotificationSettings#ad8a189b: field disable_mention_notifications: %w", err) } s.DisableMentionNotifications = value } @@ -217,7 +216,7 @@ func (s *ScopeNotificationSettings) DecodeBare(b *bin.Buffer) error { // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (s *ScopeNotificationSettings) EncodeTDLibJSON(b tdjson.Encoder) error { if s == nil { - return fmt.Errorf("can't encode scopeNotificationSettings#e69a2c3f as nil") + return fmt.Errorf("can't encode scopeNotificationSettings#ad8a189b as nil") } b.ObjStart() b.PutID("scopeNotificationSettings") @@ -225,8 +224,8 @@ func (s *ScopeNotificationSettings) EncodeTDLibJSON(b tdjson.Encoder) error { b.FieldStart("mute_for") b.PutInt32(s.MuteFor) b.Comma() - b.FieldStart("sound") - b.PutString(s.Sound) + b.FieldStart("sound_id") + b.PutLong(s.SoundID) b.Comma() b.FieldStart("show_preview") b.PutBool(s.ShowPreview) @@ -245,43 +244,43 @@ func (s *ScopeNotificationSettings) EncodeTDLibJSON(b tdjson.Encoder) error { // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (s *ScopeNotificationSettings) DecodeTDLibJSON(b tdjson.Decoder) error { if s == nil { - return fmt.Errorf("can't decode scopeNotificationSettings#e69a2c3f to nil") + return fmt.Errorf("can't decode scopeNotificationSettings#ad8a189b to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("scopeNotificationSettings"); err != nil { - return fmt.Errorf("unable to decode scopeNotificationSettings#e69a2c3f: %w", err) + return fmt.Errorf("unable to decode scopeNotificationSettings#ad8a189b: %w", err) } case "mute_for": value, err := b.Int32() if err != nil { - return fmt.Errorf("unable to decode scopeNotificationSettings#e69a2c3f: field mute_for: %w", err) + return fmt.Errorf("unable to decode scopeNotificationSettings#ad8a189b: field mute_for: %w", err) } s.MuteFor = value - case "sound": - value, err := b.String() + case "sound_id": + value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode scopeNotificationSettings#e69a2c3f: field sound: %w", err) + return fmt.Errorf("unable to decode scopeNotificationSettings#ad8a189b: field sound_id: %w", err) } - s.Sound = value + s.SoundID = value case "show_preview": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode scopeNotificationSettings#e69a2c3f: field show_preview: %w", err) + return fmt.Errorf("unable to decode scopeNotificationSettings#ad8a189b: field show_preview: %w", err) } s.ShowPreview = value case "disable_pinned_message_notifications": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode scopeNotificationSettings#e69a2c3f: field disable_pinned_message_notifications: %w", err) + return fmt.Errorf("unable to decode scopeNotificationSettings#ad8a189b: field disable_pinned_message_notifications: %w", err) } s.DisablePinnedMessageNotifications = value case "disable_mention_notifications": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode scopeNotificationSettings#e69a2c3f: field disable_mention_notifications: %w", err) + return fmt.Errorf("unable to decode scopeNotificationSettings#ad8a189b: field disable_mention_notifications: %w", err) } s.DisableMentionNotifications = value default: @@ -299,12 +298,12 @@ func (s *ScopeNotificationSettings) GetMuteFor() (value int32) { return s.MuteFor } -// GetSound returns value of Sound field. -func (s *ScopeNotificationSettings) GetSound() (value string) { +// GetSoundID returns value of SoundID field. +func (s *ScopeNotificationSettings) GetSoundID() (value int64) { if s == nil { return } - return s.Sound + return s.SoundID } // GetShowPreview returns value of ShowPreview field. diff --git a/tdapi/tl_send_inline_query_result_message_gen.go b/tdapi/tl_send_inline_query_result_message_gen.go index b227c8c285..0ec27360d8 100644 --- a/tdapi/tl_send_inline_query_result_message_gen.go +++ b/tdapi/tl_send_inline_query_result_message_gen.go @@ -37,7 +37,7 @@ type SendInlineQueryResultMessageRequest struct { ChatID int64 // If not 0, a message thread identifier in which the message will be sent MessageThreadID int64 - // Identifier of a message to reply to or 0 + // Identifier of a replied message; 0 if none ReplyToMessageID int64 // Options to be used to send the message; pass null to use default options Options MessageSendOptions diff --git a/tdapi/tl_send_message_album_gen.go b/tdapi/tl_send_message_album_gen.go index 8570528f70..da09f41843 100644 --- a/tdapi/tl_send_message_album_gen.go +++ b/tdapi/tl_send_message_album_gen.go @@ -37,7 +37,7 @@ type SendMessageAlbumRequest struct { ChatID int64 // If not 0, a message thread identifier in which the messages will be sent MessageThreadID int64 - // Identifier of a message to reply to or 0 + // Identifier of a replied message; 0 if none ReplyToMessageID int64 // Options to be used to send the messages; pass null to use default options Options MessageSendOptions diff --git a/tdapi/tl_send_message_gen.go b/tdapi/tl_send_message_gen.go index 87e759de9e..a133c73d72 100644 --- a/tdapi/tl_send_message_gen.go +++ b/tdapi/tl_send_message_gen.go @@ -37,7 +37,7 @@ type SendMessageRequest struct { ChatID int64 // If not 0, a message thread identifier in which the message will be sent MessageThreadID int64 - // Identifier of the message to reply to or 0 + // Identifier of the replied message; 0 if none ReplyToMessageID int64 // Options to be used to send the message; pass null to use default options Options MessageSendOptions diff --git a/tdapi/tl_send_web_app_data_gen.go b/tdapi/tl_send_web_app_data_gen.go new file mode 100644 index 0000000000..5b6bf14739 --- /dev/null +++ b/tdapi/tl_send_web_app_data_gen.go @@ -0,0 +1,271 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// SendWebAppDataRequest represents TL type `sendWebAppData#ab1fce0c`. +type SendWebAppDataRequest struct { + // Identifier of the target bot + BotUserID int64 + // Text of the keyboardButtonTypeWebApp button, which opened the web app + ButtonText string + // Received data + Data string +} + +// SendWebAppDataRequestTypeID is TL type id of SendWebAppDataRequest. +const SendWebAppDataRequestTypeID = 0xab1fce0c + +// Ensuring interfaces in compile-time for SendWebAppDataRequest. +var ( + _ bin.Encoder = &SendWebAppDataRequest{} + _ bin.Decoder = &SendWebAppDataRequest{} + _ bin.BareEncoder = &SendWebAppDataRequest{} + _ bin.BareDecoder = &SendWebAppDataRequest{} +) + +func (s *SendWebAppDataRequest) Zero() bool { + if s == nil { + return true + } + if !(s.BotUserID == 0) { + return false + } + if !(s.ButtonText == "") { + return false + } + if !(s.Data == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *SendWebAppDataRequest) String() string { + if s == nil { + return "SendWebAppDataRequest(nil)" + } + type Alias SendWebAppDataRequest + return fmt.Sprintf("SendWebAppDataRequest%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*SendWebAppDataRequest) TypeID() uint32 { + return SendWebAppDataRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*SendWebAppDataRequest) TypeName() string { + return "sendWebAppData" +} + +// TypeInfo returns info about TL type. +func (s *SendWebAppDataRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "sendWebAppData", + ID: SendWebAppDataRequestTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "BotUserID", + SchemaName: "bot_user_id", + }, + { + Name: "ButtonText", + SchemaName: "button_text", + }, + { + Name: "Data", + SchemaName: "data", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *SendWebAppDataRequest) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode sendWebAppData#ab1fce0c as nil") + } + b.PutID(SendWebAppDataRequestTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *SendWebAppDataRequest) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode sendWebAppData#ab1fce0c as nil") + } + b.PutInt53(s.BotUserID) + b.PutString(s.ButtonText) + b.PutString(s.Data) + return nil +} + +// Decode implements bin.Decoder. +func (s *SendWebAppDataRequest) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode sendWebAppData#ab1fce0c to nil") + } + if err := b.ConsumeID(SendWebAppDataRequestTypeID); err != nil { + return fmt.Errorf("unable to decode sendWebAppData#ab1fce0c: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *SendWebAppDataRequest) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode sendWebAppData#ab1fce0c to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode sendWebAppData#ab1fce0c: field bot_user_id: %w", err) + } + s.BotUserID = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode sendWebAppData#ab1fce0c: field button_text: %w", err) + } + s.ButtonText = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode sendWebAppData#ab1fce0c: field data: %w", err) + } + s.Data = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *SendWebAppDataRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode sendWebAppData#ab1fce0c as nil") + } + b.ObjStart() + b.PutID("sendWebAppData") + b.Comma() + b.FieldStart("bot_user_id") + b.PutInt53(s.BotUserID) + b.Comma() + b.FieldStart("button_text") + b.PutString(s.ButtonText) + b.Comma() + b.FieldStart("data") + b.PutString(s.Data) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *SendWebAppDataRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode sendWebAppData#ab1fce0c to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("sendWebAppData"); err != nil { + return fmt.Errorf("unable to decode sendWebAppData#ab1fce0c: %w", err) + } + case "bot_user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode sendWebAppData#ab1fce0c: field bot_user_id: %w", err) + } + s.BotUserID = value + case "button_text": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode sendWebAppData#ab1fce0c: field button_text: %w", err) + } + s.ButtonText = value + case "data": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode sendWebAppData#ab1fce0c: field data: %w", err) + } + s.Data = value + default: + return b.Skip() + } + return nil + }) +} + +// GetBotUserID returns value of BotUserID field. +func (s *SendWebAppDataRequest) GetBotUserID() (value int64) { + if s == nil { + return + } + return s.BotUserID +} + +// GetButtonText returns value of ButtonText field. +func (s *SendWebAppDataRequest) GetButtonText() (value string) { + if s == nil { + return + } + return s.ButtonText +} + +// GetData returns value of Data field. +func (s *SendWebAppDataRequest) GetData() (value string) { + if s == nil { + return + } + return s.Data +} + +// SendWebAppData invokes method sendWebAppData#ab1fce0c returning error if any. +func (c *Client) SendWebAppData(ctx context.Context, request *SendWebAppDataRequest) error { + var ok Ok + + if err := c.rpc.Invoke(ctx, request, &ok); err != nil { + return err + } + return nil +} diff --git a/tdapi/tl_sent_web_app_message_gen.go b/tdapi/tl_sent_web_app_message_gen.go new file mode 100644 index 0000000000..122ea35d3c --- /dev/null +++ b/tdapi/tl_sent_web_app_message_gen.go @@ -0,0 +1,193 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// SentWebAppMessage represents TL type `sentWebAppMessage#4a24eec0`. +type SentWebAppMessage struct { + // Identifier of the sent inline message, if known + InlineMessageID string +} + +// SentWebAppMessageTypeID is TL type id of SentWebAppMessage. +const SentWebAppMessageTypeID = 0x4a24eec0 + +// Ensuring interfaces in compile-time for SentWebAppMessage. +var ( + _ bin.Encoder = &SentWebAppMessage{} + _ bin.Decoder = &SentWebAppMessage{} + _ bin.BareEncoder = &SentWebAppMessage{} + _ bin.BareDecoder = &SentWebAppMessage{} +) + +func (s *SentWebAppMessage) Zero() bool { + if s == nil { + return true + } + if !(s.InlineMessageID == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *SentWebAppMessage) String() string { + if s == nil { + return "SentWebAppMessage(nil)" + } + type Alias SentWebAppMessage + return fmt.Sprintf("SentWebAppMessage%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*SentWebAppMessage) TypeID() uint32 { + return SentWebAppMessageTypeID +} + +// TypeName returns name of type in TL schema. +func (*SentWebAppMessage) TypeName() string { + return "sentWebAppMessage" +} + +// TypeInfo returns info about TL type. +func (s *SentWebAppMessage) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "sentWebAppMessage", + ID: SentWebAppMessageTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "InlineMessageID", + SchemaName: "inline_message_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *SentWebAppMessage) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode sentWebAppMessage#4a24eec0 as nil") + } + b.PutID(SentWebAppMessageTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *SentWebAppMessage) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode sentWebAppMessage#4a24eec0 as nil") + } + b.PutString(s.InlineMessageID) + return nil +} + +// Decode implements bin.Decoder. +func (s *SentWebAppMessage) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode sentWebAppMessage#4a24eec0 to nil") + } + if err := b.ConsumeID(SentWebAppMessageTypeID); err != nil { + return fmt.Errorf("unable to decode sentWebAppMessage#4a24eec0: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *SentWebAppMessage) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode sentWebAppMessage#4a24eec0 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode sentWebAppMessage#4a24eec0: field inline_message_id: %w", err) + } + s.InlineMessageID = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *SentWebAppMessage) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode sentWebAppMessage#4a24eec0 as nil") + } + b.ObjStart() + b.PutID("sentWebAppMessage") + b.Comma() + b.FieldStart("inline_message_id") + b.PutString(s.InlineMessageID) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *SentWebAppMessage) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode sentWebAppMessage#4a24eec0 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("sentWebAppMessage"); err != nil { + return fmt.Errorf("unable to decode sentWebAppMessage#4a24eec0: %w", err) + } + case "inline_message_id": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode sentWebAppMessage#4a24eec0: field inline_message_id: %w", err) + } + s.InlineMessageID = value + default: + return b.Skip() + } + return nil + }) +} + +// GetInlineMessageID returns value of InlineMessageID field. +func (s *SentWebAppMessage) GetInlineMessageID() (value string) { + if s == nil { + return + } + return s.InlineMessageID +} diff --git a/tdapi/tl_set_chat_message_ttl_gen.go b/tdapi/tl_set_chat_message_ttl_gen.go index f0b347bc55..f18b2d4e90 100644 --- a/tdapi/tl_set_chat_message_ttl_gen.go +++ b/tdapi/tl_set_chat_message_ttl_gen.go @@ -35,8 +35,8 @@ var ( type SetChatMessageTTLRequest struct { // Chat identifier ChatID int64 - // New TTL value, in seconds; must be one of 0, 86400, 7 * 86400, or 31 * 86400 unless - // the chat is secret + // New TTL value, in seconds; unless the chat is secret, it must be from 0 up to 365 * + // 86400 and be divisible by 86400 TTL int32 } diff --git a/tdapi/tl_set_default_channel_administrator_rights_gen.go b/tdapi/tl_set_default_channel_administrator_rights_gen.go new file mode 100644 index 0000000000..d629561060 --- /dev/null +++ b/tdapi/tl_set_default_channel_administrator_rights_gen.go @@ -0,0 +1,206 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// SetDefaultChannelAdministratorRightsRequest represents TL type `setDefaultChannelAdministratorRights#f20d5e19`. +type SetDefaultChannelAdministratorRightsRequest struct { + // Default administrator rights for adding the bot to channels; may be null + DefaultChannelAdministratorRights ChatAdministratorRights +} + +// SetDefaultChannelAdministratorRightsRequestTypeID is TL type id of SetDefaultChannelAdministratorRightsRequest. +const SetDefaultChannelAdministratorRightsRequestTypeID = 0xf20d5e19 + +// Ensuring interfaces in compile-time for SetDefaultChannelAdministratorRightsRequest. +var ( + _ bin.Encoder = &SetDefaultChannelAdministratorRightsRequest{} + _ bin.Decoder = &SetDefaultChannelAdministratorRightsRequest{} + _ bin.BareEncoder = &SetDefaultChannelAdministratorRightsRequest{} + _ bin.BareDecoder = &SetDefaultChannelAdministratorRightsRequest{} +) + +func (s *SetDefaultChannelAdministratorRightsRequest) Zero() bool { + if s == nil { + return true + } + if !(s.DefaultChannelAdministratorRights.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *SetDefaultChannelAdministratorRightsRequest) String() string { + if s == nil { + return "SetDefaultChannelAdministratorRightsRequest(nil)" + } + type Alias SetDefaultChannelAdministratorRightsRequest + return fmt.Sprintf("SetDefaultChannelAdministratorRightsRequest%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*SetDefaultChannelAdministratorRightsRequest) TypeID() uint32 { + return SetDefaultChannelAdministratorRightsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*SetDefaultChannelAdministratorRightsRequest) TypeName() string { + return "setDefaultChannelAdministratorRights" +} + +// TypeInfo returns info about TL type. +func (s *SetDefaultChannelAdministratorRightsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "setDefaultChannelAdministratorRights", + ID: SetDefaultChannelAdministratorRightsRequestTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "DefaultChannelAdministratorRights", + SchemaName: "default_channel_administrator_rights", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *SetDefaultChannelAdministratorRightsRequest) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode setDefaultChannelAdministratorRights#f20d5e19 as nil") + } + b.PutID(SetDefaultChannelAdministratorRightsRequestTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *SetDefaultChannelAdministratorRightsRequest) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode setDefaultChannelAdministratorRights#f20d5e19 as nil") + } + if err := s.DefaultChannelAdministratorRights.Encode(b); err != nil { + return fmt.Errorf("unable to encode setDefaultChannelAdministratorRights#f20d5e19: field default_channel_administrator_rights: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *SetDefaultChannelAdministratorRightsRequest) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode setDefaultChannelAdministratorRights#f20d5e19 to nil") + } + if err := b.ConsumeID(SetDefaultChannelAdministratorRightsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode setDefaultChannelAdministratorRights#f20d5e19: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *SetDefaultChannelAdministratorRightsRequest) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode setDefaultChannelAdministratorRights#f20d5e19 to nil") + } + { + if err := s.DefaultChannelAdministratorRights.Decode(b); err != nil { + return fmt.Errorf("unable to decode setDefaultChannelAdministratorRights#f20d5e19: field default_channel_administrator_rights: %w", err) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *SetDefaultChannelAdministratorRightsRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode setDefaultChannelAdministratorRights#f20d5e19 as nil") + } + b.ObjStart() + b.PutID("setDefaultChannelAdministratorRights") + b.Comma() + b.FieldStart("default_channel_administrator_rights") + if err := s.DefaultChannelAdministratorRights.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode setDefaultChannelAdministratorRights#f20d5e19: field default_channel_administrator_rights: %w", err) + } + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *SetDefaultChannelAdministratorRightsRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode setDefaultChannelAdministratorRights#f20d5e19 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("setDefaultChannelAdministratorRights"); err != nil { + return fmt.Errorf("unable to decode setDefaultChannelAdministratorRights#f20d5e19: %w", err) + } + case "default_channel_administrator_rights": + if err := s.DefaultChannelAdministratorRights.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode setDefaultChannelAdministratorRights#f20d5e19: field default_channel_administrator_rights: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetDefaultChannelAdministratorRights returns value of DefaultChannelAdministratorRights field. +func (s *SetDefaultChannelAdministratorRightsRequest) GetDefaultChannelAdministratorRights() (value ChatAdministratorRights) { + if s == nil { + return + } + return s.DefaultChannelAdministratorRights +} + +// SetDefaultChannelAdministratorRights invokes method setDefaultChannelAdministratorRights#f20d5e19 returning error if any. +func (c *Client) SetDefaultChannelAdministratorRights(ctx context.Context, defaultchanneladministratorrights ChatAdministratorRights) error { + var ok Ok + + request := &SetDefaultChannelAdministratorRightsRequest{ + DefaultChannelAdministratorRights: defaultchanneladministratorrights, + } + if err := c.rpc.Invoke(ctx, request, &ok); err != nil { + return err + } + return nil +} diff --git a/tdapi/tl_set_default_group_administrator_rights_gen.go b/tdapi/tl_set_default_group_administrator_rights_gen.go new file mode 100644 index 0000000000..6a5889e2f0 --- /dev/null +++ b/tdapi/tl_set_default_group_administrator_rights_gen.go @@ -0,0 +1,207 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// SetDefaultGroupAdministratorRightsRequest represents TL type `setDefaultGroupAdministratorRights#65577768`. +type SetDefaultGroupAdministratorRightsRequest struct { + // Default administrator rights for adding the bot to basic group and supergroup chats; + // may be null + DefaultGroupAdministratorRights ChatAdministratorRights +} + +// SetDefaultGroupAdministratorRightsRequestTypeID is TL type id of SetDefaultGroupAdministratorRightsRequest. +const SetDefaultGroupAdministratorRightsRequestTypeID = 0x65577768 + +// Ensuring interfaces in compile-time for SetDefaultGroupAdministratorRightsRequest. +var ( + _ bin.Encoder = &SetDefaultGroupAdministratorRightsRequest{} + _ bin.Decoder = &SetDefaultGroupAdministratorRightsRequest{} + _ bin.BareEncoder = &SetDefaultGroupAdministratorRightsRequest{} + _ bin.BareDecoder = &SetDefaultGroupAdministratorRightsRequest{} +) + +func (s *SetDefaultGroupAdministratorRightsRequest) Zero() bool { + if s == nil { + return true + } + if !(s.DefaultGroupAdministratorRights.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *SetDefaultGroupAdministratorRightsRequest) String() string { + if s == nil { + return "SetDefaultGroupAdministratorRightsRequest(nil)" + } + type Alias SetDefaultGroupAdministratorRightsRequest + return fmt.Sprintf("SetDefaultGroupAdministratorRightsRequest%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*SetDefaultGroupAdministratorRightsRequest) TypeID() uint32 { + return SetDefaultGroupAdministratorRightsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*SetDefaultGroupAdministratorRightsRequest) TypeName() string { + return "setDefaultGroupAdministratorRights" +} + +// TypeInfo returns info about TL type. +func (s *SetDefaultGroupAdministratorRightsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "setDefaultGroupAdministratorRights", + ID: SetDefaultGroupAdministratorRightsRequestTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "DefaultGroupAdministratorRights", + SchemaName: "default_group_administrator_rights", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *SetDefaultGroupAdministratorRightsRequest) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode setDefaultGroupAdministratorRights#65577768 as nil") + } + b.PutID(SetDefaultGroupAdministratorRightsRequestTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *SetDefaultGroupAdministratorRightsRequest) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode setDefaultGroupAdministratorRights#65577768 as nil") + } + if err := s.DefaultGroupAdministratorRights.Encode(b); err != nil { + return fmt.Errorf("unable to encode setDefaultGroupAdministratorRights#65577768: field default_group_administrator_rights: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *SetDefaultGroupAdministratorRightsRequest) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode setDefaultGroupAdministratorRights#65577768 to nil") + } + if err := b.ConsumeID(SetDefaultGroupAdministratorRightsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode setDefaultGroupAdministratorRights#65577768: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *SetDefaultGroupAdministratorRightsRequest) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode setDefaultGroupAdministratorRights#65577768 to nil") + } + { + if err := s.DefaultGroupAdministratorRights.Decode(b); err != nil { + return fmt.Errorf("unable to decode setDefaultGroupAdministratorRights#65577768: field default_group_administrator_rights: %w", err) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *SetDefaultGroupAdministratorRightsRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode setDefaultGroupAdministratorRights#65577768 as nil") + } + b.ObjStart() + b.PutID("setDefaultGroupAdministratorRights") + b.Comma() + b.FieldStart("default_group_administrator_rights") + if err := s.DefaultGroupAdministratorRights.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode setDefaultGroupAdministratorRights#65577768: field default_group_administrator_rights: %w", err) + } + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *SetDefaultGroupAdministratorRightsRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode setDefaultGroupAdministratorRights#65577768 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("setDefaultGroupAdministratorRights"); err != nil { + return fmt.Errorf("unable to decode setDefaultGroupAdministratorRights#65577768: %w", err) + } + case "default_group_administrator_rights": + if err := s.DefaultGroupAdministratorRights.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode setDefaultGroupAdministratorRights#65577768: field default_group_administrator_rights: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetDefaultGroupAdministratorRights returns value of DefaultGroupAdministratorRights field. +func (s *SetDefaultGroupAdministratorRightsRequest) GetDefaultGroupAdministratorRights() (value ChatAdministratorRights) { + if s == nil { + return + } + return s.DefaultGroupAdministratorRights +} + +// SetDefaultGroupAdministratorRights invokes method setDefaultGroupAdministratorRights#65577768 returning error if any. +func (c *Client) SetDefaultGroupAdministratorRights(ctx context.Context, defaultgroupadministratorrights ChatAdministratorRights) error { + var ok Ok + + request := &SetDefaultGroupAdministratorRightsRequest{ + DefaultGroupAdministratorRights: defaultgroupadministratorrights, + } + if err := c.rpc.Invoke(ctx, request, &ok); err != nil { + return err + } + return nil +} diff --git a/tdapi/tl_set_menu_button_gen.go b/tdapi/tl_set_menu_button_gen.go new file mode 100644 index 0000000000..5ac5a46296 --- /dev/null +++ b/tdapi/tl_set_menu_button_gen.go @@ -0,0 +1,237 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// SetMenuButtonRequest represents TL type `setMenuButton#b44fc141`. +type SetMenuButtonRequest struct { + // Identifier of the user or 0 to set menu button for all users + UserID int64 + // New menu button + MenuButton BotMenuButton +} + +// SetMenuButtonRequestTypeID is TL type id of SetMenuButtonRequest. +const SetMenuButtonRequestTypeID = 0xb44fc141 + +// Ensuring interfaces in compile-time for SetMenuButtonRequest. +var ( + _ bin.Encoder = &SetMenuButtonRequest{} + _ bin.Decoder = &SetMenuButtonRequest{} + _ bin.BareEncoder = &SetMenuButtonRequest{} + _ bin.BareDecoder = &SetMenuButtonRequest{} +) + +func (s *SetMenuButtonRequest) Zero() bool { + if s == nil { + return true + } + if !(s.UserID == 0) { + return false + } + if !(s.MenuButton.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *SetMenuButtonRequest) String() string { + if s == nil { + return "SetMenuButtonRequest(nil)" + } + type Alias SetMenuButtonRequest + return fmt.Sprintf("SetMenuButtonRequest%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*SetMenuButtonRequest) TypeID() uint32 { + return SetMenuButtonRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*SetMenuButtonRequest) TypeName() string { + return "setMenuButton" +} + +// TypeInfo returns info about TL type. +func (s *SetMenuButtonRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "setMenuButton", + ID: SetMenuButtonRequestTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "MenuButton", + SchemaName: "menu_button", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *SetMenuButtonRequest) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode setMenuButton#b44fc141 as nil") + } + b.PutID(SetMenuButtonRequestTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *SetMenuButtonRequest) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode setMenuButton#b44fc141 as nil") + } + b.PutInt53(s.UserID) + if err := s.MenuButton.Encode(b); err != nil { + return fmt.Errorf("unable to encode setMenuButton#b44fc141: field menu_button: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *SetMenuButtonRequest) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode setMenuButton#b44fc141 to nil") + } + if err := b.ConsumeID(SetMenuButtonRequestTypeID); err != nil { + return fmt.Errorf("unable to decode setMenuButton#b44fc141: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *SetMenuButtonRequest) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode setMenuButton#b44fc141 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode setMenuButton#b44fc141: field user_id: %w", err) + } + s.UserID = value + } + { + if err := s.MenuButton.Decode(b); err != nil { + return fmt.Errorf("unable to decode setMenuButton#b44fc141: field menu_button: %w", err) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *SetMenuButtonRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode setMenuButton#b44fc141 as nil") + } + b.ObjStart() + b.PutID("setMenuButton") + b.Comma() + b.FieldStart("user_id") + b.PutInt53(s.UserID) + b.Comma() + b.FieldStart("menu_button") + if err := s.MenuButton.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode setMenuButton#b44fc141: field menu_button: %w", err) + } + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *SetMenuButtonRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode setMenuButton#b44fc141 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("setMenuButton"); err != nil { + return fmt.Errorf("unable to decode setMenuButton#b44fc141: %w", err) + } + case "user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode setMenuButton#b44fc141: field user_id: %w", err) + } + s.UserID = value + case "menu_button": + if err := s.MenuButton.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode setMenuButton#b44fc141: field menu_button: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetUserID returns value of UserID field. +func (s *SetMenuButtonRequest) GetUserID() (value int64) { + if s == nil { + return + } + return s.UserID +} + +// GetMenuButton returns value of MenuButton field. +func (s *SetMenuButtonRequest) GetMenuButton() (value BotMenuButton) { + if s == nil { + return + } + return s.MenuButton +} + +// SetMenuButton invokes method setMenuButton#b44fc141 returning error if any. +func (c *Client) SetMenuButton(ctx context.Context, request *SetMenuButtonRequest) error { + var ok Ok + + if err := c.rpc.Invoke(ctx, request, &ok); err != nil { + return err + } + return nil +} diff --git a/tdapi/tl_sponsored_message_gen.go b/tdapi/tl_sponsored_message_gen.go index 45fe260f92..4e065cbd39 100644 --- a/tdapi/tl_sponsored_message_gen.go +++ b/tdapi/tl_sponsored_message_gen.go @@ -40,8 +40,8 @@ type SponsoredMessage struct { SponsorChatID int64 // Information about the sponsor chat; may be null unless sponsor_chat_id == 0 SponsorChatInfo ChatInviteLinkInfo - // An internal link to be opened when the sponsored message is clicked; may be null. If - // null, the sponsor chat needs to be opened instead + // An internal link to be opened when the sponsored message is clicked; may be null if + // the sponsor chat needs to be opened instead Link InternalLinkTypeClass // Content of the message. Currently, can be only of the type messageText Content MessageContentClass diff --git a/tdapi/tl_test_proxy_gen.go b/tdapi/tl_test_proxy_gen.go index a1db79102f..fcdbe1321b 100644 --- a/tdapi/tl_test_proxy_gen.go +++ b/tdapi/tl_test_proxy_gen.go @@ -39,7 +39,7 @@ type TestProxyRequest struct { Port int32 // Proxy type Type ProxyTypeClass - // Identifier of a datacenter, with which to test connection + // Identifier of a datacenter with which to test connection DCID int32 // The maximum overall timeout for the request Timeout float64 diff --git a/tdapi/tl_theme_parameters_gen.go b/tdapi/tl_theme_parameters_gen.go new file mode 100644 index 0000000000..ad014c7474 --- /dev/null +++ b/tdapi/tl_theme_parameters_gen.go @@ -0,0 +1,363 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// ThemeParameters represents TL type `themeParameters#8d6f03d4`. +type ThemeParameters struct { + // A color of the background in the RGB24 format + BackgroundColor int32 + // A color of text in the RGB24 format + TextColor int32 + // A color of hints in the RGB24 format + HintColor int32 + // A color of links in the RGB24 format + LinkColor int32 + // A color of the buttons in the RGB24 format + ButtonColor int32 + // A color of text on the buttons in the RGB24 format + ButtonTextColor int32 +} + +// ThemeParametersTypeID is TL type id of ThemeParameters. +const ThemeParametersTypeID = 0x8d6f03d4 + +// Ensuring interfaces in compile-time for ThemeParameters. +var ( + _ bin.Encoder = &ThemeParameters{} + _ bin.Decoder = &ThemeParameters{} + _ bin.BareEncoder = &ThemeParameters{} + _ bin.BareDecoder = &ThemeParameters{} +) + +func (t *ThemeParameters) Zero() bool { + if t == nil { + return true + } + if !(t.BackgroundColor == 0) { + return false + } + if !(t.TextColor == 0) { + return false + } + if !(t.HintColor == 0) { + return false + } + if !(t.LinkColor == 0) { + return false + } + if !(t.ButtonColor == 0) { + return false + } + if !(t.ButtonTextColor == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (t *ThemeParameters) String() string { + if t == nil { + return "ThemeParameters(nil)" + } + type Alias ThemeParameters + return fmt.Sprintf("ThemeParameters%+v", Alias(*t)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ThemeParameters) TypeID() uint32 { + return ThemeParametersTypeID +} + +// TypeName returns name of type in TL schema. +func (*ThemeParameters) TypeName() string { + return "themeParameters" +} + +// TypeInfo returns info about TL type. +func (t *ThemeParameters) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "themeParameters", + ID: ThemeParametersTypeID, + } + if t == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "BackgroundColor", + SchemaName: "background_color", + }, + { + Name: "TextColor", + SchemaName: "text_color", + }, + { + Name: "HintColor", + SchemaName: "hint_color", + }, + { + Name: "LinkColor", + SchemaName: "link_color", + }, + { + Name: "ButtonColor", + SchemaName: "button_color", + }, + { + Name: "ButtonTextColor", + SchemaName: "button_text_color", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (t *ThemeParameters) Encode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode themeParameters#8d6f03d4 as nil") + } + b.PutID(ThemeParametersTypeID) + return t.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (t *ThemeParameters) EncodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode themeParameters#8d6f03d4 as nil") + } + b.PutInt32(t.BackgroundColor) + b.PutInt32(t.TextColor) + b.PutInt32(t.HintColor) + b.PutInt32(t.LinkColor) + b.PutInt32(t.ButtonColor) + b.PutInt32(t.ButtonTextColor) + return nil +} + +// Decode implements bin.Decoder. +func (t *ThemeParameters) Decode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode themeParameters#8d6f03d4 to nil") + } + if err := b.ConsumeID(ThemeParametersTypeID); err != nil { + return fmt.Errorf("unable to decode themeParameters#8d6f03d4: %w", err) + } + return t.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (t *ThemeParameters) DecodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode themeParameters#8d6f03d4 to nil") + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode themeParameters#8d6f03d4: field background_color: %w", err) + } + t.BackgroundColor = value + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode themeParameters#8d6f03d4: field text_color: %w", err) + } + t.TextColor = value + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode themeParameters#8d6f03d4: field hint_color: %w", err) + } + t.HintColor = value + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode themeParameters#8d6f03d4: field link_color: %w", err) + } + t.LinkColor = value + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode themeParameters#8d6f03d4: field button_color: %w", err) + } + t.ButtonColor = value + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode themeParameters#8d6f03d4: field button_text_color: %w", err) + } + t.ButtonTextColor = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (t *ThemeParameters) EncodeTDLibJSON(b tdjson.Encoder) error { + if t == nil { + return fmt.Errorf("can't encode themeParameters#8d6f03d4 as nil") + } + b.ObjStart() + b.PutID("themeParameters") + b.Comma() + b.FieldStart("background_color") + b.PutInt32(t.BackgroundColor) + b.Comma() + b.FieldStart("text_color") + b.PutInt32(t.TextColor) + b.Comma() + b.FieldStart("hint_color") + b.PutInt32(t.HintColor) + b.Comma() + b.FieldStart("link_color") + b.PutInt32(t.LinkColor) + b.Comma() + b.FieldStart("button_color") + b.PutInt32(t.ButtonColor) + b.Comma() + b.FieldStart("button_text_color") + b.PutInt32(t.ButtonTextColor) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (t *ThemeParameters) DecodeTDLibJSON(b tdjson.Decoder) error { + if t == nil { + return fmt.Errorf("can't decode themeParameters#8d6f03d4 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("themeParameters"); err != nil { + return fmt.Errorf("unable to decode themeParameters#8d6f03d4: %w", err) + } + case "background_color": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode themeParameters#8d6f03d4: field background_color: %w", err) + } + t.BackgroundColor = value + case "text_color": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode themeParameters#8d6f03d4: field text_color: %w", err) + } + t.TextColor = value + case "hint_color": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode themeParameters#8d6f03d4: field hint_color: %w", err) + } + t.HintColor = value + case "link_color": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode themeParameters#8d6f03d4: field link_color: %w", err) + } + t.LinkColor = value + case "button_color": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode themeParameters#8d6f03d4: field button_color: %w", err) + } + t.ButtonColor = value + case "button_text_color": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode themeParameters#8d6f03d4: field button_text_color: %w", err) + } + t.ButtonTextColor = value + default: + return b.Skip() + } + return nil + }) +} + +// GetBackgroundColor returns value of BackgroundColor field. +func (t *ThemeParameters) GetBackgroundColor() (value int32) { + if t == nil { + return + } + return t.BackgroundColor +} + +// GetTextColor returns value of TextColor field. +func (t *ThemeParameters) GetTextColor() (value int32) { + if t == nil { + return + } + return t.TextColor +} + +// GetHintColor returns value of HintColor field. +func (t *ThemeParameters) GetHintColor() (value int32) { + if t == nil { + return + } + return t.HintColor +} + +// GetLinkColor returns value of LinkColor field. +func (t *ThemeParameters) GetLinkColor() (value int32) { + if t == nil { + return + } + return t.LinkColor +} + +// GetButtonColor returns value of ButtonColor field. +func (t *ThemeParameters) GetButtonColor() (value int32) { + if t == nil { + return + } + return t.ButtonColor +} + +// GetButtonTextColor returns value of ButtonTextColor field. +func (t *ThemeParameters) GetButtonTextColor() (value int32) { + if t == nil { + return + } + return t.ButtonTextColor +} diff --git a/tdapi/tl_toggle_bot_is_added_to_attachment_menu_gen.go b/tdapi/tl_toggle_bot_is_added_to_attachment_menu_gen.go new file mode 100644 index 0000000000..d79bcb88df --- /dev/null +++ b/tdapi/tl_toggle_bot_is_added_to_attachment_menu_gen.go @@ -0,0 +1,238 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// ToggleBotIsAddedToAttachmentMenuRequest represents TL type `toggleBotIsAddedToAttachmentMenu#b56763e2`. +type ToggleBotIsAddedToAttachmentMenuRequest struct { + // Bot's user identifier + BotUserID int64 + // Pass true to add the bot to attachment menu; pass false to remove the bot from + // attachment menu + IsAdded bool +} + +// ToggleBotIsAddedToAttachmentMenuRequestTypeID is TL type id of ToggleBotIsAddedToAttachmentMenuRequest. +const ToggleBotIsAddedToAttachmentMenuRequestTypeID = 0xb56763e2 + +// Ensuring interfaces in compile-time for ToggleBotIsAddedToAttachmentMenuRequest. +var ( + _ bin.Encoder = &ToggleBotIsAddedToAttachmentMenuRequest{} + _ bin.Decoder = &ToggleBotIsAddedToAttachmentMenuRequest{} + _ bin.BareEncoder = &ToggleBotIsAddedToAttachmentMenuRequest{} + _ bin.BareDecoder = &ToggleBotIsAddedToAttachmentMenuRequest{} +) + +func (t *ToggleBotIsAddedToAttachmentMenuRequest) Zero() bool { + if t == nil { + return true + } + if !(t.BotUserID == 0) { + return false + } + if !(t.IsAdded == false) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (t *ToggleBotIsAddedToAttachmentMenuRequest) String() string { + if t == nil { + return "ToggleBotIsAddedToAttachmentMenuRequest(nil)" + } + type Alias ToggleBotIsAddedToAttachmentMenuRequest + return fmt.Sprintf("ToggleBotIsAddedToAttachmentMenuRequest%+v", Alias(*t)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ToggleBotIsAddedToAttachmentMenuRequest) TypeID() uint32 { + return ToggleBotIsAddedToAttachmentMenuRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*ToggleBotIsAddedToAttachmentMenuRequest) TypeName() string { + return "toggleBotIsAddedToAttachmentMenu" +} + +// TypeInfo returns info about TL type. +func (t *ToggleBotIsAddedToAttachmentMenuRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "toggleBotIsAddedToAttachmentMenu", + ID: ToggleBotIsAddedToAttachmentMenuRequestTypeID, + } + if t == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "BotUserID", + SchemaName: "bot_user_id", + }, + { + Name: "IsAdded", + SchemaName: "is_added", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (t *ToggleBotIsAddedToAttachmentMenuRequest) Encode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode toggleBotIsAddedToAttachmentMenu#b56763e2 as nil") + } + b.PutID(ToggleBotIsAddedToAttachmentMenuRequestTypeID) + return t.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (t *ToggleBotIsAddedToAttachmentMenuRequest) EncodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't encode toggleBotIsAddedToAttachmentMenu#b56763e2 as nil") + } + b.PutInt53(t.BotUserID) + b.PutBool(t.IsAdded) + return nil +} + +// Decode implements bin.Decoder. +func (t *ToggleBotIsAddedToAttachmentMenuRequest) Decode(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode toggleBotIsAddedToAttachmentMenu#b56763e2 to nil") + } + if err := b.ConsumeID(ToggleBotIsAddedToAttachmentMenuRequestTypeID); err != nil { + return fmt.Errorf("unable to decode toggleBotIsAddedToAttachmentMenu#b56763e2: %w", err) + } + return t.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (t *ToggleBotIsAddedToAttachmentMenuRequest) DecodeBare(b *bin.Buffer) error { + if t == nil { + return fmt.Errorf("can't decode toggleBotIsAddedToAttachmentMenu#b56763e2 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode toggleBotIsAddedToAttachmentMenu#b56763e2: field bot_user_id: %w", err) + } + t.BotUserID = value + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode toggleBotIsAddedToAttachmentMenu#b56763e2: field is_added: %w", err) + } + t.IsAdded = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (t *ToggleBotIsAddedToAttachmentMenuRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if t == nil { + return fmt.Errorf("can't encode toggleBotIsAddedToAttachmentMenu#b56763e2 as nil") + } + b.ObjStart() + b.PutID("toggleBotIsAddedToAttachmentMenu") + b.Comma() + b.FieldStart("bot_user_id") + b.PutInt53(t.BotUserID) + b.Comma() + b.FieldStart("is_added") + b.PutBool(t.IsAdded) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (t *ToggleBotIsAddedToAttachmentMenuRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if t == nil { + return fmt.Errorf("can't decode toggleBotIsAddedToAttachmentMenu#b56763e2 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("toggleBotIsAddedToAttachmentMenu"); err != nil { + return fmt.Errorf("unable to decode toggleBotIsAddedToAttachmentMenu#b56763e2: %w", err) + } + case "bot_user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode toggleBotIsAddedToAttachmentMenu#b56763e2: field bot_user_id: %w", err) + } + t.BotUserID = value + case "is_added": + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode toggleBotIsAddedToAttachmentMenu#b56763e2: field is_added: %w", err) + } + t.IsAdded = value + default: + return b.Skip() + } + return nil + }) +} + +// GetBotUserID returns value of BotUserID field. +func (t *ToggleBotIsAddedToAttachmentMenuRequest) GetBotUserID() (value int64) { + if t == nil { + return + } + return t.BotUserID +} + +// GetIsAdded returns value of IsAdded field. +func (t *ToggleBotIsAddedToAttachmentMenuRequest) GetIsAdded() (value bool) { + if t == nil { + return + } + return t.IsAdded +} + +// ToggleBotIsAddedToAttachmentMenu invokes method toggleBotIsAddedToAttachmentMenu#b56763e2 returning error if any. +func (c *Client) ToggleBotIsAddedToAttachmentMenu(ctx context.Context, request *ToggleBotIsAddedToAttachmentMenuRequest) error { + var ok Ok + + if err := c.rpc.Invoke(ctx, request, &ok); err != nil { + return err + } + return nil +} diff --git a/tdapi/tl_update_gen.go b/tdapi/tl_update_gen.go index 280de5d48e..084d431a17 100644 --- a/tdapi/tl_update_gen.go +++ b/tdapi/tl_update_gen.go @@ -8935,7 +8935,7 @@ func (u *UpdateNotification) GetNotification() (value Notification) { return u.Notification } -// UpdateNotificationGroup represents TL type `updateNotificationGroup#2ec53c49`. +// UpdateNotificationGroup represents TL type `updateNotificationGroup#96cd9e06`. type UpdateNotificationGroup struct { // Unique notification group identifier NotificationGroupID int32 @@ -8946,8 +8946,8 @@ type UpdateNotificationGroup struct { // Chat identifier, which notification settings must be applied to the added // notifications NotificationSettingsChatID int64 - // True, if the notifications must be shown without sound - IsSilent bool + // Identifier of the notification sound to be played; 0 if sound is disabled + NotificationSoundID int64 // Total number of unread notifications in the group, can be bigger than number of active // notifications TotalCount int32 @@ -8958,7 +8958,7 @@ type UpdateNotificationGroup struct { } // UpdateNotificationGroupTypeID is TL type id of UpdateNotificationGroup. -const UpdateNotificationGroupTypeID = 0x2ec53c49 +const UpdateNotificationGroupTypeID = 0x96cd9e06 // construct implements constructor of UpdateClass. func (u UpdateNotificationGroup) construct() UpdateClass { return &u } @@ -8989,7 +8989,7 @@ func (u *UpdateNotificationGroup) Zero() bool { if !(u.NotificationSettingsChatID == 0) { return false } - if !(u.IsSilent == false) { + if !(u.NotificationSoundID == 0) { return false } if !(u.TotalCount == 0) { @@ -9054,8 +9054,8 @@ func (u *UpdateNotificationGroup) TypeInfo() tdp.Type { SchemaName: "notification_settings_chat_id", }, { - Name: "IsSilent", - SchemaName: "is_silent", + Name: "NotificationSoundID", + SchemaName: "notification_sound_id", }, { Name: "TotalCount", @@ -9076,7 +9076,7 @@ func (u *UpdateNotificationGroup) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (u *UpdateNotificationGroup) Encode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode updateNotificationGroup#2ec53c49 as nil") + return fmt.Errorf("can't encode updateNotificationGroup#96cd9e06 as nil") } b.PutID(UpdateNotificationGroupTypeID) return u.EncodeBare(b) @@ -9085,23 +9085,23 @@ func (u *UpdateNotificationGroup) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (u *UpdateNotificationGroup) EncodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode updateNotificationGroup#2ec53c49 as nil") + return fmt.Errorf("can't encode updateNotificationGroup#96cd9e06 as nil") } b.PutInt32(u.NotificationGroupID) if u.Type == nil { - return fmt.Errorf("unable to encode updateNotificationGroup#2ec53c49: field type is nil") + return fmt.Errorf("unable to encode updateNotificationGroup#96cd9e06: field type is nil") } if err := u.Type.Encode(b); err != nil { - return fmt.Errorf("unable to encode updateNotificationGroup#2ec53c49: field type: %w", err) + return fmt.Errorf("unable to encode updateNotificationGroup#96cd9e06: field type: %w", err) } b.PutInt53(u.ChatID) b.PutInt53(u.NotificationSettingsChatID) - b.PutBool(u.IsSilent) + b.PutLong(u.NotificationSoundID) b.PutInt32(u.TotalCount) b.PutInt(len(u.AddedNotifications)) for idx, v := range u.AddedNotifications { if err := v.EncodeBare(b); err != nil { - return fmt.Errorf("unable to encode bare updateNotificationGroup#2ec53c49: field added_notifications element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode bare updateNotificationGroup#96cd9e06: field added_notifications element with index %d: %w", idx, err) } } b.PutInt(len(u.RemovedNotificationIDs)) @@ -9114,10 +9114,10 @@ func (u *UpdateNotificationGroup) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (u *UpdateNotificationGroup) Decode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode updateNotificationGroup#2ec53c49 to nil") + return fmt.Errorf("can't decode updateNotificationGroup#96cd9e06 to nil") } if err := b.ConsumeID(UpdateNotificationGroupTypeID); err != nil { - return fmt.Errorf("unable to decode updateNotificationGroup#2ec53c49: %w", err) + return fmt.Errorf("unable to decode updateNotificationGroup#96cd9e06: %w", err) } return u.DecodeBare(b) } @@ -9125,54 +9125,54 @@ func (u *UpdateNotificationGroup) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (u *UpdateNotificationGroup) DecodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode updateNotificationGroup#2ec53c49 to nil") + return fmt.Errorf("can't decode updateNotificationGroup#96cd9e06 to nil") } { value, err := b.Int32() if err != nil { - return fmt.Errorf("unable to decode updateNotificationGroup#2ec53c49: field notification_group_id: %w", err) + return fmt.Errorf("unable to decode updateNotificationGroup#96cd9e06: field notification_group_id: %w", err) } u.NotificationGroupID = value } { value, err := DecodeNotificationGroupType(b) if err != nil { - return fmt.Errorf("unable to decode updateNotificationGroup#2ec53c49: field type: %w", err) + return fmt.Errorf("unable to decode updateNotificationGroup#96cd9e06: field type: %w", err) } u.Type = value } { value, err := b.Int53() if err != nil { - return fmt.Errorf("unable to decode updateNotificationGroup#2ec53c49: field chat_id: %w", err) + return fmt.Errorf("unable to decode updateNotificationGroup#96cd9e06: field chat_id: %w", err) } u.ChatID = value } { value, err := b.Int53() if err != nil { - return fmt.Errorf("unable to decode updateNotificationGroup#2ec53c49: field notification_settings_chat_id: %w", err) + return fmt.Errorf("unable to decode updateNotificationGroup#96cd9e06: field notification_settings_chat_id: %w", err) } u.NotificationSettingsChatID = value } { - value, err := b.Bool() + value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode updateNotificationGroup#2ec53c49: field is_silent: %w", err) + return fmt.Errorf("unable to decode updateNotificationGroup#96cd9e06: field notification_sound_id: %w", err) } - u.IsSilent = value + u.NotificationSoundID = value } { value, err := b.Int32() if err != nil { - return fmt.Errorf("unable to decode updateNotificationGroup#2ec53c49: field total_count: %w", err) + return fmt.Errorf("unable to decode updateNotificationGroup#96cd9e06: field total_count: %w", err) } u.TotalCount = value } { headerLen, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode updateNotificationGroup#2ec53c49: field added_notifications: %w", err) + return fmt.Errorf("unable to decode updateNotificationGroup#96cd9e06: field added_notifications: %w", err) } if headerLen > 0 { @@ -9181,7 +9181,7 @@ func (u *UpdateNotificationGroup) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value Notification if err := value.DecodeBare(b); err != nil { - return fmt.Errorf("unable to decode bare updateNotificationGroup#2ec53c49: field added_notifications: %w", err) + return fmt.Errorf("unable to decode bare updateNotificationGroup#96cd9e06: field added_notifications: %w", err) } u.AddedNotifications = append(u.AddedNotifications, value) } @@ -9189,7 +9189,7 @@ func (u *UpdateNotificationGroup) DecodeBare(b *bin.Buffer) error { { headerLen, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode updateNotificationGroup#2ec53c49: field removed_notification_ids: %w", err) + return fmt.Errorf("unable to decode updateNotificationGroup#96cd9e06: field removed_notification_ids: %w", err) } if headerLen > 0 { @@ -9198,7 +9198,7 @@ func (u *UpdateNotificationGroup) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { value, err := b.Int32() if err != nil { - return fmt.Errorf("unable to decode updateNotificationGroup#2ec53c49: field removed_notification_ids: %w", err) + return fmt.Errorf("unable to decode updateNotificationGroup#96cd9e06: field removed_notification_ids: %w", err) } u.RemovedNotificationIDs = append(u.RemovedNotificationIDs, value) } @@ -9209,7 +9209,7 @@ func (u *UpdateNotificationGroup) DecodeBare(b *bin.Buffer) error { // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (u *UpdateNotificationGroup) EncodeTDLibJSON(b tdjson.Encoder) error { if u == nil { - return fmt.Errorf("can't encode updateNotificationGroup#2ec53c49 as nil") + return fmt.Errorf("can't encode updateNotificationGroup#96cd9e06 as nil") } b.ObjStart() b.PutID("updateNotificationGroup") @@ -9219,10 +9219,10 @@ func (u *UpdateNotificationGroup) EncodeTDLibJSON(b tdjson.Encoder) error { b.Comma() b.FieldStart("type") if u.Type == nil { - return fmt.Errorf("unable to encode updateNotificationGroup#2ec53c49: field type is nil") + return fmt.Errorf("unable to encode updateNotificationGroup#96cd9e06: field type is nil") } if err := u.Type.EncodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to encode updateNotificationGroup#2ec53c49: field type: %w", err) + return fmt.Errorf("unable to encode updateNotificationGroup#96cd9e06: field type: %w", err) } b.Comma() b.FieldStart("chat_id") @@ -9231,8 +9231,8 @@ func (u *UpdateNotificationGroup) EncodeTDLibJSON(b tdjson.Encoder) error { b.FieldStart("notification_settings_chat_id") b.PutInt53(u.NotificationSettingsChatID) b.Comma() - b.FieldStart("is_silent") - b.PutBool(u.IsSilent) + b.FieldStart("notification_sound_id") + b.PutLong(u.NotificationSoundID) b.Comma() b.FieldStart("total_count") b.PutInt32(u.TotalCount) @@ -9241,7 +9241,7 @@ func (u *UpdateNotificationGroup) EncodeTDLibJSON(b tdjson.Encoder) error { b.ArrStart() for idx, v := range u.AddedNotifications { if err := v.EncodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to encode updateNotificationGroup#2ec53c49: field added_notifications element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode updateNotificationGroup#96cd9e06: field added_notifications element with index %d: %w", idx, err) } b.Comma() } @@ -9265,72 +9265,72 @@ func (u *UpdateNotificationGroup) EncodeTDLibJSON(b tdjson.Encoder) error { // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (u *UpdateNotificationGroup) DecodeTDLibJSON(b tdjson.Decoder) error { if u == nil { - return fmt.Errorf("can't decode updateNotificationGroup#2ec53c49 to nil") + return fmt.Errorf("can't decode updateNotificationGroup#96cd9e06 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("updateNotificationGroup"); err != nil { - return fmt.Errorf("unable to decode updateNotificationGroup#2ec53c49: %w", err) + return fmt.Errorf("unable to decode updateNotificationGroup#96cd9e06: %w", err) } case "notification_group_id": value, err := b.Int32() if err != nil { - return fmt.Errorf("unable to decode updateNotificationGroup#2ec53c49: field notification_group_id: %w", err) + return fmt.Errorf("unable to decode updateNotificationGroup#96cd9e06: field notification_group_id: %w", err) } u.NotificationGroupID = value case "type": value, err := DecodeTDLibJSONNotificationGroupType(b) if err != nil { - return fmt.Errorf("unable to decode updateNotificationGroup#2ec53c49: field type: %w", err) + return fmt.Errorf("unable to decode updateNotificationGroup#96cd9e06: field type: %w", err) } u.Type = value case "chat_id": value, err := b.Int53() if err != nil { - return fmt.Errorf("unable to decode updateNotificationGroup#2ec53c49: field chat_id: %w", err) + return fmt.Errorf("unable to decode updateNotificationGroup#96cd9e06: field chat_id: %w", err) } u.ChatID = value case "notification_settings_chat_id": value, err := b.Int53() if err != nil { - return fmt.Errorf("unable to decode updateNotificationGroup#2ec53c49: field notification_settings_chat_id: %w", err) + return fmt.Errorf("unable to decode updateNotificationGroup#96cd9e06: field notification_settings_chat_id: %w", err) } u.NotificationSettingsChatID = value - case "is_silent": - value, err := b.Bool() + case "notification_sound_id": + value, err := b.Long() if err != nil { - return fmt.Errorf("unable to decode updateNotificationGroup#2ec53c49: field is_silent: %w", err) + return fmt.Errorf("unable to decode updateNotificationGroup#96cd9e06: field notification_sound_id: %w", err) } - u.IsSilent = value + u.NotificationSoundID = value case "total_count": value, err := b.Int32() if err != nil { - return fmt.Errorf("unable to decode updateNotificationGroup#2ec53c49: field total_count: %w", err) + return fmt.Errorf("unable to decode updateNotificationGroup#96cd9e06: field total_count: %w", err) } u.TotalCount = value case "added_notifications": if err := b.Arr(func(b tdjson.Decoder) error { var value Notification if err := value.DecodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to decode updateNotificationGroup#2ec53c49: field added_notifications: %w", err) + return fmt.Errorf("unable to decode updateNotificationGroup#96cd9e06: field added_notifications: %w", err) } u.AddedNotifications = append(u.AddedNotifications, value) return nil }); err != nil { - return fmt.Errorf("unable to decode updateNotificationGroup#2ec53c49: field added_notifications: %w", err) + return fmt.Errorf("unable to decode updateNotificationGroup#96cd9e06: field added_notifications: %w", err) } case "removed_notification_ids": if err := b.Arr(func(b tdjson.Decoder) error { value, err := b.Int32() if err != nil { - return fmt.Errorf("unable to decode updateNotificationGroup#2ec53c49: field removed_notification_ids: %w", err) + return fmt.Errorf("unable to decode updateNotificationGroup#96cd9e06: field removed_notification_ids: %w", err) } u.RemovedNotificationIDs = append(u.RemovedNotificationIDs, value) return nil }); err != nil { - return fmt.Errorf("unable to decode updateNotificationGroup#2ec53c49: field removed_notification_ids: %w", err) + return fmt.Errorf("unable to decode updateNotificationGroup#96cd9e06: field removed_notification_ids: %w", err) } default: return b.Skip() @@ -9371,12 +9371,12 @@ func (u *UpdateNotificationGroup) GetNotificationSettingsChatID() (value int64) return u.NotificationSettingsChatID } -// GetIsSilent returns value of IsSilent field. -func (u *UpdateNotificationGroup) GetIsSilent() (value bool) { +// GetNotificationSoundID returns value of NotificationSoundID field. +func (u *UpdateNotificationGroup) GetNotificationSoundID() (value int64) { if u == nil { return } - return u.IsSilent + return u.NotificationSoundID } // GetTotalCount returns value of TotalCount field. @@ -16474,6 +16474,196 @@ func (u *UpdateSavedAnimations) GetAnimationIDs() (value []int32) { return u.AnimationIDs } +// UpdateSavedNotificationSounds represents TL type `updateSavedNotificationSounds#5a6653b4`. +type UpdateSavedNotificationSounds struct { + // The new list of identifiers of saved notification sounds + NotificationSoundIDs []int64 +} + +// UpdateSavedNotificationSoundsTypeID is TL type id of UpdateSavedNotificationSounds. +const UpdateSavedNotificationSoundsTypeID = 0x5a6653b4 + +// construct implements constructor of UpdateClass. +func (u UpdateSavedNotificationSounds) construct() UpdateClass { return &u } + +// Ensuring interfaces in compile-time for UpdateSavedNotificationSounds. +var ( + _ bin.Encoder = &UpdateSavedNotificationSounds{} + _ bin.Decoder = &UpdateSavedNotificationSounds{} + _ bin.BareEncoder = &UpdateSavedNotificationSounds{} + _ bin.BareDecoder = &UpdateSavedNotificationSounds{} + + _ UpdateClass = &UpdateSavedNotificationSounds{} +) + +func (u *UpdateSavedNotificationSounds) Zero() bool { + if u == nil { + return true + } + if !(u.NotificationSoundIDs == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *UpdateSavedNotificationSounds) String() string { + if u == nil { + return "UpdateSavedNotificationSounds(nil)" + } + type Alias UpdateSavedNotificationSounds + return fmt.Sprintf("UpdateSavedNotificationSounds%+v", Alias(*u)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*UpdateSavedNotificationSounds) TypeID() uint32 { + return UpdateSavedNotificationSoundsTypeID +} + +// TypeName returns name of type in TL schema. +func (*UpdateSavedNotificationSounds) TypeName() string { + return "updateSavedNotificationSounds" +} + +// TypeInfo returns info about TL type. +func (u *UpdateSavedNotificationSounds) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "updateSavedNotificationSounds", + ID: UpdateSavedNotificationSoundsTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "NotificationSoundIDs", + SchemaName: "notification_sound_ids", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (u *UpdateSavedNotificationSounds) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateSavedNotificationSounds#5a6653b4 as nil") + } + b.PutID(UpdateSavedNotificationSoundsTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *UpdateSavedNotificationSounds) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateSavedNotificationSounds#5a6653b4 as nil") + } + b.PutInt(len(u.NotificationSoundIDs)) + for _, v := range u.NotificationSoundIDs { + b.PutLong(v) + } + return nil +} + +// Decode implements bin.Decoder. +func (u *UpdateSavedNotificationSounds) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateSavedNotificationSounds#5a6653b4 to nil") + } + if err := b.ConsumeID(UpdateSavedNotificationSoundsTypeID); err != nil { + return fmt.Errorf("unable to decode updateSavedNotificationSounds#5a6653b4: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *UpdateSavedNotificationSounds) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateSavedNotificationSounds#5a6653b4 to nil") + } + { + headerLen, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode updateSavedNotificationSounds#5a6653b4: field notification_sound_ids: %w", err) + } + + if headerLen > 0 { + u.NotificationSoundIDs = make([]int64, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode updateSavedNotificationSounds#5a6653b4: field notification_sound_ids: %w", err) + } + u.NotificationSoundIDs = append(u.NotificationSoundIDs, value) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (u *UpdateSavedNotificationSounds) EncodeTDLibJSON(b tdjson.Encoder) error { + if u == nil { + return fmt.Errorf("can't encode updateSavedNotificationSounds#5a6653b4 as nil") + } + b.ObjStart() + b.PutID("updateSavedNotificationSounds") + b.Comma() + b.FieldStart("notification_sound_ids") + b.ArrStart() + for _, v := range u.NotificationSoundIDs { + b.PutLong(v) + b.Comma() + } + b.StripComma() + b.ArrEnd() + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (u *UpdateSavedNotificationSounds) DecodeTDLibJSON(b tdjson.Decoder) error { + if u == nil { + return fmt.Errorf("can't decode updateSavedNotificationSounds#5a6653b4 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("updateSavedNotificationSounds"); err != nil { + return fmt.Errorf("unable to decode updateSavedNotificationSounds#5a6653b4: %w", err) + } + case "notification_sound_ids": + if err := b.Arr(func(b tdjson.Decoder) error { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode updateSavedNotificationSounds#5a6653b4: field notification_sound_ids: %w", err) + } + u.NotificationSoundIDs = append(u.NotificationSoundIDs, value) + return nil + }); err != nil { + return fmt.Errorf("unable to decode updateSavedNotificationSounds#5a6653b4: field notification_sound_ids: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetNotificationSoundIDs returns value of NotificationSoundIDs field. +func (u *UpdateSavedNotificationSounds) GetNotificationSoundIDs() (value []int64) { + if u == nil { + return + } + return u.NotificationSoundIDs +} + // UpdateSelectedBackground represents TL type `updateSelectedBackground#99bd205d`. type UpdateSelectedBackground struct { // True, if background for dark theme has changed @@ -17700,6 +17890,367 @@ func (u *UpdateUsersNearby) GetUsersNearby() (value []ChatNearby) { return u.UsersNearby } +// UpdateAttachmentMenuBots represents TL type `updateAttachmentMenuBots#b6b910c`. +type UpdateAttachmentMenuBots struct { + // The new list of bots added to attachment menu. The bots must be shown in attachment + // menu only in private chats. The bots must not be shown on scheduled messages screen + Bots []AttachmentMenuBot +} + +// UpdateAttachmentMenuBotsTypeID is TL type id of UpdateAttachmentMenuBots. +const UpdateAttachmentMenuBotsTypeID = 0xb6b910c + +// construct implements constructor of UpdateClass. +func (u UpdateAttachmentMenuBots) construct() UpdateClass { return &u } + +// Ensuring interfaces in compile-time for UpdateAttachmentMenuBots. +var ( + _ bin.Encoder = &UpdateAttachmentMenuBots{} + _ bin.Decoder = &UpdateAttachmentMenuBots{} + _ bin.BareEncoder = &UpdateAttachmentMenuBots{} + _ bin.BareDecoder = &UpdateAttachmentMenuBots{} + + _ UpdateClass = &UpdateAttachmentMenuBots{} +) + +func (u *UpdateAttachmentMenuBots) Zero() bool { + if u == nil { + return true + } + if !(u.Bots == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *UpdateAttachmentMenuBots) String() string { + if u == nil { + return "UpdateAttachmentMenuBots(nil)" + } + type Alias UpdateAttachmentMenuBots + return fmt.Sprintf("UpdateAttachmentMenuBots%+v", Alias(*u)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*UpdateAttachmentMenuBots) TypeID() uint32 { + return UpdateAttachmentMenuBotsTypeID +} + +// TypeName returns name of type in TL schema. +func (*UpdateAttachmentMenuBots) TypeName() string { + return "updateAttachmentMenuBots" +} + +// TypeInfo returns info about TL type. +func (u *UpdateAttachmentMenuBots) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "updateAttachmentMenuBots", + ID: UpdateAttachmentMenuBotsTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Bots", + SchemaName: "bots", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (u *UpdateAttachmentMenuBots) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateAttachmentMenuBots#b6b910c as nil") + } + b.PutID(UpdateAttachmentMenuBotsTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *UpdateAttachmentMenuBots) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateAttachmentMenuBots#b6b910c as nil") + } + b.PutInt(len(u.Bots)) + for idx, v := range u.Bots { + if err := v.EncodeBare(b); err != nil { + return fmt.Errorf("unable to encode bare updateAttachmentMenuBots#b6b910c: field bots element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (u *UpdateAttachmentMenuBots) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateAttachmentMenuBots#b6b910c to nil") + } + if err := b.ConsumeID(UpdateAttachmentMenuBotsTypeID); err != nil { + return fmt.Errorf("unable to decode updateAttachmentMenuBots#b6b910c: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *UpdateAttachmentMenuBots) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateAttachmentMenuBots#b6b910c to nil") + } + { + headerLen, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode updateAttachmentMenuBots#b6b910c: field bots: %w", err) + } + + if headerLen > 0 { + u.Bots = make([]AttachmentMenuBot, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value AttachmentMenuBot + if err := value.DecodeBare(b); err != nil { + return fmt.Errorf("unable to decode bare updateAttachmentMenuBots#b6b910c: field bots: %w", err) + } + u.Bots = append(u.Bots, value) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (u *UpdateAttachmentMenuBots) EncodeTDLibJSON(b tdjson.Encoder) error { + if u == nil { + return fmt.Errorf("can't encode updateAttachmentMenuBots#b6b910c as nil") + } + b.ObjStart() + b.PutID("updateAttachmentMenuBots") + b.Comma() + b.FieldStart("bots") + b.ArrStart() + for idx, v := range u.Bots { + if err := v.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode updateAttachmentMenuBots#b6b910c: field bots element with index %d: %w", idx, err) + } + b.Comma() + } + b.StripComma() + b.ArrEnd() + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (u *UpdateAttachmentMenuBots) DecodeTDLibJSON(b tdjson.Decoder) error { + if u == nil { + return fmt.Errorf("can't decode updateAttachmentMenuBots#b6b910c to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("updateAttachmentMenuBots"); err != nil { + return fmt.Errorf("unable to decode updateAttachmentMenuBots#b6b910c: %w", err) + } + case "bots": + if err := b.Arr(func(b tdjson.Decoder) error { + var value AttachmentMenuBot + if err := value.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode updateAttachmentMenuBots#b6b910c: field bots: %w", err) + } + u.Bots = append(u.Bots, value) + return nil + }); err != nil { + return fmt.Errorf("unable to decode updateAttachmentMenuBots#b6b910c: field bots: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetBots returns value of Bots field. +func (u *UpdateAttachmentMenuBots) GetBots() (value []AttachmentMenuBot) { + if u == nil { + return + } + return u.Bots +} + +// UpdateWebAppMessageSent represents TL type `updateWebAppMessageSent#58431229`. +type UpdateWebAppMessageSent struct { + // Identifier of web app launch + WebAppLaunchID int64 +} + +// UpdateWebAppMessageSentTypeID is TL type id of UpdateWebAppMessageSent. +const UpdateWebAppMessageSentTypeID = 0x58431229 + +// construct implements constructor of UpdateClass. +func (u UpdateWebAppMessageSent) construct() UpdateClass { return &u } + +// Ensuring interfaces in compile-time for UpdateWebAppMessageSent. +var ( + _ bin.Encoder = &UpdateWebAppMessageSent{} + _ bin.Decoder = &UpdateWebAppMessageSent{} + _ bin.BareEncoder = &UpdateWebAppMessageSent{} + _ bin.BareDecoder = &UpdateWebAppMessageSent{} + + _ UpdateClass = &UpdateWebAppMessageSent{} +) + +func (u *UpdateWebAppMessageSent) Zero() bool { + if u == nil { + return true + } + if !(u.WebAppLaunchID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (u *UpdateWebAppMessageSent) String() string { + if u == nil { + return "UpdateWebAppMessageSent(nil)" + } + type Alias UpdateWebAppMessageSent + return fmt.Sprintf("UpdateWebAppMessageSent%+v", Alias(*u)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*UpdateWebAppMessageSent) TypeID() uint32 { + return UpdateWebAppMessageSentTypeID +} + +// TypeName returns name of type in TL schema. +func (*UpdateWebAppMessageSent) TypeName() string { + return "updateWebAppMessageSent" +} + +// TypeInfo returns info about TL type. +func (u *UpdateWebAppMessageSent) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "updateWebAppMessageSent", + ID: UpdateWebAppMessageSentTypeID, + } + if u == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "WebAppLaunchID", + SchemaName: "web_app_launch_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (u *UpdateWebAppMessageSent) Encode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateWebAppMessageSent#58431229 as nil") + } + b.PutID(UpdateWebAppMessageSentTypeID) + return u.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (u *UpdateWebAppMessageSent) EncodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't encode updateWebAppMessageSent#58431229 as nil") + } + b.PutLong(u.WebAppLaunchID) + return nil +} + +// Decode implements bin.Decoder. +func (u *UpdateWebAppMessageSent) Decode(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateWebAppMessageSent#58431229 to nil") + } + if err := b.ConsumeID(UpdateWebAppMessageSentTypeID); err != nil { + return fmt.Errorf("unable to decode updateWebAppMessageSent#58431229: %w", err) + } + return u.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (u *UpdateWebAppMessageSent) DecodeBare(b *bin.Buffer) error { + if u == nil { + return fmt.Errorf("can't decode updateWebAppMessageSent#58431229 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode updateWebAppMessageSent#58431229: field web_app_launch_id: %w", err) + } + u.WebAppLaunchID = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (u *UpdateWebAppMessageSent) EncodeTDLibJSON(b tdjson.Encoder) error { + if u == nil { + return fmt.Errorf("can't encode updateWebAppMessageSent#58431229 as nil") + } + b.ObjStart() + b.PutID("updateWebAppMessageSent") + b.Comma() + b.FieldStart("web_app_launch_id") + b.PutLong(u.WebAppLaunchID) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (u *UpdateWebAppMessageSent) DecodeTDLibJSON(b tdjson.Decoder) error { + if u == nil { + return fmt.Errorf("can't decode updateWebAppMessageSent#58431229 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("updateWebAppMessageSent"); err != nil { + return fmt.Errorf("unable to decode updateWebAppMessageSent#58431229: %w", err) + } + case "web_app_launch_id": + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode updateWebAppMessageSent#58431229: field web_app_launch_id: %w", err) + } + u.WebAppLaunchID = value + default: + return b.Skip() + } + return nil + }) +} + +// GetWebAppLaunchID returns value of WebAppLaunchID field. +func (u *UpdateWebAppMessageSent) GetWebAppLaunchID() (value int64) { + if u == nil { + return + } + return u.WebAppLaunchID +} + // UpdateReactions represents TL type `updateReactions#e769e4e7`. type UpdateReactions struct { // The new list of supported reactions @@ -18818,7 +19369,7 @@ type UpdateNewInlineQuery struct { SenderUserID int64 // User location; may be null UserLocation Location - // The type of the chat, from which the query originated; may be null if unknown + // The type of the chat from which the query originated; may be null if unknown ChatType ChatTypeClass // Text of the query Query string @@ -19466,7 +20017,7 @@ type UpdateNewCallbackQuery struct { SenderUserID int64 // Identifier of the chat where the query was sent ChatID int64 - // Identifier of the message, from which the query originated + // Identifier of the message from which the query originated MessageID int64 // Identifier that uniquely corresponds to the chat to which the message was sent ChatInstance int64 @@ -19810,7 +20361,7 @@ type UpdateNewInlineCallbackQuery struct { ID int64 // Identifier of the user who sent the query SenderUserID int64 - // Identifier of the inline message, from which the query originated + // Identifier of the inline message from which the query originated InlineMessageID string // An identifier uniquely corresponding to the chat a message was sent to ChatInstance int64 @@ -22201,7 +22752,7 @@ const UpdateClassName = "Update" // case *tdapi.UpdateChatOnlineMemberCount: // updateChatOnlineMemberCount#1d0caa9d // case *tdapi.UpdateScopeNotificationSettings: // updateScopeNotificationSettings#b83ccb73 // case *tdapi.UpdateNotification: // updateNotification#8ee67ed4 -// case *tdapi.UpdateNotificationGroup: // updateNotificationGroup#2ec53c49 +// case *tdapi.UpdateNotificationGroup: // updateNotificationGroup#96cd9e06 // case *tdapi.UpdateActiveNotifications: // updateActiveNotifications#317d80f2 // case *tdapi.UpdateHavePendingNotifications: // updateHavePendingNotifications#aaee1db // case *tdapi.UpdateDeleteMessages: // updateDeleteMessages#6a05bf9 @@ -22236,12 +22787,15 @@ const UpdateClassName = "Update" // case *tdapi.UpdateRecentStickers: // updateRecentStickers#aefdf8dc // case *tdapi.UpdateFavoriteStickers: // updateFavoriteStickers#113f2b6a // case *tdapi.UpdateSavedAnimations: // updateSavedAnimations#1084a1c8 +// case *tdapi.UpdateSavedNotificationSounds: // updateSavedNotificationSounds#5a6653b4 // case *tdapi.UpdateSelectedBackground: // updateSelectedBackground#99bd205d // case *tdapi.UpdateChatThemes: // updateChatThemes#98dc58d5 // case *tdapi.UpdateLanguagePackStrings: // updateLanguagePackStrings#af87919f // case *tdapi.UpdateConnectionState: // updateConnectionState#57939e2e // case *tdapi.UpdateTermsOfService: // updateTermsOfService#b23cc55e // case *tdapi.UpdateUsersNearby: // updateUsersNearby#97c8ab5 +// case *tdapi.UpdateAttachmentMenuBots: // updateAttachmentMenuBots#b6b910c +// case *tdapi.UpdateWebAppMessageSent: // updateWebAppMessageSent#58431229 // case *tdapi.UpdateReactions: // updateReactions#e769e4e7 // case *tdapi.UpdateDiceEmojis: // updateDiceEmojis#9d0f91df // case *tdapi.UpdateAnimatedEmojiMessageClicked: // updateAnimatedEmojiMessageClicked#a3167405 @@ -22585,7 +23139,7 @@ func DecodeUpdate(buf *bin.Buffer) (UpdateClass, error) { } return &v, nil case UpdateNotificationGroupTypeID: - // Decoding updateNotificationGroup#2ec53c49. + // Decoding updateNotificationGroup#96cd9e06. v := UpdateNotificationGroup{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) @@ -22829,6 +23383,13 @@ func DecodeUpdate(buf *bin.Buffer) (UpdateClass, error) { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) } return &v, nil + case UpdateSavedNotificationSoundsTypeID: + // Decoding updateSavedNotificationSounds#5a6653b4. + v := UpdateSavedNotificationSounds{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) + } + return &v, nil case UpdateSelectedBackgroundTypeID: // Decoding updateSelectedBackground#99bd205d. v := UpdateSelectedBackground{} @@ -22871,6 +23432,20 @@ func DecodeUpdate(buf *bin.Buffer) (UpdateClass, error) { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) } return &v, nil + case UpdateAttachmentMenuBotsTypeID: + // Decoding updateAttachmentMenuBots#b6b910c. + v := UpdateAttachmentMenuBots{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) + } + return &v, nil + case UpdateWebAppMessageSentTypeID: + // Decoding updateWebAppMessageSent#58431229. + v := UpdateWebAppMessageSent{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) + } + return &v, nil case UpdateReactionsTypeID: // Decoding updateReactions#e769e4e7. v := UpdateReactions{} @@ -23297,7 +23872,7 @@ func DecodeTDLibJSONUpdate(buf tdjson.Decoder) (UpdateClass, error) { } return &v, nil case "updateNotificationGroup": - // Decoding updateNotificationGroup#2ec53c49. + // Decoding updateNotificationGroup#96cd9e06. v := UpdateNotificationGroup{} if err := v.DecodeTDLibJSON(buf); err != nil { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) @@ -23541,6 +24116,13 @@ func DecodeTDLibJSONUpdate(buf tdjson.Decoder) (UpdateClass, error) { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) } return &v, nil + case "updateSavedNotificationSounds": + // Decoding updateSavedNotificationSounds#5a6653b4. + v := UpdateSavedNotificationSounds{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) + } + return &v, nil case "updateSelectedBackground": // Decoding updateSelectedBackground#99bd205d. v := UpdateSelectedBackground{} @@ -23583,6 +24165,20 @@ func DecodeTDLibJSONUpdate(buf tdjson.Decoder) (UpdateClass, error) { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) } return &v, nil + case "updateAttachmentMenuBots": + // Decoding updateAttachmentMenuBots#b6b910c. + v := UpdateAttachmentMenuBots{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) + } + return &v, nil + case "updateWebAppMessageSent": + // Decoding updateWebAppMessageSent#58431229. + v := UpdateWebAppMessageSent{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) + } + return &v, nil case "updateReactions": // Decoding updateReactions#e769e4e7. v := UpdateReactions{} diff --git a/tdapi/tl_user_full_info_gen.go b/tdapi/tl_user_full_info_gen.go index d4dc7f15a2..a61dac08d7 100644 --- a/tdapi/tl_user_full_info_gen.go +++ b/tdapi/tl_user_full_info_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// UserFullInfo represents TL type `userFullInfo#bbb225cf`. +// UserFullInfo represents TL type `userFullInfo#b2090391`. type UserFullInfo struct { // User profile photo; may be null Photo ChatPhoto @@ -50,20 +50,15 @@ type UserFullInfo struct { NeedPhoneNumberPrivacyException bool // A short user bio Bio string - // For bots, the text that is shown on the bot's profile page and is sent together with - // the link when users share the bot - ShareText string - // Contains full information about a user - Description string // Number of group chats where both the other user and the current user are a member; 0 // for the current user GroupInCommonCount int32 - // For bots, list of the bot commands - Commands []BotCommand + // For bots, information about the bot; may be null + BotInfo BotInfo } // UserFullInfoTypeID is TL type id of UserFullInfo. -const UserFullInfoTypeID = 0xbbb225cf +const UserFullInfoTypeID = 0xb2090391 // Ensuring interfaces in compile-time for UserFullInfo. var ( @@ -101,16 +96,10 @@ func (u *UserFullInfo) Zero() bool { if !(u.Bio == "") { return false } - if !(u.ShareText == "") { - return false - } - if !(u.Description == "") { - return false - } if !(u.GroupInCommonCount == 0) { return false } - if !(u.Commands == nil) { + if !(u.BotInfo.Zero()) { return false } @@ -181,21 +170,13 @@ func (u *UserFullInfo) TypeInfo() tdp.Type { Name: "Bio", SchemaName: "bio", }, - { - Name: "ShareText", - SchemaName: "share_text", - }, - { - Name: "Description", - SchemaName: "description", - }, { Name: "GroupInCommonCount", SchemaName: "group_in_common_count", }, { - Name: "Commands", - SchemaName: "commands", + Name: "BotInfo", + SchemaName: "bot_info", }, } return typ @@ -204,7 +185,7 @@ func (u *UserFullInfo) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (u *UserFullInfo) Encode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode userFullInfo#bbb225cf as nil") + return fmt.Errorf("can't encode userFullInfo#b2090391 as nil") } b.PutID(UserFullInfoTypeID) return u.EncodeBare(b) @@ -213,10 +194,10 @@ func (u *UserFullInfo) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (u *UserFullInfo) EncodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode userFullInfo#bbb225cf as nil") + return fmt.Errorf("can't encode userFullInfo#b2090391 as nil") } if err := u.Photo.Encode(b); err != nil { - return fmt.Errorf("unable to encode userFullInfo#bbb225cf: field photo: %w", err) + return fmt.Errorf("unable to encode userFullInfo#b2090391: field photo: %w", err) } b.PutBool(u.IsBlocked) b.PutBool(u.CanBeCalled) @@ -225,14 +206,9 @@ func (u *UserFullInfo) EncodeBare(b *bin.Buffer) error { b.PutBool(u.HasPrivateForwards) b.PutBool(u.NeedPhoneNumberPrivacyException) b.PutString(u.Bio) - b.PutString(u.ShareText) - b.PutString(u.Description) b.PutInt32(u.GroupInCommonCount) - b.PutInt(len(u.Commands)) - for idx, v := range u.Commands { - if err := v.EncodeBare(b); err != nil { - return fmt.Errorf("unable to encode bare userFullInfo#bbb225cf: field commands element with index %d: %w", idx, err) - } + if err := u.BotInfo.Encode(b); err != nil { + return fmt.Errorf("unable to encode userFullInfo#b2090391: field bot_info: %w", err) } return nil } @@ -240,10 +216,10 @@ func (u *UserFullInfo) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (u *UserFullInfo) Decode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode userFullInfo#bbb225cf to nil") + return fmt.Errorf("can't decode userFullInfo#b2090391 to nil") } if err := b.ConsumeID(UserFullInfoTypeID); err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: %w", err) + return fmt.Errorf("unable to decode userFullInfo#b2090391: %w", err) } return u.DecodeBare(b) } @@ -251,98 +227,72 @@ func (u *UserFullInfo) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (u *UserFullInfo) DecodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode userFullInfo#bbb225cf to nil") + return fmt.Errorf("can't decode userFullInfo#b2090391 to nil") } { if err := u.Photo.Decode(b); err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field photo: %w", err) + return fmt.Errorf("unable to decode userFullInfo#b2090391: field photo: %w", err) } } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field is_blocked: %w", err) + return fmt.Errorf("unable to decode userFullInfo#b2090391: field is_blocked: %w", err) } u.IsBlocked = value } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field can_be_called: %w", err) + return fmt.Errorf("unable to decode userFullInfo#b2090391: field can_be_called: %w", err) } u.CanBeCalled = value } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field supports_video_calls: %w", err) + return fmt.Errorf("unable to decode userFullInfo#b2090391: field supports_video_calls: %w", err) } u.SupportsVideoCalls = value } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field has_private_calls: %w", err) + return fmt.Errorf("unable to decode userFullInfo#b2090391: field has_private_calls: %w", err) } u.HasPrivateCalls = value } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field has_private_forwards: %w", err) + return fmt.Errorf("unable to decode userFullInfo#b2090391: field has_private_forwards: %w", err) } u.HasPrivateForwards = value } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field need_phone_number_privacy_exception: %w", err) + return fmt.Errorf("unable to decode userFullInfo#b2090391: field need_phone_number_privacy_exception: %w", err) } u.NeedPhoneNumberPrivacyException = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field bio: %w", err) + return fmt.Errorf("unable to decode userFullInfo#b2090391: field bio: %w", err) } u.Bio = value } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field share_text: %w", err) - } - u.ShareText = value - } - { - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field description: %w", err) - } - u.Description = value - } { value, err := b.Int32() if err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field group_in_common_count: %w", err) + return fmt.Errorf("unable to decode userFullInfo#b2090391: field group_in_common_count: %w", err) } u.GroupInCommonCount = value } { - headerLen, err := b.Int() - if err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field commands: %w", err) - } - - if headerLen > 0 { - u.Commands = make([]BotCommand, 0, headerLen%bin.PreallocateLimit) - } - for idx := 0; idx < headerLen; idx++ { - var value BotCommand - if err := value.DecodeBare(b); err != nil { - return fmt.Errorf("unable to decode bare userFullInfo#bbb225cf: field commands: %w", err) - } - u.Commands = append(u.Commands, value) + if err := u.BotInfo.Decode(b); err != nil { + return fmt.Errorf("unable to decode userFullInfo#b2090391: field bot_info: %w", err) } } return nil @@ -351,14 +301,14 @@ func (u *UserFullInfo) DecodeBare(b *bin.Buffer) error { // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (u *UserFullInfo) EncodeTDLibJSON(b tdjson.Encoder) error { if u == nil { - return fmt.Errorf("can't encode userFullInfo#bbb225cf as nil") + return fmt.Errorf("can't encode userFullInfo#b2090391 as nil") } b.ObjStart() b.PutID("userFullInfo") b.Comma() b.FieldStart("photo") if err := u.Photo.EncodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to encode userFullInfo#bbb225cf: field photo: %w", err) + return fmt.Errorf("unable to encode userFullInfo#b2090391: field photo: %w", err) } b.Comma() b.FieldStart("is_blocked") @@ -382,25 +332,13 @@ func (u *UserFullInfo) EncodeTDLibJSON(b tdjson.Encoder) error { b.FieldStart("bio") b.PutString(u.Bio) b.Comma() - b.FieldStart("share_text") - b.PutString(u.ShareText) - b.Comma() - b.FieldStart("description") - b.PutString(u.Description) - b.Comma() b.FieldStart("group_in_common_count") b.PutInt32(u.GroupInCommonCount) b.Comma() - b.FieldStart("commands") - b.ArrStart() - for idx, v := range u.Commands { - if err := v.EncodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to encode userFullInfo#bbb225cf: field commands element with index %d: %w", idx, err) - } - b.Comma() + b.FieldStart("bot_info") + if err := u.BotInfo.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode userFullInfo#b2090391: field bot_info: %w", err) } - b.StripComma() - b.ArrEnd() b.Comma() b.StripComma() b.ObjEnd() @@ -410,89 +348,70 @@ func (u *UserFullInfo) EncodeTDLibJSON(b tdjson.Encoder) error { // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (u *UserFullInfo) DecodeTDLibJSON(b tdjson.Decoder) error { if u == nil { - return fmt.Errorf("can't decode userFullInfo#bbb225cf to nil") + return fmt.Errorf("can't decode userFullInfo#b2090391 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("userFullInfo"); err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: %w", err) + return fmt.Errorf("unable to decode userFullInfo#b2090391: %w", err) } case "photo": if err := u.Photo.DecodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field photo: %w", err) + return fmt.Errorf("unable to decode userFullInfo#b2090391: field photo: %w", err) } case "is_blocked": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field is_blocked: %w", err) + return fmt.Errorf("unable to decode userFullInfo#b2090391: field is_blocked: %w", err) } u.IsBlocked = value case "can_be_called": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field can_be_called: %w", err) + return fmt.Errorf("unable to decode userFullInfo#b2090391: field can_be_called: %w", err) } u.CanBeCalled = value case "supports_video_calls": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field supports_video_calls: %w", err) + return fmt.Errorf("unable to decode userFullInfo#b2090391: field supports_video_calls: %w", err) } u.SupportsVideoCalls = value case "has_private_calls": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field has_private_calls: %w", err) + return fmt.Errorf("unable to decode userFullInfo#b2090391: field has_private_calls: %w", err) } u.HasPrivateCalls = value case "has_private_forwards": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field has_private_forwards: %w", err) + return fmt.Errorf("unable to decode userFullInfo#b2090391: field has_private_forwards: %w", err) } u.HasPrivateForwards = value case "need_phone_number_privacy_exception": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field need_phone_number_privacy_exception: %w", err) + return fmt.Errorf("unable to decode userFullInfo#b2090391: field need_phone_number_privacy_exception: %w", err) } u.NeedPhoneNumberPrivacyException = value case "bio": value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field bio: %w", err) + return fmt.Errorf("unable to decode userFullInfo#b2090391: field bio: %w", err) } u.Bio = value - case "share_text": - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field share_text: %w", err) - } - u.ShareText = value - case "description": - value, err := b.String() - if err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field description: %w", err) - } - u.Description = value case "group_in_common_count": value, err := b.Int32() if err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field group_in_common_count: %w", err) + return fmt.Errorf("unable to decode userFullInfo#b2090391: field group_in_common_count: %w", err) } u.GroupInCommonCount = value - case "commands": - if err := b.Arr(func(b tdjson.Decoder) error { - var value BotCommand - if err := value.DecodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field commands: %w", err) - } - u.Commands = append(u.Commands, value) - return nil - }); err != nil { - return fmt.Errorf("unable to decode userFullInfo#bbb225cf: field commands: %w", err) + case "bot_info": + if err := u.BotInfo.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode userFullInfo#b2090391: field bot_info: %w", err) } default: return b.Skip() @@ -565,22 +484,6 @@ func (u *UserFullInfo) GetBio() (value string) { return u.Bio } -// GetShareText returns value of ShareText field. -func (u *UserFullInfo) GetShareText() (value string) { - if u == nil { - return - } - return u.ShareText -} - -// GetDescription returns value of Description field. -func (u *UserFullInfo) GetDescription() (value string) { - if u == nil { - return - } - return u.Description -} - // GetGroupInCommonCount returns value of GroupInCommonCount field. func (u *UserFullInfo) GetGroupInCommonCount() (value int32) { if u == nil { @@ -589,10 +492,10 @@ func (u *UserFullInfo) GetGroupInCommonCount() (value int32) { return u.GroupInCommonCount } -// GetCommands returns value of Commands field. -func (u *UserFullInfo) GetCommands() (value []BotCommand) { +// GetBotInfo returns value of BotInfo field. +func (u *UserFullInfo) GetBotInfo() (value BotInfo) { if u == nil { return } - return u.Commands + return u.BotInfo } diff --git a/tdapi/tl_user_type_gen.go b/tdapi/tl_user_type_gen.go index 90c6d03c18..56757a1286 100644 --- a/tdapi/tl_user_type_gen.go +++ b/tdapi/tl_user_type_gen.go @@ -293,7 +293,7 @@ func (u *UserTypeDeleted) DecodeTDLibJSON(b tdjson.Decoder) error { }) } -// UserTypeBot represents TL type `userTypeBot#4b3e8235`. +// UserTypeBot represents TL type `userTypeBot#c6256f88`. type UserTypeBot struct { // True, if the bot can be invited to basic group and supergroup chats CanJoinGroups bool @@ -308,10 +308,12 @@ type UserTypeBot struct { // True, if the location of the user is expected to be sent with every inline query to // this bot NeedLocation bool + // True, if the bot can be added to attachment menu + CanBeAddedToAttachmentMenu bool } // UserTypeBotTypeID is TL type id of UserTypeBot. -const UserTypeBotTypeID = 0x4b3e8235 +const UserTypeBotTypeID = 0xc6256f88 // construct implements constructor of UserTypeClass. func (u UserTypeBot) construct() UserTypeClass { return &u } @@ -345,6 +347,9 @@ func (u *UserTypeBot) Zero() bool { if !(u.NeedLocation == false) { return false } + if !(u.CanBeAddedToAttachmentMenu == false) { + return false + } return true } @@ -401,6 +406,10 @@ func (u *UserTypeBot) TypeInfo() tdp.Type { Name: "NeedLocation", SchemaName: "need_location", }, + { + Name: "CanBeAddedToAttachmentMenu", + SchemaName: "can_be_added_to_attachment_menu", + }, } return typ } @@ -408,7 +417,7 @@ func (u *UserTypeBot) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (u *UserTypeBot) Encode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode userTypeBot#4b3e8235 as nil") + return fmt.Errorf("can't encode userTypeBot#c6256f88 as nil") } b.PutID(UserTypeBotTypeID) return u.EncodeBare(b) @@ -417,23 +426,24 @@ func (u *UserTypeBot) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (u *UserTypeBot) EncodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode userTypeBot#4b3e8235 as nil") + return fmt.Errorf("can't encode userTypeBot#c6256f88 as nil") } b.PutBool(u.CanJoinGroups) b.PutBool(u.CanReadAllGroupMessages) b.PutBool(u.IsInline) b.PutString(u.InlineQueryPlaceholder) b.PutBool(u.NeedLocation) + b.PutBool(u.CanBeAddedToAttachmentMenu) return nil } // Decode implements bin.Decoder. func (u *UserTypeBot) Decode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode userTypeBot#4b3e8235 to nil") + return fmt.Errorf("can't decode userTypeBot#c6256f88 to nil") } if err := b.ConsumeID(UserTypeBotTypeID); err != nil { - return fmt.Errorf("unable to decode userTypeBot#4b3e8235: %w", err) + return fmt.Errorf("unable to decode userTypeBot#c6256f88: %w", err) } return u.DecodeBare(b) } @@ -441,50 +451,57 @@ func (u *UserTypeBot) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (u *UserTypeBot) DecodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode userTypeBot#4b3e8235 to nil") + return fmt.Errorf("can't decode userTypeBot#c6256f88 to nil") } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode userTypeBot#4b3e8235: field can_join_groups: %w", err) + return fmt.Errorf("unable to decode userTypeBot#c6256f88: field can_join_groups: %w", err) } u.CanJoinGroups = value } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode userTypeBot#4b3e8235: field can_read_all_group_messages: %w", err) + return fmt.Errorf("unable to decode userTypeBot#c6256f88: field can_read_all_group_messages: %w", err) } u.CanReadAllGroupMessages = value } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode userTypeBot#4b3e8235: field is_inline: %w", err) + return fmt.Errorf("unable to decode userTypeBot#c6256f88: field is_inline: %w", err) } u.IsInline = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode userTypeBot#4b3e8235: field inline_query_placeholder: %w", err) + return fmt.Errorf("unable to decode userTypeBot#c6256f88: field inline_query_placeholder: %w", err) } u.InlineQueryPlaceholder = value } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode userTypeBot#4b3e8235: field need_location: %w", err) + return fmt.Errorf("unable to decode userTypeBot#c6256f88: field need_location: %w", err) } u.NeedLocation = value } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode userTypeBot#c6256f88: field can_be_added_to_attachment_menu: %w", err) + } + u.CanBeAddedToAttachmentMenu = value + } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (u *UserTypeBot) EncodeTDLibJSON(b tdjson.Encoder) error { if u == nil { - return fmt.Errorf("can't encode userTypeBot#4b3e8235 as nil") + return fmt.Errorf("can't encode userTypeBot#c6256f88 as nil") } b.ObjStart() b.PutID("userTypeBot") @@ -504,6 +521,9 @@ func (u *UserTypeBot) EncodeTDLibJSON(b tdjson.Encoder) error { b.FieldStart("need_location") b.PutBool(u.NeedLocation) b.Comma() + b.FieldStart("can_be_added_to_attachment_menu") + b.PutBool(u.CanBeAddedToAttachmentMenu) + b.Comma() b.StripComma() b.ObjEnd() return nil @@ -512,45 +532,51 @@ func (u *UserTypeBot) EncodeTDLibJSON(b tdjson.Encoder) error { // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (u *UserTypeBot) DecodeTDLibJSON(b tdjson.Decoder) error { if u == nil { - return fmt.Errorf("can't decode userTypeBot#4b3e8235 to nil") + return fmt.Errorf("can't decode userTypeBot#c6256f88 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("userTypeBot"); err != nil { - return fmt.Errorf("unable to decode userTypeBot#4b3e8235: %w", err) + return fmt.Errorf("unable to decode userTypeBot#c6256f88: %w", err) } case "can_join_groups": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode userTypeBot#4b3e8235: field can_join_groups: %w", err) + return fmt.Errorf("unable to decode userTypeBot#c6256f88: field can_join_groups: %w", err) } u.CanJoinGroups = value case "can_read_all_group_messages": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode userTypeBot#4b3e8235: field can_read_all_group_messages: %w", err) + return fmt.Errorf("unable to decode userTypeBot#c6256f88: field can_read_all_group_messages: %w", err) } u.CanReadAllGroupMessages = value case "is_inline": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode userTypeBot#4b3e8235: field is_inline: %w", err) + return fmt.Errorf("unable to decode userTypeBot#c6256f88: field is_inline: %w", err) } u.IsInline = value case "inline_query_placeholder": value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode userTypeBot#4b3e8235: field inline_query_placeholder: %w", err) + return fmt.Errorf("unable to decode userTypeBot#c6256f88: field inline_query_placeholder: %w", err) } u.InlineQueryPlaceholder = value case "need_location": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode userTypeBot#4b3e8235: field need_location: %w", err) + return fmt.Errorf("unable to decode userTypeBot#c6256f88: field need_location: %w", err) } u.NeedLocation = value + case "can_be_added_to_attachment_menu": + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode userTypeBot#c6256f88: field can_be_added_to_attachment_menu: %w", err) + } + u.CanBeAddedToAttachmentMenu = value default: return b.Skip() } @@ -598,6 +624,14 @@ func (u *UserTypeBot) GetNeedLocation() (value bool) { return u.NeedLocation } +// GetCanBeAddedToAttachmentMenu returns value of CanBeAddedToAttachmentMenu field. +func (u *UserTypeBot) GetCanBeAddedToAttachmentMenu() (value bool) { + if u == nil { + return + } + return u.CanBeAddedToAttachmentMenu +} + // UserTypeUnknown represents TL type `userTypeUnknown#d4d0613d`. type UserTypeUnknown struct { } @@ -742,7 +776,7 @@ const UserTypeClassName = "UserType" // switch v := g.(type) { // case *tdapi.UserTypeRegular: // userTypeRegular#dc51699b // case *tdapi.UserTypeDeleted: // userTypeDeleted#94403d24 -// case *tdapi.UserTypeBot: // userTypeBot#4b3e8235 +// case *tdapi.UserTypeBot: // userTypeBot#c6256f88 // case *tdapi.UserTypeUnknown: // userTypeUnknown#d4d0613d // default: panic(v) // } @@ -790,7 +824,7 @@ func DecodeUserType(buf *bin.Buffer) (UserTypeClass, error) { } return &v, nil case UserTypeBotTypeID: - // Decoding userTypeBot#4b3e8235. + // Decoding userTypeBot#c6256f88. v := UserTypeBot{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode UserTypeClass: %w", err) @@ -830,7 +864,7 @@ func DecodeTDLibJSONUserType(buf tdjson.Decoder) (UserTypeClass, error) { } return &v, nil case "userTypeBot": - // Decoding userTypeBot#4b3e8235. + // Decoding userTypeBot#c6256f88. v := UserTypeBot{} if err := v.DecodeTDLibJSON(buf); err != nil { return nil, fmt.Errorf("unable to decode UserTypeClass: %w", err) diff --git a/tdapi/tl_web_app_info_gen.go b/tdapi/tl_web_app_info_gen.go new file mode 100644 index 0000000000..58d3d700d8 --- /dev/null +++ b/tdapi/tl_web_app_info_gen.go @@ -0,0 +1,227 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +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{} +) + +// WebAppInfo represents TL type `webAppInfo#2efdb2e8`. +type WebAppInfo struct { + // Unique identifier for the web app launch + LaunchID int64 + // A web app URL to open in a web view + URL string +} + +// WebAppInfoTypeID is TL type id of WebAppInfo. +const WebAppInfoTypeID = 0x2efdb2e8 + +// Ensuring interfaces in compile-time for WebAppInfo. +var ( + _ bin.Encoder = &WebAppInfo{} + _ bin.Decoder = &WebAppInfo{} + _ bin.BareEncoder = &WebAppInfo{} + _ bin.BareDecoder = &WebAppInfo{} +) + +func (w *WebAppInfo) Zero() bool { + if w == nil { + return true + } + if !(w.LaunchID == 0) { + return false + } + if !(w.URL == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (w *WebAppInfo) String() string { + if w == nil { + return "WebAppInfo(nil)" + } + type Alias WebAppInfo + return fmt.Sprintf("WebAppInfo%+v", Alias(*w)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*WebAppInfo) TypeID() uint32 { + return WebAppInfoTypeID +} + +// TypeName returns name of type in TL schema. +func (*WebAppInfo) TypeName() string { + return "webAppInfo" +} + +// TypeInfo returns info about TL type. +func (w *WebAppInfo) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "webAppInfo", + ID: WebAppInfoTypeID, + } + if w == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "LaunchID", + SchemaName: "launch_id", + }, + { + Name: "URL", + SchemaName: "url", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (w *WebAppInfo) Encode(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't encode webAppInfo#2efdb2e8 as nil") + } + b.PutID(WebAppInfoTypeID) + return w.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (w *WebAppInfo) EncodeBare(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't encode webAppInfo#2efdb2e8 as nil") + } + b.PutLong(w.LaunchID) + b.PutString(w.URL) + return nil +} + +// Decode implements bin.Decoder. +func (w *WebAppInfo) Decode(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't decode webAppInfo#2efdb2e8 to nil") + } + if err := b.ConsumeID(WebAppInfoTypeID); err != nil { + return fmt.Errorf("unable to decode webAppInfo#2efdb2e8: %w", err) + } + return w.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (w *WebAppInfo) DecodeBare(b *bin.Buffer) error { + if w == nil { + return fmt.Errorf("can't decode webAppInfo#2efdb2e8 to nil") + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode webAppInfo#2efdb2e8: field launch_id: %w", err) + } + w.LaunchID = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode webAppInfo#2efdb2e8: field url: %w", err) + } + w.URL = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (w *WebAppInfo) EncodeTDLibJSON(b tdjson.Encoder) error { + if w == nil { + return fmt.Errorf("can't encode webAppInfo#2efdb2e8 as nil") + } + b.ObjStart() + b.PutID("webAppInfo") + b.Comma() + b.FieldStart("launch_id") + b.PutLong(w.LaunchID) + b.Comma() + b.FieldStart("url") + b.PutString(w.URL) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (w *WebAppInfo) DecodeTDLibJSON(b tdjson.Decoder) error { + if w == nil { + return fmt.Errorf("can't decode webAppInfo#2efdb2e8 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("webAppInfo"); err != nil { + return fmt.Errorf("unable to decode webAppInfo#2efdb2e8: %w", err) + } + case "launch_id": + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode webAppInfo#2efdb2e8: field launch_id: %w", err) + } + w.LaunchID = value + case "url": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode webAppInfo#2efdb2e8: field url: %w", err) + } + w.URL = value + default: + return b.Skip() + } + return nil + }) +} + +// GetLaunchID returns value of LaunchID field. +func (w *WebAppInfo) GetLaunchID() (value int64) { + if w == nil { + return + } + return w.LaunchID +} + +// GetURL returns value of URL field. +func (w *WebAppInfo) GetURL() (value string) { + if w == nil { + return + } + return w.URL +}