diff --git a/crates/teloxide-core/schema.ron b/crates/teloxide-core/schema.ron index 4a0c41e8..446c1d11 100644 --- a/crates/teloxide-core/schema.ron +++ b/crates/teloxide-core/schema.ron @@ -1,14 +1,14 @@ //! This file is written in [RON] (Rusty Object Notation). -//! -//! This "schema" is a formalized version of the +//! +//! This "schema" is a formalized version of the //! [telegram bot api documentation][tbadoc] which is not machine readable. //! (note: this schema currently covers only API methods and **not** types). -//! +//! //! Also, note that this file is **hand written** and may contain typos, //! deviations from original doc, and other kinds of typical human errors. //! If you found an error please open an issue (or make a PR) on [github]. -//! -//! This schema is targeting code generation for API wrappers in a statically +//! +//! This schema is targeting code generation for API wrappers in a statically //! typed language, though you may use it whatever you want. //! //! This scheme also has some intentional differences from original doc: @@ -20,26 +20,26 @@ //! + `AllowedUpdate` inner type of `allowed_updates` in `getUpdates` and //! `setWebhook` (so type is `ArrayOf(AllowedUpdate)`) //! + `ReplyMarkup` - type of `reply_markup` parameter, in the original -//! documentation written as `InlineKeyboardMarkup or ReplyKeyboardMarkup or +//! documentation written as `InlineKeyboardMarkup or ReplyKeyboardMarkup or //! ReplyKeyboardRemove or ForceReply` //! + `ParseMode` type of `parse_mode` params //! + `PollType` type of poll, either “quiz” or “regular” //! + `DiceEmoji` emoji that can be used in `sendDice` one of “🎲”, “🎯”, or “🏀” //! + `TargetMessage` either `inline_message_id: String` or `chat_id: ChatId` and `message_id: i64` //! * Integers represented with more strict (when possible) types, e.g.: -//! `u8` (unsigned, 8-bit integer), `u32` (unsigned, 32-bit), +//! `u8` (unsigned, 8-bit integer), `u32` (unsigned, 32-bit), //! `i64` (signed, 64-bit), etc //! * Instead of optional parameters `Option(Ty)` is used //! * Instead of `InputFile or String` just `InputFile` is used (assuming that //! `InputFile` is a sum-type or something and it can contain `String`s) //! * `f64` ~= `Float number` -//! +//! //! [tbadoc]: https://core.telegram.org/bots/api //! [RON]: https://github.com/ron-rs/ron //! [github]: https://github.com/WaffleLapkin/tg-methods-schema Schema( - api_version: ApiVersion(ver: "7.1", date: "February 16, 2024"), + api_version: ApiVersion(ver: "7.2", date: "March 31, 2024"), methods: [ Method( names: ("getUpdates", "GetUpdates", "get_updates"), @@ -49,7 +49,7 @@ Schema( md_links: { "wiki": "https://en.wikipedia.org/wiki/Push_technology#Long_polling", "Update": "https://core.telegram.org/bots/api#update", - }, + }, ), tg_doc: "https://core.telegram.org/bots/api#getupdates", tg_category: "Getting updates", @@ -155,7 +155,7 @@ Schema( md_links: {"amazing guide to Webhooks": "https://core.telegram.org/bots/webhooks"} ) ] - ), + ), Method( names: ("deleteWebhook", "DeleteWebhook", "delete_webhook"), return_ty: True, @@ -205,7 +205,7 @@ Schema( tg_doc: "https://core.telegram.org/bots/api#logout", tg_category: "Available methods", params: [], - ), + ), Method( names: ("close", "Close", "close"), return_ty: True, @@ -259,7 +259,7 @@ Schema( ), Param( name: "disable_notification", - ty: Option(bool), + ty: Option(bool), descr: Doc( md: "Sends the message [silently]. Users will receive a notification with no sound.", md_links: {"silently": "https://telegram.org/blog/channels-2-0#silent-messages"} @@ -315,7 +315,7 @@ Schema( ), Param( name: "disable_notification", - ty: Option(bool), + ty: Option(bool), descr: Doc( md: "Sends the message [silently]. Users will receive a notification with no sound.", md_links: {"silently": "https://telegram.org/blog/channels-2-0#silent-messages"} @@ -328,7 +328,7 @@ Schema( ), Param( name: "message_id", - ty: RawTy("MessageId"), + ty: RawTy("MessageId"), descr: Doc(md: "Message identifier in the chat specified in _from\\_chat\\_id_") ), ], @@ -365,7 +365,7 @@ Schema( ), Param( name: "disable_notification", - ty: Option(bool), + ty: Option(bool), descr: Doc( md: "Sends the message [silently]. Users will receive a notification with no sound.", md_links: {"silently": "https://telegram.org/blog/channels-2-0#silent-messages"} @@ -405,7 +405,7 @@ Schema( ), Param( name: "message_id", - ty: RawTy("MessageId"), + ty: RawTy("MessageId"), descr: Doc(md: "Message identifier in the chat specified in _from\\_chat\\_id_") ), Param( @@ -428,7 +428,7 @@ Schema( ), Param( name: "disable_notification", - ty: Option(bool), + ty: Option(bool), descr: Doc( md: "Sends the message [silently]. Users will receive a notification with no sound.", md_links: {"silently": "https://telegram.org/blog/channels-2-0#silent-messages"} @@ -487,12 +487,12 @@ Schema( ), Param( name: "message_ids", - ty: ArrayOf(RawTy("MessageId")), + ty: ArrayOf(RawTy("MessageId")), descr: Doc(md: "Identifiers of 1-100 messages in the chat _from\\_chat\\_id_ to copy. The identifiers must be specified in a strictly increasing order.") ), Param( name: "disable_notification", - ty: Option(bool), + ty: Option(bool), descr: Doc( md: "Sends the message [silently]. Users will receive a notification with no sound.", md_links: {"silently": "https://telegram.org/blog/channels-2-0#silent-messages"} @@ -555,7 +555,7 @@ Schema( name: "caption_entities", ty: Option(ArrayOf(RawTy("MessageEntity"))), descr: Doc(md: "List of special entities that appear in the photo caption, which can be specified instead of _parse\\_mode_"), - ), + ), Param( name: "has_spoiler", ty: Option(bool), @@ -563,7 +563,7 @@ Schema( ), Param( name: "disable_notification", - ty: Option(bool), + ty: Option(bool), descr: Doc( md: "Sends the message [silently]. Users will receive a notification with no sound.", md_links: {"silently": "https://telegram.org/blog/channels-2-0#silent-messages"} @@ -666,7 +666,7 @@ Schema( ), Param( name: "disable_notification", - ty: Option(bool), + ty: Option(bool), descr: Doc( md: "Sends the message [silently]. Users will receive a notification with no sound.", md_links: {"silently": "https://telegram.org/blog/channels-2-0#silent-messages"}, @@ -756,7 +756,7 @@ Schema( ), Param( name: "disable_notification", - ty: Option(bool), + ty: Option(bool), descr: Doc( md: "Sends the message [silently]. Users will receive a notification with no sound.", md_links: {"silently": "https://telegram.org/blog/channels-2-0#silent-messages"}, @@ -869,7 +869,7 @@ Schema( ), Param( name: "disable_notification", - ty: Option(bool), + ty: Option(bool), descr: Doc( md: "Sends the message [silently]. Users will receive a notification with no sound.", md_links: {"silently": "https://telegram.org/blog/channels-2-0#silent-messages"}, @@ -895,7 +895,7 @@ Schema( "custom reply keyboard": "https://core.telegram.org/bots#keyboards", } ), - + ), ], ), @@ -975,7 +975,7 @@ Schema( ), Param( name: "disable_notification", - ty: Option(bool), + ty: Option(bool), descr: Doc( md: "Sends the message [silently]. Users will receive a notification with no sound.", md_links: {"silently": "https://telegram.org/blog/channels-2-0#silent-messages"}, @@ -1061,7 +1061,7 @@ Schema( ), Param( name: "disable_notification", - ty: Option(bool), + ty: Option(bool), descr: Doc( md: "Sends the message [silently]. Users will receive a notification with no sound.", md_links: {"silently": "https://telegram.org/blog/channels-2-0#silent-messages"}, @@ -1080,7 +1080,7 @@ Schema( md_links: { "inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating", "custom reply keyboard": "https://core.telegram.org/bots#keyboards", - } + } ), ), ], @@ -1136,7 +1136,7 @@ Schema( ), Param( name: "disable_notification", - ty: Option(bool), + ty: Option(bool), descr: Doc( md: "Sends the message [silently]. Users will receive a notification with no sound.", md_links: {"silently": "https://telegram.org/blog/channels-2-0#silent-messages"}, @@ -1160,9 +1160,9 @@ Schema( md_links: { "inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating", "custom reply keyboard": "https://core.telegram.org/bots#keyboards", - } + } ), - + ), ], ), @@ -1193,7 +1193,7 @@ Schema( ), Param( name: "disable_notification", - ty: Option(bool), + ty: Option(bool), descr: Doc( md: "Sends the message [silently]. Users will receive a notification with no sound.", md_links: {"silently": "https://telegram.org/blog/channels-2-0#silent-messages"} @@ -1256,17 +1256,17 @@ Schema( ), Param( name: "heading", - ty: Option(u16), + ty: Option(u16), descr: Doc(md: "For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.") ), Param( name: "proximity_alert_radius", - ty: Option(u32), + ty: Option(u32), descr: Doc(md: "For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.") ), Param( name: "disable_notification", - ty: Option(bool), + ty: Option(bool), descr: Doc( md: "Sends the message [silently]. Users will receive a notification with no sound.", md_links: {"silently": "https://telegram.org/blog/channels-2-0#silent-messages"} @@ -1312,7 +1312,7 @@ Schema( ), Param( name: "message_id", - ty: RawTy("MessageId"), + ty: RawTy("MessageId"), descr: Doc(md: "Identifier of the message to edit") ), Param( @@ -1332,12 +1332,12 @@ Schema( ), Param( name: "heading", - ty: Option(u16), + ty: Option(u16), descr: Doc(md: "For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.") ), Param( name: "proximity_alert_radius", - ty: Option(u32), + ty: Option(u32), descr: Doc(md: "For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.") ), Param( @@ -1386,12 +1386,12 @@ Schema( ), Param( name: "heading", - ty: Option(u16), + ty: Option(u16), descr: Doc(md: "For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.") ), Param( name: "proximity_alert_radius", - ty: Option(u32), + ty: Option(u32), descr: Doc(md: "For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.") ), Param( @@ -1428,7 +1428,7 @@ Schema( ), Param( name: "message_id", - ty: RawTy("MessageId"), + ty: RawTy("MessageId"), descr: Doc(md: "Identifier of the message to edit") ), Param( @@ -1439,7 +1439,7 @@ Schema( md_links: { "inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating", "custom reply keyboard": "https://core.telegram.org/bots#keyboards", - } + } ), ), ], @@ -1539,7 +1539,7 @@ Schema( ), Param( name: "disable_notification", - ty: Option(bool), + ty: Option(bool), descr: Doc( md: "Sends the message [silently]. Users will receive a notification with no sound.", md_links: {"silently": "https://telegram.org/blog/channels-2-0#silent-messages"} @@ -1563,7 +1563,7 @@ Schema( md_links: { "inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating", "custom reply keyboard": "https://core.telegram.org/bots#keyboards", - } + } ), ), ], @@ -1613,7 +1613,7 @@ Schema( ), Param( name: "disable_notification", - ty: Option(bool), + ty: Option(bool), descr: Doc( md: "Sends the message [silently]. Users will receive a notification with no sound.", md_links: {"silently": "https://telegram.org/blog/channels-2-0#silent-messages"} @@ -1727,7 +1727,7 @@ Schema( ), Param( name: "disable_notification", - ty: Option(bool), + ty: Option(bool), descr: Doc( md: "Sends the message [silently]. Users will receive a notification with no sound.", md_links: {"silently": "https://telegram.org/blog/channels-2-0#silent-messages"} @@ -1751,7 +1751,7 @@ Schema( md_links: { "inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating", "custom reply keyboard": "https://core.telegram.org/bots#keyboards", - } + } ), ), ], @@ -1783,7 +1783,7 @@ Schema( ), Param( name: "disable_notification", - ty: Option(bool), + ty: Option(bool), descr: Doc( md: "Sends the message [silently]. Users will receive a notification with no sound.", md_links: {"silently": "https://telegram.org/blog/channels-2-0#silent-messages"} @@ -1826,7 +1826,7 @@ Schema( name: "chat_id", ty: RawTy("Recipient"), descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)") - ), + ), Param( name: "action", ty: RawTy("ChatAction"), @@ -2189,7 +2189,7 @@ Schema( descr: Doc(md: "Unique identifier of the target sender chat") ), ], - ), + ), Method( names: ("unbanChatSenderChat", "UnbanChatSenderChat", "unban_chat_sender_chat"), return_ty: True, @@ -2246,7 +2246,7 @@ Schema( descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)") ), ], - ), + ), Method( names: ("createChatInviteLink", "CreateChatInviteLink", "create_chat_invite_link"), return_ty: RawTy("ChatInviteLink"), @@ -2286,7 +2286,7 @@ Schema( descr: Doc(md: "True, if users joining the chat via the link need to be approved by chat administrators. If True, member_limit can't be specified") ), ], - ), + ), Method( names: ("editChatInviteLink", "EditChatInviteLink", "edit_chat_invite_link"), return_ty: String, @@ -2328,7 +2328,7 @@ Schema( descr: Doc(md: "True, if users joining the chat via the link need to be approved by chat administrators. If True, member_limit can't be specified") ), ], - ), + ), Method( names: ("revokeChatInviteLink", "RevokeChatInviteLink", "revoke_chat_invite_link"), return_ty: String, @@ -2479,7 +2479,7 @@ Schema( ), Param( name: "disable_notification", - ty: Option(bool), + ty: Option(bool), descr: Doc(md: "Pass True, if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels.") ), ], @@ -2976,7 +2976,7 @@ Schema( descr: Doc(md: "A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands") ), ], - ), + ), Method( names: ("getMyCommands", "GetMyCommands", "get_my_commands"), return_ty: ArrayOf(RawTy("BotCommand")), @@ -3238,7 +3238,7 @@ Schema( names: ("answerWebAppQuery", "AnswerWebAppQuery", "answer_web_app_query"), return_ty: RawTy("SentWebAppMessage"), doc: Doc( - md: "Use this method to set the result of an interaction with a [Web App] and send a corresponding message on behalf of the user to the chat from which the query originated.", + md: "Use this method to set the result of an interaction with a [Web App] and send a corresponding message on behalf of the user to the chat from which the query originated.", md_links: {"Web App": "https://core.telegram.org/bots/webapps"} ), tg_doc: "https://core.telegram.org/bots/api#answerwebappquery", @@ -3305,7 +3305,7 @@ Schema( ty: Option(RawTy("InlineKeyboardMarkup")), descr: Doc( md: "A JSON-serialized object for an [inline keyboard].", - md_links: {"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating"}, + md_links: {"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating"}, ), ), ], @@ -3399,7 +3399,7 @@ Schema( name: "reply_markup", ty: Option(RawTy("InlineKeyboardMarkup")), descr: Doc( - md: "A JSON-serialized object for an [inline keyboard].", + md: "A JSON-serialized object for an [inline keyboard].", md_links: {"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating",} ), ), @@ -3442,7 +3442,7 @@ Schema( ty: Option(RawTy("InlineKeyboardMarkup")), descr: Doc( md: "A JSON-serialized object for an [inline keyboard].", - md_links: {"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating"} + md_links: {"inline keyboard": "https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating"} ), ), ], @@ -3602,7 +3602,7 @@ Schema( name: "message_id", ty: RawTy("MessageId"), descr: Doc(md: "Identifier of the message to delete") - ), + ), ], ), Method( @@ -3624,14 +3624,14 @@ Schema( md: "Identifiers of 1-100 messages to delete. See [deleteMessage] for limitations on which messages can be deleted", md_links: {"deleteMessage": "https://core.telegram.org/bots/api#delete_message"} ) - ), + ), ], ), Method( names: ("sendSticker", "SendSticker", "send_sticker"), return_ty: RawTy("Message"), doc: Doc( - md: "Use this method to send static .WEBP or [animated] .TGS stickers. On success, the sent Message is returned.", + md: "Use this method to send static .WEBP or [animated] .TGS stickers. On success, the sent Message is returned.", md_links: {"animated": "https://telegram.org/blog/animated-stickers"} ), tg_doc: "https://core.telegram.org/bots/api#sendsticker", @@ -3662,7 +3662,7 @@ Schema( ), Param( name: "disable_notification", - ty: Option(bool), + ty: Option(bool), descr: Doc( md: "Sends the message [silently]. Users will receive a notification with no sound.", md_links: {"silently": "https://telegram.org/blog/channels-2-0#silent-messages"} @@ -3859,6 +3859,42 @@ Schema( ), ], ), + Method( + names: ("replaceStickerInSet", "ReplaceStickerInSet", "replace_sticker_in_set"), + return_ty: True, + doc: Doc( + md: "Use this method to replace an existing sticker in a sticker set with a new one. The method is equivalent to calling [DeleteStickerFromSet], then [AddStickerToSet], then [SetStickerPositionInSet]. Returns _True_ on success.", + md_links: { + "DeleteStickerFromSet": "https://docs.rs/teloxide/latest/teloxide/payloads/struct.DeleteStickerFromSet.html", + "AddStickerToSet": "https://docs.rs/teloxide/latest/teloxide/payloads/struct.AddStickerToSet.html", + "SetStickerPositionInSet": "https://docs.rs/teloxide/latest/teloxide/payloads/struct.SetStickerPositionInSet.html", + } + ), + tg_doc: "https://core.telegram.org/bots/api#replacestickerinset", + tg_category: "Stickers", + params: [ + Param( + name: "user_id", + ty: RawTy("UserId"), + descr: Doc(md: "User identifier of the sticker set owner"), + ), + Param( + name: "name", + ty: String, + descr: Doc(md: "Sticker set name"), + ), + Param( + name: "old_sticker", + ty: String, + descr: Doc(md: "File identifier of the replaced sticker"), + ), + Param( + name: "sticker", + ty: RawTy("InputSticker"), + descr: Doc(md: "A JSON-serialized object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set remains unchanged."), + ), + ], + ), Method( names: ("setStickerSetThumbnail", "SetStickerSetThumbnail", "set_sticker_set_thumbnail"), return_ty: True, @@ -4035,7 +4071,7 @@ Schema( ty: String, descr: Doc( md: "Payments provider token, obtained via [Botfather]", - md_links: {"Botfather":"https://t.me/botfather"} + md_links: {"Botfather":"https://t.me/botfather"} ), ), Param( @@ -4128,7 +4164,7 @@ Schema( ), Param( name: "disable_notification", - ty: Option(bool), + ty: Option(bool), descr: Doc( md: "Sends the message [silently]. Users will receive a notification with no sound.", md_links: {"silently": "https://telegram.org/blog/channels-2-0#silent-messages"} @@ -4181,7 +4217,7 @@ Schema( ty: String, descr: Doc( md: "Payments provider token, obtained via [Botfather]", - md_links: {"Botfather":"https://t.me/botfather"} + md_links: {"Botfather":"https://t.me/botfather"} ), ), Param( @@ -4352,7 +4388,7 @@ Schema( return_ty: RawTy("Message"), doc: Doc( md: "Use this method to send a game. On success, the sent [Message] is returned.", - md_links: {"Message": "https://core.telegram.org/bots/api#message"} + md_links: {"Message": "https://core.telegram.org/bots/api#message"} ), tg_doc: "https://core.telegram.org/bots/api#sendgame", tg_category: "Games", @@ -4374,7 +4410,7 @@ Schema( ), Param( name: "disable_notification", - ty: Option(bool), + ty: Option(bool), descr: Doc( md: "Sends the message [silently]. Users will receive a notification with no sound.", md_links: {"silently": "https://telegram.org/blog/channels-2-0#silent-messages"} @@ -4405,7 +4441,7 @@ Schema( return_ty: RawTy("Message"), doc: Doc( md: "Use this method to set the score of the specified user in a game. On success, returns the edited [Message]. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.", - md_links: {"Message": "https://core.telegram.org/bots/api#message"} + md_links: {"Message": "https://core.telegram.org/bots/api#message"} ), tg_doc: "https://core.telegram.org/bots/api#setgamescore", tg_category: "Games", @@ -4437,7 +4473,7 @@ Schema( ), Param( name: "message_id", - ty: RawTy("MessageId"), + ty: RawTy("MessageId"), descr: Doc(md: "Identifier of the message to edit") ), ], @@ -4508,7 +4544,7 @@ Schema( "Updating messages": "https://core.telegram.org/bots/api#updating-messages", "Stickers": "https://core.telegram.org/bots/api#stickers", "Payments": "https://core.telegram.org/bots/api#payments", - "Telegram Passport": "https://core.telegram.org/bots/api#telegram-passport", + "Telegram Passport": "https://core.telegram.org/bots/api#telegram-passport", "Games": "https://core.telegram.org/bots/api#games", } ) diff --git a/crates/teloxide-core/src/adaptors/cache_me.rs b/crates/teloxide-core/src/adaptors/cache_me.rs index aafe2aca..457822a6 100644 --- a/crates/teloxide-core/src/adaptors/cache_me.rs +++ b/crates/teloxide-core/src/adaptors/cache_me.rs @@ -196,6 +196,7 @@ where add_sticker_to_set, set_sticker_position_in_set, delete_sticker_from_set, + replace_sticker_in_set, set_sticker_set_thumbnail, set_custom_emoji_sticker_set_thumbnail, set_sticker_set_title, diff --git a/crates/teloxide-core/src/adaptors/erased.rs b/crates/teloxide-core/src/adaptors/erased.rs index 7d4eae0f..fc055f13 100644 --- a/crates/teloxide-core/src/adaptors/erased.rs +++ b/crates/teloxide-core/src/adaptors/erased.rs @@ -295,6 +295,7 @@ where add_sticker_to_set, set_sticker_position_in_set, delete_sticker_from_set, + replace_sticker_in_set, set_sticker_set_thumbnail, set_custom_emoji_sticker_set_thumbnail, set_sticker_set_title, diff --git a/crates/teloxide-core/src/adaptors/parse_mode.rs b/crates/teloxide-core/src/adaptors/parse_mode.rs index 2906302e..d6896693 100644 --- a/crates/teloxide-core/src/adaptors/parse_mode.rs +++ b/crates/teloxide-core/src/adaptors/parse_mode.rs @@ -269,6 +269,7 @@ where add_sticker_to_set, set_sticker_position_in_set, delete_sticker_from_set, + replace_sticker_in_set, set_sticker_set_thumbnail, set_custom_emoji_sticker_set_thumbnail, set_sticker_set_title, diff --git a/crates/teloxide-core/src/adaptors/throttle/requester_impl.rs b/crates/teloxide-core/src/adaptors/throttle/requester_impl.rs index 9c6fbd28..d9695664 100644 --- a/crates/teloxide-core/src/adaptors/throttle/requester_impl.rs +++ b/crates/teloxide-core/src/adaptors/throttle/requester_impl.rs @@ -178,6 +178,7 @@ where add_sticker_to_set, set_sticker_position_in_set, delete_sticker_from_set, + replace_sticker_in_set, set_sticker_set_thumbnail, set_custom_emoji_sticker_set_thumbnail, set_sticker_set_title, diff --git a/crates/teloxide-core/src/adaptors/trace.rs b/crates/teloxide-core/src/adaptors/trace.rs index 4a865dc3..2ff661d2 100644 --- a/crates/teloxide-core/src/adaptors/trace.rs +++ b/crates/teloxide-core/src/adaptors/trace.rs @@ -225,6 +225,7 @@ where add_sticker_to_set, set_sticker_position_in_set, delete_sticker_from_set, + replace_sticker_in_set, set_sticker_set_thumbnail, set_custom_emoji_sticker_set_thumbnail, set_sticker_set_title, diff --git a/crates/teloxide-core/src/bot/api.rs b/crates/teloxide-core/src/bot/api.rs index 2088bbcb..a1c1bbf9 100644 --- a/crates/teloxide-core/src/bot/api.rs +++ b/crates/teloxide-core/src/bot/api.rs @@ -1244,6 +1244,30 @@ impl Requester for Bot { Self::DeleteStickerFromSet::new(self.clone(), payloads::DeleteStickerFromSet::new(sticker)) } + type ReplaceStickerInSet = JsonRequest; + + fn replace_sticker_in_set( + &self, + user_id: UserId, + name: N, + old_sticker: O, + sticker: InputSticker, + ) -> Self::ReplaceStickerInSet + where + N: Into, + O: Into, + { + Self::ReplaceStickerInSet::new( + self.clone(), + payloads::ReplaceStickerInSet { + user_id, + name: name.into(), + old_sticker: old_sticker.into(), + sticker, + }, + ) + } + type SetStickerSetThumbnail = MultipartRequest; fn set_sticker_set_thumbnail(&self, name: N, user_id: UserId) -> Self::SetStickerSetThumbnail diff --git a/crates/teloxide-core/src/local_macros.rs b/crates/teloxide-core/src/local_macros.rs index 3fd2bbc7..7bc088cc 100644 --- a/crates/teloxide-core/src/local_macros.rs +++ b/crates/teloxide-core/src/local_macros.rs @@ -1339,6 +1339,15 @@ macro_rules! requester_forward { $body!(delete_sticker_from_set this (sticker: S)) } }; + (@method replace_sticker_in_set $body:ident $ty:ident) => { + type ReplaceStickerInSet = $ty![ReplaceStickerInSet]; + + fn replace_sticker_in_set(&self, user_id: UserId, name: N, old_sticker: O, sticker: InputSticker) -> Self::ReplaceStickerInSet where N: Into, + O: Into { + let this = self; + $body!(replace_sticker_in_set this (user_id: UserId, name: N, old_sticker: O, sticker: InputSticker)) + } + }; (@method set_sticker_set_thumbnail $body:ident $ty:ident) => { type SetStickerSetThumbnail = $ty![SetStickerSetThumbnail]; diff --git a/crates/teloxide-core/src/payloads.rs b/crates/teloxide-core/src/payloads.rs index 47fbac31..f298563d 100644 --- a/crates/teloxide-core/src/payloads.rs +++ b/crates/teloxide-core/src/payloads.rs @@ -88,6 +88,7 @@ mod pin_chat_message; mod promote_chat_member; mod reopen_forum_topic; mod reopen_general_forum_topic; +mod replace_sticker_in_set; mod restrict_chat_member; mod revoke_chat_invite_link; mod send_animation; @@ -225,6 +226,7 @@ pub use pin_chat_message::{PinChatMessage, PinChatMessageSetters}; pub use promote_chat_member::{PromoteChatMember, PromoteChatMemberSetters}; pub use reopen_forum_topic::{ReopenForumTopic, ReopenForumTopicSetters}; pub use reopen_general_forum_topic::{ReopenGeneralForumTopic, ReopenGeneralForumTopicSetters}; +pub use replace_sticker_in_set::{ReplaceStickerInSet, ReplaceStickerInSetSetters}; pub use restrict_chat_member::{RestrictChatMember, RestrictChatMemberSetters}; pub use revoke_chat_invite_link::{RevokeChatInviteLink, RevokeChatInviteLinkSetters}; pub use send_animation::{SendAnimation, SendAnimationSetters}; diff --git a/crates/teloxide-core/src/payloads/replace_sticker_in_set.rs b/crates/teloxide-core/src/payloads/replace_sticker_in_set.rs new file mode 100644 index 00000000..8e64e9b5 --- /dev/null +++ b/crates/teloxide-core/src/payloads/replace_sticker_in_set.rs @@ -0,0 +1,27 @@ +//! Generated by `codegen_payloads`, do not edit by hand. + +use serde::Serialize; + +use crate::types::{InputSticker, True, UserId}; + +impl_payload! { + @[multipart = sticker] + /// Use this method to replace an existing sticker in a sticker set with a new one. The method is equivalent to calling [DeleteStickerFromSet], then [AddStickerToSet], then [SetStickerPositionInSet]. Returns _True_ on success. + /// + /// [DeleteStickerFromSet]: https://docs.rs/teloxide/latest/teloxide/payloads/struct.DeleteStickerFromSet.html + /// [AddStickerToSet]: https://docs.rs/teloxide/latest/teloxide/payloads/struct.AddStickerToSet.html + /// [SetStickerPositionInSet]: https://docs.rs/teloxide/latest/teloxide/payloads/struct.SetStickerPositionInSet.html + #[derive(Debug, Clone, Serialize)] + pub ReplaceStickerInSet (ReplaceStickerInSetSetters) => True { + required { + /// User identifier of the sticker set owner + pub user_id: UserId, + /// Sticker set name + pub name: String [into], + /// File identifier of the replaced sticker + pub old_sticker: String [into], + /// A JSON-serialized object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set remains unchanged. + pub sticker: InputSticker, + } + } +} diff --git a/crates/teloxide-core/src/payloads/setters.rs b/crates/teloxide-core/src/payloads/setters.rs index 06a24b76..7ed3a581 100644 --- a/crates/teloxide-core/src/payloads/setters.rs +++ b/crates/teloxide-core/src/payloads/setters.rs @@ -29,10 +29,10 @@ pub use crate::payloads::{ GetWebhookInfoSetters as _, HideGeneralForumTopicSetters as _, KickChatMemberSetters as _, LeaveChatSetters as _, LogOutSetters as _, PinChatMessageSetters as _, PromoteChatMemberSetters as _, ReopenForumTopicSetters as _, - ReopenGeneralForumTopicSetters as _, RestrictChatMemberSetters as _, - RevokeChatInviteLinkSetters as _, SendAnimationSetters as _, SendAudioSetters as _, - SendChatActionSetters as _, SendContactSetters as _, SendDiceSetters as _, - SendDocumentSetters as _, SendGameSetters as _, SendInvoiceSetters as _, + ReopenGeneralForumTopicSetters as _, ReplaceStickerInSetSetters as _, + RestrictChatMemberSetters as _, RevokeChatInviteLinkSetters as _, SendAnimationSetters as _, + SendAudioSetters as _, SendChatActionSetters as _, SendContactSetters as _, + SendDiceSetters as _, SendDocumentSetters as _, SendGameSetters as _, SendInvoiceSetters as _, SendLocationSetters as _, SendMediaGroupSetters as _, SendMessageSetters as _, SendPhotoSetters as _, SendPollSetters as _, SendStickerSetters as _, SendVenueSetters as _, SendVideoNoteSetters as _, SendVideoSetters as _, SendVoiceSetters as _, diff --git a/crates/teloxide-core/src/requests/requester.rs b/crates/teloxide-core/src/requests/requester.rs index 977e2c19..731e370f 100644 --- a/crates/teloxide-core/src/requests/requester.rs +++ b/crates/teloxide-core/src/requests/requester.rs @@ -1108,6 +1108,20 @@ pub trait Requester { where S: Into; + type ReplaceStickerInSet: Request; + + /// For Telegram documentation see [`ReplaceStickerInSet`]. + fn replace_sticker_in_set( + &self, + user_id: UserId, + name: N, + old_sticker: O, + sticker: InputSticker, + ) -> Self::ReplaceStickerInSet + where + N: Into, + O: Into; + type SetStickerSetThumbnail: Request; /// For Telegram documentation see [`SetStickerSetThumbnail`]. @@ -1405,6 +1419,7 @@ macro_rules! forward_all { add_sticker_to_set, set_sticker_position_in_set, delete_sticker_from_set, + replace_sticker_in_set, set_sticker_set_thumbnail, set_custom_emoji_sticker_set_thumbnail, set_sticker_set_title,