From f624b9a996a865fb87421a312ff6d90b1cee1f5a Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Sat, 14 Jan 2023 20:01:54 +0400 Subject: [PATCH] TBA 6.4 methods --- crates/teloxide-core/schema.ron | 105 +++++++++++++++++- .../teloxide-core/src/adaptors/auto_send.rs | 5 + crates/teloxide-core/src/adaptors/cache_me.rs | 5 + crates/teloxide-core/src/adaptors/erased.rs | 74 +++++++++++- .../teloxide-core/src/adaptors/parse_mode.rs | 5 + .../src/adaptors/throttle/requester_impl.rs | 5 + crates/teloxide-core/src/adaptors/trace.rs | 5 + crates/teloxide-core/src/bot/api.rs | 77 +++++++++++-- crates/teloxide-core/src/codegen.rs | 2 +- crates/teloxide-core/src/local_macros.rs | 47 +++++++- crates/teloxide-core/src/payloads.rs | 10 ++ .../src/payloads/close_general_forum_topic.rs | 16 +++ .../src/payloads/edit_forum_topic.rs | 6 +- .../src/payloads/edit_general_forum_topic.rs | 18 +++ .../src/payloads/hide_general_forum_topic.rs | 16 +++ .../payloads/reopen_general_forum_topic.rs | 16 +++ .../src/payloads/send_animation.rs | 2 + .../src/payloads/send_chat_action.rs | 4 + .../teloxide-core/src/payloads/send_photo.rs | 2 + .../teloxide-core/src/payloads/send_video.rs | 2 + crates/teloxide-core/src/payloads/setters.rs | 26 +++-- .../payloads/unhide_general_forum_topic.rs | 16 +++ .../teloxide-core/src/requests/requester.rs | 53 +++++++-- 23 files changed, 467 insertions(+), 50 deletions(-) create mode 100644 crates/teloxide-core/src/payloads/close_general_forum_topic.rs create mode 100644 crates/teloxide-core/src/payloads/edit_general_forum_topic.rs create mode 100644 crates/teloxide-core/src/payloads/hide_general_forum_topic.rs create mode 100644 crates/teloxide-core/src/payloads/reopen_general_forum_topic.rs create mode 100644 crates/teloxide-core/src/payloads/unhide_general_forum_topic.rs diff --git a/crates/teloxide-core/schema.ron b/crates/teloxide-core/schema.ron index d814072e..5e1fe732 100644 --- a/crates/teloxide-core/schema.ron +++ b/crates/teloxide-core/schema.ron @@ -468,6 +468,11 @@ 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), + descr: Doc(md: "Pass True if the photo needs to be covered with a spoiler animation"), ), Param( name: "disable_notification", @@ -780,6 +785,11 @@ Schema( ty: Option(ArrayOf(RawTy("MessageEntity"))), descr: Doc(md: "List of special entities that appear in the caption, which can be specified instead of _parse\\_mode_"), ), + Param( + name: "has_spoiler", + ty: Option(bool), + descr: Doc(md: "Pass True if the video needs to be covered with a spoiler animation"), + ), Param( name: "supports_streaming", ty: Option(bool), @@ -891,6 +901,11 @@ Schema( 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), + descr: Doc(md: "Pass True if the animation needs to be covered with a spoiler animation"), + ), Param( name: "disable_notification", ty: Option(bool), @@ -1809,7 +1824,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"), @@ -1827,6 +1842,11 @@ Schema( } ), ), + Param( + name: "message_thread_id", + ty: Option(i32), + descr: Doc(md: "Unique identifier for the target message thread; supergroups only") + ), ], ), Method( @@ -2631,13 +2651,13 @@ Schema( ), Param( name: "name", - ty: String, - descr: Doc(md: "Topic name, 1-128 characters") + ty: Option(String), + descr: Doc(md: "Topic name, 0-128 characters. If not specified or empty, the current name of the topic will be kept") ), Param( name: "icon_custom_emoji_id", - ty: String, - descr: Doc(md: "Unique identifier of the custom emoji shown as the topic icon. Use `getForumTopicIconStickers` to get all allowed custom emoji identifiers.") + ty: Option(String), + descr: Doc(md: "Unique identifier of the custom emoji shown as the topic icon. Use `getForumTopicIconStickers` to get all allowed custom emoji identifiers. Pass an empty string to remove the icon. If not specified, the current icon will be kept") ), ], ), @@ -2717,6 +2737,81 @@ Schema( ), ], ), + Method( + names: ("editGeneralForumTopic", "EditGeneralForumTopic", "edit_general_forum_topic"), + return_ty: True, + doc: Doc(md: "Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have _can\\_manage\\_topics_ administrator rights. Returns True on success."), + tg_doc: "https://core.telegram.org/bots/api#editgeneralforumtopic", + tg_category: "Available methods", + params: [ + Param( + 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: "name", + ty: String, + descr: Doc(md: "New topic name, 1-128 characters"), + ), + ], + ), + Method( + names: ("closeGeneralForumTopic", "CloseGeneralForumTopic", "close_general_forum_topic"), + return_ty: True, + doc: Doc(md: "Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\\_manage\\_topics_ administrator rights. Returns True on success."), + tg_doc: "https://core.telegram.org/bots/api#closegeneralforumtopic", + tg_category: "Available methods", + params: [ + Param( + 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`)") + ), + ], + ), + Method( + names: ("reopenGeneralForumTopic", "ReopenGeneralForumTopic", "reopen_general_forum_topic"), + return_ty: True, + doc: Doc(md: "Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\\_manage\\_topics_ administrator rights. The topic will be automatically unhidden if it was hidden. Returns True on success."), + tg_doc: "https://core.telegram.org/bots/api#reopengeneralforumtopic", + tg_category: "Available methods", + params: [ + Param( + 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`)") + ), + ], + ), + Method( + names: ("hideGeneralForumTopic", "HideGeneralForumTopic", "hide_general_forum_topic"), + return_ty: True, + doc: Doc(md: "Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\\_manage\\_topics_ administrator rights. The topic will be automatically closed if it was open. Returns True on success."), + tg_doc: "https://core.telegram.org/bots/api#hidegeneralforumtopic", + tg_category: "Available methods", + params: [ + Param( + 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`)") + ), + ], + ), + Method( + names: ("unhideGeneralForumTopic", "UnhideGeneralForumTopic", "unhide_general_forum_topic"), + return_ty: True, + doc: Doc(md: "Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\\_manage\\_topics_ administrator rights. Returns True on success."), + tg_doc: "https://core.telegram.org/bots/api#unhidegeneralforumtopic", + tg_category: "Available methods", + params: [ + Param( + 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`)") + ), + ], + ), Method( names: ("answerCallbackQuery", "AnswerCallbackQuery", "answer_callback_query"), return_ty: True, diff --git a/crates/teloxide-core/src/adaptors/auto_send.rs b/crates/teloxide-core/src/adaptors/auto_send.rs index 2bd9c075..a613d486 100644 --- a/crates/teloxide-core/src/adaptors/auto_send.rs +++ b/crates/teloxide-core/src/adaptors/auto_send.rs @@ -127,6 +127,11 @@ where reopen_forum_topic, delete_forum_topic, unpin_all_forum_topic_messages, + edit_general_forum_topic, + close_general_forum_topic, + reopen_general_forum_topic, + hide_general_forum_topic, + unhide_general_forum_topic, answer_callback_query, set_my_commands, get_my_commands, diff --git a/crates/teloxide-core/src/adaptors/cache_me.rs b/crates/teloxide-core/src/adaptors/cache_me.rs index c2b3537f..ae940f37 100644 --- a/crates/teloxide-core/src/adaptors/cache_me.rs +++ b/crates/teloxide-core/src/adaptors/cache_me.rs @@ -151,6 +151,11 @@ where reopen_forum_topic, delete_forum_topic, unpin_all_forum_topic_messages, + edit_general_forum_topic, + close_general_forum_topic, + reopen_general_forum_topic, + hide_general_forum_topic, + unhide_general_forum_topic, answer_callback_query, set_my_commands, get_my_commands, diff --git a/crates/teloxide-core/src/adaptors/erased.rs b/crates/teloxide-core/src/adaptors/erased.rs index 2041d22c..4d06a22e 100644 --- a/crates/teloxide-core/src/adaptors/erased.rs +++ b/crates/teloxide-core/src/adaptors/erased.rs @@ -240,6 +240,11 @@ where reopen_forum_topic, delete_forum_topic, unpin_all_forum_topic_messages, + edit_general_forum_topic, + close_general_forum_topic, + reopen_general_forum_topic, + hide_general_forum_topic, + unhide_general_forum_topic, answer_callback_query, set_my_commands, get_my_commands, @@ -628,8 +633,6 @@ trait ErasableRequester<'a> { &self, chat_id: Recipient, message_thread_id: i32, - name: String, - icon_custom_emoji_id: String, ) -> ErasedRequest<'a, EditForumTopic, Self::Err>; fn close_forum_topic( @@ -656,6 +659,32 @@ trait ErasableRequester<'a> { message_thread_id: i32, ) -> ErasedRequest<'a, UnpinAllForumTopicMessages, Self::Err>; + fn edit_general_forum_topic( + &self, + chat_id: Recipient, + name: String, + ) -> ErasedRequest<'a, EditGeneralForumTopic, Self::Err>; + + fn close_general_forum_topic( + &self, + chat_id: Recipient, + ) -> ErasedRequest<'a, CloseGeneralForumTopic, Self::Err>; + + fn reopen_general_forum_topic( + &self, + chat_id: Recipient, + ) -> ErasedRequest<'a, ReopenGeneralForumTopic, Self::Err>; + + fn hide_general_forum_topic( + &self, + chat_id: Recipient, + ) -> ErasedRequest<'a, HideGeneralForumTopic, Self::Err>; + + fn unhide_general_forum_topic( + &self, + chat_id: Recipient, + ) -> ErasedRequest<'a, UnhideGeneralForumTopic, Self::Err>; + fn answer_callback_query( &self, callback_query_id: String, @@ -1350,11 +1379,8 @@ where &self, chat_id: Recipient, message_thread_id: i32, - name: String, - icon_custom_emoji_id: String, ) -> ErasedRequest<'a, EditForumTopic, Self::Err> { - Requester::edit_forum_topic(self, chat_id, message_thread_id, name, icon_custom_emoji_id) - .erase() + Requester::edit_forum_topic(self, chat_id, message_thread_id).erase() } fn close_forum_topic( @@ -1389,6 +1415,42 @@ where Requester::unpin_all_forum_topic_messages(self, chat_id, message_thread_id).erase() } + fn edit_general_forum_topic( + &self, + chat_id: Recipient, + name: String, + ) -> ErasedRequest<'a, EditGeneralForumTopic, Self::Err> { + Requester::edit_general_forum_topic(self, chat_id, name).erase() + } + + fn close_general_forum_topic( + &self, + chat_id: Recipient, + ) -> ErasedRequest<'a, CloseGeneralForumTopic, Self::Err> { + Requester::close_general_forum_topic(self, chat_id).erase() + } + + fn reopen_general_forum_topic( + &self, + chat_id: Recipient, + ) -> ErasedRequest<'a, ReopenGeneralForumTopic, Self::Err> { + Requester::reopen_general_forum_topic(self, chat_id).erase() + } + + fn hide_general_forum_topic( + &self, + chat_id: Recipient, + ) -> ErasedRequest<'a, HideGeneralForumTopic, Self::Err> { + Requester::hide_general_forum_topic(self, chat_id).erase() + } + + fn unhide_general_forum_topic( + &self, + chat_id: Recipient, + ) -> ErasedRequest<'a, UnhideGeneralForumTopic, Self::Err> { + Requester::unhide_general_forum_topic(self, chat_id).erase() + } + fn answer_callback_query( &self, callback_query_id: String, diff --git a/crates/teloxide-core/src/adaptors/parse_mode.rs b/crates/teloxide-core/src/adaptors/parse_mode.rs index d69c275b..1d915c9a 100644 --- a/crates/teloxide-core/src/adaptors/parse_mode.rs +++ b/crates/teloxide-core/src/adaptors/parse_mode.rs @@ -149,6 +149,11 @@ impl Requester for DefaultParseMode { close_forum_topic, reopen_forum_topic, delete_forum_topic, + edit_general_forum_topic, + close_general_forum_topic, + reopen_general_forum_topic, + hide_general_forum_topic, + unhide_general_forum_topic, unpin_all_forum_topic_messages, answer_callback_query, set_my_commands, diff --git a/crates/teloxide-core/src/adaptors/throttle/requester_impl.rs b/crates/teloxide-core/src/adaptors/throttle/requester_impl.rs index a0d5965c..02b747e7 100644 --- a/crates/teloxide-core/src/adaptors/throttle/requester_impl.rs +++ b/crates/teloxide-core/src/adaptors/throttle/requester_impl.rs @@ -134,6 +134,11 @@ where reopen_forum_topic, delete_forum_topic, unpin_all_forum_topic_messages, + edit_general_forum_topic, + close_general_forum_topic, + reopen_general_forum_topic, + hide_general_forum_topic, + unhide_general_forum_topic, answer_callback_query, set_my_commands, get_my_commands, diff --git a/crates/teloxide-core/src/adaptors/trace.rs b/crates/teloxide-core/src/adaptors/trace.rs index 189e1c96..4dca2bc5 100644 --- a/crates/teloxide-core/src/adaptors/trace.rs +++ b/crates/teloxide-core/src/adaptors/trace.rs @@ -180,6 +180,11 @@ where reopen_forum_topic, delete_forum_topic, unpin_all_forum_topic_messages, + edit_general_forum_topic, + close_general_forum_topic, + reopen_general_forum_topic, + hide_general_forum_topic, + unhide_general_forum_topic, answer_callback_query, set_my_commands, get_my_commands, diff --git a/crates/teloxide-core/src/bot/api.rs b/crates/teloxide-core/src/bot/api.rs index 8a4b8140..97bc97de 100644 --- a/crates/teloxide-core/src/bot/api.rs +++ b/crates/teloxide-core/src/bot/api.rs @@ -675,21 +675,13 @@ impl Requester for Bot { type EditForumTopic = JsonRequest; - fn edit_forum_topic( - &self, - chat_id: C, - message_thread_id: i32, - name: N, - icon_custom_emoji_id: I, - ) -> Self::EditForumTopic + fn edit_forum_topic(&self, chat_id: C, message_thread_id: i32) -> Self::EditForumTopic where C: Into, - N: Into, - I: Into, { Self::EditForumTopic::new( self.clone(), - payloads::EditForumTopic::new(chat_id, message_thread_id, name, icon_custom_emoji_id), + payloads::EditForumTopic::new(chat_id, message_thread_id), ) } @@ -745,6 +737,71 @@ impl Requester for Bot { ) } + type EditGeneralForumTopic = JsonRequest; + + fn edit_general_forum_topic(&self, chat_id: C, name: N) -> Self::EditGeneralForumTopic + where + C: Into, + N: Into, + { + Self::EditGeneralForumTopic::new( + self.clone(), + payloads::EditGeneralForumTopic::new(chat_id, name), + ) + } + + type CloseGeneralForumTopic = JsonRequest; + + /// For Telegram documentation see [`CloseGeneralForumTopic`]. + fn close_general_forum_topic(&self, chat_id: C) -> Self::CloseGeneralForumTopic + where + C: Into, + { + Self::CloseGeneralForumTopic::new( + self.clone(), + payloads::CloseGeneralForumTopic::new(chat_id), + ) + } + + type ReopenGeneralForumTopic = JsonRequest; + + /// For Telegram documentation see [`ReopenGeneralForumTopic`]. + fn reopen_general_forum_topic(&self, chat_id: C) -> Self::ReopenGeneralForumTopic + where + C: Into, + { + Self::ReopenGeneralForumTopic::new( + self.clone(), + payloads::ReopenGeneralForumTopic::new(chat_id), + ) + } + + type HideGeneralForumTopic = JsonRequest; + + /// For Telegram documentation see [`HideGeneralForumTopic`]. + fn hide_general_forum_topic(&self, chat_id: C) -> Self::HideGeneralForumTopic + where + C: Into, + { + Self::HideGeneralForumTopic::new( + self.clone(), + payloads::HideGeneralForumTopic::new(chat_id), + ) + } + + type UnhideGeneralForumTopic = JsonRequest; + + /// For Telegram documentation see [`UnhideGeneralForumTopic`]. + fn unhide_general_forum_topic(&self, chat_id: C) -> Self::UnhideGeneralForumTopic + where + C: Into, + { + Self::UnhideGeneralForumTopic::new( + self.clone(), + payloads::UnhideGeneralForumTopic::new(chat_id), + ) + } + type AnswerCallbackQuery = JsonRequest; fn answer_callback_query(&self, callback_query_id: C) -> Self::AnswerCallbackQuery diff --git a/crates/teloxide-core/src/codegen.rs b/crates/teloxide-core/src/codegen.rs index 899343f2..fe956bce 100644 --- a/crates/teloxide-core/src/codegen.rs +++ b/crates/teloxide-core/src/codegen.rs @@ -80,7 +80,7 @@ pub fn ensure_files_contents<'a>( for (path, contents) in files_and_contents { if path.exists() { let old_contents = fs::read_to_string(path).unwrap(); - + if normalize_newlines(&old_contents) == normalize_newlines(contents) { // File is already up to date. continue; diff --git a/crates/teloxide-core/src/local_macros.rs b/crates/teloxide-core/src/local_macros.rs index 15884d21..95b31eb0 100644 --- a/crates/teloxide-core/src/local_macros.rs +++ b/crates/teloxide-core/src/local_macros.rs @@ -931,11 +931,9 @@ macro_rules! requester_forward { (@method edit_forum_topic $body:ident $ty:ident) => { type EditForumTopic = $ty![EditForumTopic]; - fn edit_forum_topic(&self, chat_id: C, message_thread_id: i32, name: N, icon_custom_emoji_id: I) -> Self::EditForumTopic where C: Into, - N: Into, - I: Into { + fn edit_forum_topic(&self, chat_id: C, message_thread_id: i32) -> Self::EditForumTopic where C: Into { let this = self; - $body!(edit_forum_topic this (chat_id: C, message_thread_id: i32, name: N, icon_custom_emoji_id: I)) + $body!(edit_forum_topic this (chat_id: C, message_thread_id: i32)) } }; (@method close_forum_topic $body:ident $ty:ident) => { @@ -970,6 +968,47 @@ macro_rules! requester_forward { $body!(unpin_all_forum_topic_messages this (chat_id: C, message_thread_id: i32)) } }; + (@method edit_general_forum_topic $body:ident $ty:ident) => { + type EditGeneralForumTopic = $ty![EditGeneralForumTopic]; + + fn edit_general_forum_topic(&self, chat_id: C, name: N) -> Self::EditGeneralForumTopic where C: Into, + N: Into { + let this = self; + $body!(edit_general_forum_topic this (chat_id: C, name: N)) + } + }; + (@method close_general_forum_topic $body:ident $ty:ident) => { + type CloseGeneralForumTopic = $ty![CloseGeneralForumTopic]; + + fn close_general_forum_topic(&self, chat_id: C) -> Self::CloseGeneralForumTopic where C: Into { + let this = self; + $body!(close_general_forum_topic this (chat_id: C)) + } + }; + (@method reopen_general_forum_topic $body:ident $ty:ident) => { + type ReopenGeneralForumTopic = $ty![ReopenGeneralForumTopic]; + + fn reopen_general_forum_topic(&self, chat_id: C) -> Self::ReopenGeneralForumTopic where C: Into { + let this = self; + $body!(reopen_general_forum_topic this (chat_id: C)) + } + }; + (@method hide_general_forum_topic $body:ident $ty:ident) => { + type HideGeneralForumTopic = $ty![HideGeneralForumTopic]; + + fn hide_general_forum_topic(&self, chat_id: C) -> Self::HideGeneralForumTopic where C: Into { + let this = self; + $body!(hide_general_forum_topic this (chat_id: C)) + } + }; + (@method unhide_general_forum_topic $body:ident $ty:ident) => { + type UnhideGeneralForumTopic = $ty![UnhideGeneralForumTopic]; + + fn unhide_general_forum_topic(&self, chat_id: C) -> Self::UnhideGeneralForumTopic where C: Into { + let this = self; + $body!(unhide_general_forum_topic this (chat_id: C)) + } + }; (@method answer_callback_query $body:ident $ty:ident) => { type AnswerCallbackQuery = $ty![AnswerCallbackQuery]; diff --git a/crates/teloxide-core/src/payloads.rs b/crates/teloxide-core/src/payloads.rs index b74b1fb4..2f4d7e08 100644 --- a/crates/teloxide-core/src/payloads.rs +++ b/crates/teloxide-core/src/payloads.rs @@ -26,6 +26,7 @@ mod ban_chat_member; mod ban_chat_sender_chat; mod close; mod close_forum_topic; +mod close_general_forum_topic; mod copy_message; mod create_chat_invite_link; mod create_forum_topic; @@ -41,6 +42,7 @@ mod delete_sticker_from_set; mod delete_webhook; mod edit_chat_invite_link; mod edit_forum_topic; +mod edit_general_forum_topic; mod edit_message_caption; mod edit_message_caption_inline; mod edit_message_live_location; @@ -70,12 +72,14 @@ mod get_sticker_set; mod get_updates; mod get_user_profile_photos; mod get_webhook_info; +mod hide_general_forum_topic; mod kick_chat_member; mod leave_chat; mod log_out; mod pin_chat_message; mod promote_chat_member; mod reopen_forum_topic; +mod reopen_general_forum_topic; mod restrict_chat_member; mod revoke_chat_invite_link; mod send_animation; @@ -116,6 +120,7 @@ mod stop_message_live_location_inline; mod stop_poll; mod unban_chat_member; mod unban_chat_sender_chat; +mod unhide_general_forum_topic; mod unpin_all_chat_messages; mod unpin_all_forum_topic_messages; mod unpin_chat_message; @@ -132,6 +137,7 @@ pub use ban_chat_member::{BanChatMember, BanChatMemberSetters}; pub use ban_chat_sender_chat::{BanChatSenderChat, BanChatSenderChatSetters}; pub use close::{Close, CloseSetters}; pub use close_forum_topic::{CloseForumTopic, CloseForumTopicSetters}; +pub use close_general_forum_topic::{CloseGeneralForumTopic, CloseGeneralForumTopicSetters}; pub use copy_message::{CopyMessage, CopyMessageSetters}; pub use create_chat_invite_link::{CreateChatInviteLink, CreateChatInviteLinkSetters}; pub use create_forum_topic::{CreateForumTopic, CreateForumTopicSetters}; @@ -147,6 +153,7 @@ pub use delete_sticker_from_set::{DeleteStickerFromSet, DeleteStickerFromSetSett pub use delete_webhook::{DeleteWebhook, DeleteWebhookSetters}; pub use edit_chat_invite_link::{EditChatInviteLink, EditChatInviteLinkSetters}; pub use edit_forum_topic::{EditForumTopic, EditForumTopicSetters}; +pub use edit_general_forum_topic::{EditGeneralForumTopic, EditGeneralForumTopicSetters}; pub use edit_message_caption::{EditMessageCaption, EditMessageCaptionSetters}; pub use edit_message_caption_inline::{EditMessageCaptionInline, EditMessageCaptionInlineSetters}; pub use edit_message_live_location::{EditMessageLiveLocation, EditMessageLiveLocationSetters}; @@ -184,12 +191,14 @@ pub use get_sticker_set::{GetStickerSet, GetStickerSetSetters}; pub use get_updates::{GetUpdates, GetUpdatesSetters}; pub use get_user_profile_photos::{GetUserProfilePhotos, GetUserProfilePhotosSetters}; pub use get_webhook_info::{GetWebhookInfo, GetWebhookInfoSetters}; +pub use hide_general_forum_topic::{HideGeneralForumTopic, HideGeneralForumTopicSetters}; pub use kick_chat_member::{KickChatMember, KickChatMemberSetters}; pub use leave_chat::{LeaveChat, LeaveChatSetters}; pub use log_out::{LogOut, LogOutSetters}; 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 restrict_chat_member::{RestrictChatMember, RestrictChatMemberSetters}; pub use revoke_chat_invite_link::{RevokeChatInviteLink, RevokeChatInviteLinkSetters}; pub use send_animation::{SendAnimation, SendAnimationSetters}; @@ -236,6 +245,7 @@ pub use stop_message_live_location_inline::{ pub use stop_poll::{StopPoll, StopPollSetters}; pub use unban_chat_member::{UnbanChatMember, UnbanChatMemberSetters}; pub use unban_chat_sender_chat::{UnbanChatSenderChat, UnbanChatSenderChatSetters}; +pub use unhide_general_forum_topic::{UnhideGeneralForumTopic, UnhideGeneralForumTopicSetters}; pub use unpin_all_chat_messages::{UnpinAllChatMessages, UnpinAllChatMessagesSetters}; pub use unpin_all_forum_topic_messages::{ UnpinAllForumTopicMessages, UnpinAllForumTopicMessagesSetters, diff --git a/crates/teloxide-core/src/payloads/close_general_forum_topic.rs b/crates/teloxide-core/src/payloads/close_general_forum_topic.rs new file mode 100644 index 00000000..d211f0d8 --- /dev/null +++ b/crates/teloxide-core/src/payloads/close_general_forum_topic.rs @@ -0,0 +1,16 @@ +//! Generated by `codegen_payloads`, do not edit by hand. + +use serde::Serialize; + +use crate::types::{Recipient, True}; + +impl_payload! { + /// Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_manage\_topics_ administrator rights. Returns True on success. + #[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)] + pub CloseGeneralForumTopic (CloseGeneralForumTopicSetters) => True { + required { + /// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) + pub chat_id: Recipient [into], + } + } +} diff --git a/crates/teloxide-core/src/payloads/edit_forum_topic.rs b/crates/teloxide-core/src/payloads/edit_forum_topic.rs index 8cbcf916..dd311dea 100644 --- a/crates/teloxide-core/src/payloads/edit_forum_topic.rs +++ b/crates/teloxide-core/src/payloads/edit_forum_topic.rs @@ -13,9 +13,11 @@ impl_payload! { pub chat_id: Recipient [into], /// Unique identifier for the target message thread of the forum topic pub message_thread_id: i32, - /// Topic name, 1-128 characters + } + optional { + /// Topic name, 0-128 characters. If not specified or empty, the current name of the topic will be kept pub name: String [into], - /// Unique identifier of the custom emoji shown as the topic icon. Use `getForumTopicIconStickers` to get all allowed custom emoji identifiers. + /// Unique identifier of the custom emoji shown as the topic icon. Use `getForumTopicIconStickers` to get all allowed custom emoji identifiers. Pass an empty string to remove the icon. If not specified, the current icon will be kept pub icon_custom_emoji_id: String [into], } } diff --git a/crates/teloxide-core/src/payloads/edit_general_forum_topic.rs b/crates/teloxide-core/src/payloads/edit_general_forum_topic.rs new file mode 100644 index 00000000..3f593e7c --- /dev/null +++ b/crates/teloxide-core/src/payloads/edit_general_forum_topic.rs @@ -0,0 +1,18 @@ +//! Generated by `codegen_payloads`, do not edit by hand. + +use serde::Serialize; + +use crate::types::{Recipient, True}; + +impl_payload! { + /// Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have _can\_manage\_topics_ administrator rights. Returns True on success. + #[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)] + pub EditGeneralForumTopic (EditGeneralForumTopicSetters) => True { + required { + /// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) + pub chat_id: Recipient [into], + /// New topic name, 1-128 characters + pub name: String [into], + } + } +} diff --git a/crates/teloxide-core/src/payloads/hide_general_forum_topic.rs b/crates/teloxide-core/src/payloads/hide_general_forum_topic.rs new file mode 100644 index 00000000..014061a7 --- /dev/null +++ b/crates/teloxide-core/src/payloads/hide_general_forum_topic.rs @@ -0,0 +1,16 @@ +//! Generated by `codegen_payloads`, do not edit by hand. + +use serde::Serialize; + +use crate::types::{Recipient, True}; + +impl_payload! { + /// Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_manage\_topics_ administrator rights. The topic will be automatically closed if it was open. Returns True on success. + #[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)] + pub HideGeneralForumTopic (HideGeneralForumTopicSetters) => True { + required { + /// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) + pub chat_id: Recipient [into], + } + } +} diff --git a/crates/teloxide-core/src/payloads/reopen_general_forum_topic.rs b/crates/teloxide-core/src/payloads/reopen_general_forum_topic.rs new file mode 100644 index 00000000..09fe1f2b --- /dev/null +++ b/crates/teloxide-core/src/payloads/reopen_general_forum_topic.rs @@ -0,0 +1,16 @@ +//! Generated by `codegen_payloads`, do not edit by hand. + +use serde::Serialize; + +use crate::types::{Recipient, True}; + +impl_payload! { + /// Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_manage\_topics_ administrator rights. The topic will be automatically unhidden if it was hidden. Returns True on success. + #[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)] + pub ReopenGeneralForumTopic (ReopenGeneralForumTopicSetters) => True { + required { + /// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) + pub chat_id: Recipient [into], + } + } +} diff --git a/crates/teloxide-core/src/payloads/send_animation.rs b/crates/teloxide-core/src/payloads/send_animation.rs index b6bc5b7f..3c4e487d 100644 --- a/crates/teloxide-core/src/payloads/send_animation.rs +++ b/crates/teloxide-core/src/payloads/send_animation.rs @@ -42,6 +42,8 @@ impl_payload! { pub parse_mode: ParseMode, /// List of special entities that appear in the photo caption, which can be specified instead of _parse\_mode_ pub caption_entities: Vec [collect], + /// Pass True if the animation needs to be covered with a spoiler animation + pub has_spoiler: bool, /// Sends the message [silently]. Users will receive a notification with no sound. /// /// [silently]: https://telegram.org/blog/channels-2-0#silent-messages diff --git a/crates/teloxide-core/src/payloads/send_chat_action.rs b/crates/teloxide-core/src/payloads/send_chat_action.rs index a3acd43e..50b4c3db 100644 --- a/crates/teloxide-core/src/payloads/send_chat_action.rs +++ b/crates/teloxide-core/src/payloads/send_chat_action.rs @@ -29,5 +29,9 @@ impl_payload! { /// [video notes]: crate::payloads::SendVideoNote pub action: ChatAction, } + optional { + /// Unique identifier for the target message thread; supergroups only + pub message_thread_id: i32, + } } } diff --git a/crates/teloxide-core/src/payloads/send_photo.rs b/crates/teloxide-core/src/payloads/send_photo.rs index 77399f1c..70e97bea 100644 --- a/crates/teloxide-core/src/payloads/send_photo.rs +++ b/crates/teloxide-core/src/payloads/send_photo.rs @@ -32,6 +32,8 @@ impl_payload! { pub parse_mode: ParseMode, /// List of special entities that appear in the photo caption, which can be specified instead of _parse\_mode_ pub caption_entities: Vec [collect], + /// Pass True if the photo needs to be covered with a spoiler animation + pub has_spoiler: bool, /// Sends the message [silently]. Users will receive a notification with no sound. /// /// [silently]: https://telegram.org/blog/channels-2-0#silent-messages diff --git a/crates/teloxide-core/src/payloads/send_video.rs b/crates/teloxide-core/src/payloads/send_video.rs index 9eb0f307..2723e6e4 100644 --- a/crates/teloxide-core/src/payloads/send_video.rs +++ b/crates/teloxide-core/src/payloads/send_video.rs @@ -43,6 +43,8 @@ impl_payload! { pub parse_mode: ParseMode, /// List of special entities that appear in the caption, which can be specified instead of _parse\_mode_ pub caption_entities: Vec [collect], + /// Pass True if the video needs to be covered with a spoiler animation + pub has_spoiler: bool, /// Pass _True_, if the uploaded video is suitable for streaming pub supports_streaming: bool, /// Sends the message [silently]. Users will receive a notification with no sound. diff --git a/crates/teloxide-core/src/payloads/setters.rs b/crates/teloxide-core/src/payloads/setters.rs index d111970f..ac2a626f 100644 --- a/crates/teloxide-core/src/payloads/setters.rs +++ b/crates/teloxide-core/src/payloads/setters.rs @@ -5,13 +5,13 @@ pub use crate::payloads::{ AddStickerToSetSetters as _, AnswerCallbackQuerySetters as _, AnswerInlineQuerySetters as _, AnswerPreCheckoutQuerySetters as _, AnswerShippingQuerySetters as _, AnswerWebAppQuerySetters as _, ApproveChatJoinRequestSetters as _, BanChatMemberSetters as _, - BanChatSenderChatSetters as _, CloseForumTopicSetters as _, CloseSetters as _, - CopyMessageSetters as _, CreateChatInviteLinkSetters as _, CreateForumTopicSetters as _, - CreateInvoiceLinkSetters as _, CreateNewStickerSetSetters as _, + BanChatSenderChatSetters as _, CloseForumTopicSetters as _, CloseGeneralForumTopicSetters as _, + CloseSetters as _, CopyMessageSetters as _, CreateChatInviteLinkSetters as _, + CreateForumTopicSetters as _, CreateInvoiceLinkSetters as _, CreateNewStickerSetSetters as _, DeclineChatJoinRequestSetters as _, DeleteChatPhotoSetters as _, DeleteChatStickerSetSetters as _, DeleteForumTopicSetters as _, DeleteMessageSetters as _, DeleteMyCommandsSetters as _, DeleteStickerFromSetSetters as _, DeleteWebhookSetters as _, - EditChatInviteLinkSetters as _, EditForumTopicSetters as _, + EditChatInviteLinkSetters as _, EditForumTopicSetters as _, EditGeneralForumTopicSetters as _, EditMessageCaptionInlineSetters as _, EditMessageCaptionSetters as _, EditMessageLiveLocationInlineSetters as _, EditMessageLiveLocationSetters as _, EditMessageMediaInlineSetters as _, EditMessageMediaSetters as _, @@ -23,12 +23,13 @@ pub use crate::payloads::{ GetCustomEmojiStickersSetters as _, GetFileSetters as _, GetForumTopicIconStickersSetters as _, GetGameHighScoresSetters as _, GetMeSetters as _, GetMyCommandsSetters as _, GetMyDefaultAdministratorRightsSetters as _, GetStickerSetSetters as _, GetUpdatesSetters as _, - GetUserProfilePhotosSetters as _, GetWebhookInfoSetters as _, KickChatMemberSetters as _, - LeaveChatSetters as _, LogOutSetters as _, PinChatMessageSetters as _, - PromoteChatMemberSetters as _, ReopenForumTopicSetters as _, RestrictChatMemberSetters as _, - RevokeChatInviteLinkSetters as _, SendAnimationSetters as _, SendAudioSetters as _, - SendChatActionSetters as _, SendContactSetters as _, SendDiceSetters as _, - SendDocumentSetters as _, SendGameSetters as _, SendInvoiceSetters as _, + GetUserProfilePhotosSetters as _, 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 _, SendLocationSetters as _, SendMediaGroupSetters as _, SendMessageSetters as _, SendPhotoSetters as _, SendPollSetters as _, SendStickerSetters as _, SendVenueSetters as _, SendVideoNoteSetters as _, SendVideoSetters as _, SendVoiceSetters as _, @@ -40,6 +41,7 @@ pub use crate::payloads::{ SetStickerPositionInSetSetters as _, SetStickerSetThumbSetters as _, SetWebhookSetters as _, StopMessageLiveLocationInlineSetters as _, StopMessageLiveLocationSetters as _, StopPollSetters as _, UnbanChatMemberSetters as _, UnbanChatSenderChatSetters as _, - UnpinAllChatMessagesSetters as _, UnpinAllForumTopicMessagesSetters as _, - UnpinChatMessageSetters as _, UploadStickerFileSetters as _, + UnhideGeneralForumTopicSetters as _, UnpinAllChatMessagesSetters as _, + UnpinAllForumTopicMessagesSetters as _, UnpinChatMessageSetters as _, + UploadStickerFileSetters as _, }; diff --git a/crates/teloxide-core/src/payloads/unhide_general_forum_topic.rs b/crates/teloxide-core/src/payloads/unhide_general_forum_topic.rs new file mode 100644 index 00000000..640e4737 --- /dev/null +++ b/crates/teloxide-core/src/payloads/unhide_general_forum_topic.rs @@ -0,0 +1,16 @@ +//! Generated by `codegen_payloads`, do not edit by hand. + +use serde::Serialize; + +use crate::types::{Recipient, True}; + +impl_payload! { + /// Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_manage\_topics_ administrator rights. Returns True on success. + #[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)] + pub UnhideGeneralForumTopic (UnhideGeneralForumTopicSetters) => True { + required { + /// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) + pub chat_id: Recipient [into], + } + } +} diff --git a/crates/teloxide-core/src/requests/requester.rs b/crates/teloxide-core/src/requests/requester.rs index 974c4f66..5c0c64d5 100644 --- a/crates/teloxide-core/src/requests/requester.rs +++ b/crates/teloxide-core/src/requests/requester.rs @@ -682,17 +682,9 @@ pub trait Requester { type EditForumTopic: Request; /// For Telegram documentation see [`EditForumTopic`]. - fn edit_forum_topic( - &self, - chat_id: C, - message_thread_id: i32, - name: N, - icon_custom_emoji_id: I, - ) -> Self::EditForumTopic + fn edit_forum_topic(&self, chat_id: C, message_thread_id: i32) -> Self::EditForumTopic where - C: Into, - N: Into, - I: Into; + C: Into; type CloseForumTopic: Request; @@ -726,6 +718,42 @@ pub trait Requester { where C: Into; + type EditGeneralForumTopic: Request; + + /// For Telegram documentation see [`EditGeneralForumTopic`]. + fn edit_general_forum_topic(&self, chat_id: C, name: N) -> Self::EditGeneralForumTopic + where + C: Into, + N: Into; + + type CloseGeneralForumTopic: Request; + + /// For Telegram documentation see [`CloseGeneralForumTopic`]. + fn close_general_forum_topic(&self, chat_id: C) -> Self::CloseGeneralForumTopic + where + C: Into; + + type ReopenGeneralForumTopic: Request; + + /// For Telegram documentation see [`ReopenGeneralForumTopic`]. + fn reopen_general_forum_topic(&self, chat_id: C) -> Self::ReopenGeneralForumTopic + where + C: Into; + + type HideGeneralForumTopic: Request; + + /// For Telegram documentation see [`HideGeneralForumTopic`]. + fn hide_general_forum_topic(&self, chat_id: C) -> Self::HideGeneralForumTopic + where + C: Into; + + type UnhideGeneralForumTopic: Request; + + /// For Telegram documentation see [`UnhideGeneralForumTopic`]. + fn unhide_general_forum_topic(&self, chat_id: C) -> Self::UnhideGeneralForumTopic + where + C: Into; + type AnswerCallbackQuery: Request; /// For Telegram documentation see [`AnswerCallbackQuery`]. @@ -1177,6 +1205,11 @@ macro_rules! forward_all { reopen_forum_topic, delete_forum_topic, unpin_all_forum_topic_messages, + edit_general_forum_topic, + close_general_forum_topic, + reopen_general_forum_topic, + hide_general_forum_topic, + unhide_general_forum_topic, answer_callback_query, set_my_commands, get_my_commands,